How to use the babel-types.blockStatement function in babel-types

To help you get started, we’ve selected a few babel-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Tencent / omi / packages / omip / my-app-ts / scripts / taro-cli / src / h5.js View on Github external
exit (astPath) {
        if (hasComponentDidShow && !hasComponentDidMount) {
          astPath.pushContainer('body', t.classMethod(
            'method', t.identifier('componentDidMount'), [],
            t.blockStatement([]), false, false))
        }
        if (hasComponentDidHide && !hasComponentWillUnmount) {
          astPath.pushContainer('body', t.classMethod(
            'method', t.identifier('componentWillUnmount'), [],
            t.blockStatement([]), false, false))
        }
        //@fix
        // if (!hasConstructor) {
        //   astPath.pushContainer('body', t.classMethod(
        //     'method', t.identifier('constructor'), [t.identifier('props'), t.identifier('context')],
        //     t.blockStatement([toAst('super(props, context)'), additionalConstructorNode]), false, false))
        // }
        if (tabBar) {
          if (!hasComponentWillMount) {
            astPath.pushContainer('body', t.classMethod(
              'method', t.identifier('componentWillMount'), [],
github plasma-umass / Stopify / src / yieldDebug / yieldDebug.ts View on Github external
enter: function (path: NodePath>): void {

    // Set line mapping
    if(path.node.lineMapping) {
      lineMapping = path.node.lineMapping
    } else {
      // NOTE(rachit): This can't actually happen
      throw new Error('No line mapping found')
    }

    // Wrap program into a function.
    const prog = path.node.body;
    const func = t.functionDeclaration(
      t.identifier('$runProg'), [], t.blockStatement(prog))
    path.node.body = [func]
  },
  exit: function (path: NodePath): void {
github robotlolita / metamagical / experimental / markdown / src / index.js View on Github external
function functionFromExamples(sources, options) {
  const body = flatten(sources.map(s => parseJs(s).program.body));

  const { _code, _map, ast } = babel.transformFromAst(t.program(body), null, options);

  return new Raw(t.functionExpression(
    null,
    [],
    t.blockStatement(ast.program.body)
  ));
}
github bfrgoncalves / Online-PhyloViZ / node_modules / l / node_modules / jsdom / node_modules / cssstyle / scripts / generate_properties.js View on Github external
t.objectExpression(
      propertyDefinitions
    )
  ]
);
statements.push(t.expressionStatement(
  t.assignmentExpression(
    '=',
    t.memberExpression(
      t.identifier('module'),
      t.identifier('exports')
    ),
    t.functionExpression(
      null,
      [t.identifier('prototype')],
      t.blockStatement([t.expressionStatement(definePropertiesCall)])
    )
  )
));
out_file.write(generate(t.program(statements)).code + '\n')
out_file.end(function (err) {
    if (err) {
        throw err;
    }
});
github Tencent / omi / packages / cax-omip / scripts / taro-transformer-wx / lib / src / class.js View on Github external
function buildConstructor() {
    const ctor = t.classMethod('constructor', t.identifier('constructor'), [t.identifier('props')], t.blockStatement([
        t.expressionStatement(t.callExpression(t.identifier('super'), [
            t.identifier('props')
        ]))
    ]));
    return ctor;
}
function processThisPropsFnMemberProperties(member, path, args, binded) {
github eps1lon / poe-db / src / model / SequelizeModelAst.js View on Github external
exportBody() {
    return t.blockStatement([
      this.modelDefinition(),
      this.associate(),
      this.datFileGetter(),
      t.returnStatement(t.identifier('model')),
    ]);
  }
github trivago / melody / packages / melody-compiler / src / convert / template.js View on Github external
t.memberExpression(
                                    t.identifier(this.templateVariableName),
                                    t.identifier('displayName')
                                ),
                                t.stringLiteral(fileName)
                            )
                        ),
                    ])
                )
            );
            this.program.body.push(
                t.exportDefaultDeclaration(
                    t.functionDeclaration(
                        t.identifier(fileName),
                        [t.identifier('props')],
                        t.blockStatement([
                            t.returnStatement(
                                t.callExpression(
                                    t.memberExpression(
                                        t.identifier(this.templateVariableName),
                                        t.identifier('render')
                                    ),
                                    [t.identifier('props')]
                                )
                            ),
                        ])
                    )
                    //t.identifier(this.templateVariableName),
                )
            );
            path.replaceWithJS(this.program);
        },
github ben-eb / css-values / src / generators / property.js View on Github external
function getValidatorResult (identifier, cache) {
    const result = t.identifier(`${identifier}Result`);
    return [
        createConst(result, cache),
        t.ifStatement(
            callExpression(
                'shouldReturnResult',
                result
            ),
            t.blockStatement([
                t.returnStatement(result),
            ])
        ),
    ];
}
github babel / babel / packages / babel-core / src / transformation / transformers / es7 / comprehensions.js View on Github external
function generator(node) {
  var body = [];
  var container = t.functionExpression(null, [], t.blockStatement(body), true);
  container.shadow = true;

  body.push(buildComprehension(node, function () {
    return t.expressionStatement(t.yieldExpression(node.body));
  }));

  return t.callExpression(container, []);
}