How to use the babel-types.callExpression 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 GridProtectionAlliance / openHistorian-grafana / node_modules / regenerator-transform / src / visit.js View on Github external
// Babylon represents directives like "use strict" as elements of
        // a bodyBlockPath.node.directives array. (#248)
        node.body.directives = oldDirectives;
      }

      let wasGeneratorFunction = node.generator;
      if (wasGeneratorFunction) {
        node.generator = false;
      }

      if (node.async) {
        node.async = false;
      }

      if (wasGeneratorFunction && t.isExpression(node)) {
        util.replaceWithOrRemove(path, t.callExpression(util.runtimeProperty("mark"), [node]))
        path.addComment("leading", "#__PURE__");
      }

      // Generators are processed in 'exit' handlers so that regenerator only has to run on
      // an ES5 AST, but that means traversal will not pick up newly inserted references
      // to things like 'regeneratorRuntime'. To avoid this, we explicitly requeue.
      path.requeue();
    }
  }
github babel / babel / packages / babel-helper-builder-react-jsx / src / index.js View on Github external
if (objs.length === 1) {
      // only one object
      attribs = objs[0];
    } else {
      // looks like we have multiple objects
      if (!t.isObjectExpression(objs[0])) {
        objs.unshift(t.objectExpression([]));
      }

      const helper = useBuiltIns ?
        t.memberExpression(t.identifier("Object"), t.identifier("assign")) :
        file.addHelper("extends");

      // spread it
      attribs = t.callExpression(helper, objs);
    }

    return attribs;
  }
}
github dwqs / vue-to-react / src / react-ast-helpers.js View on Github external
exports.genConstructor = function genConstructor (path, state) {
    const nodeLists = path.node.body;
    const blocks = [
        t.expressionStatement(t.callExpression(t.super(), [t.identifier('props')]))
    ];
    if (state.data['_statements']) {
        state.data['_statements'].forEach(node => {
            if (t.isReturnStatement(node)) {
                const props = node.argument.properties;
                // supports init data property with props property
                props.forEach(n => {
                    if (t.isMemberExpression(n.value)) {
                        n.value = t.memberExpression(t.identifier('props'), t.identifier(n.value.property.name));
                    }
                });

                blocks.push(
                    t.expressionStatement(t.assignmentExpression('=', t.memberExpression(t.thisExpression(), t.identifier('state')), node.argument))
                );
            } else {
github NervJS / taro / packages / taro-transformer-wx / src / index.ts View on Github external
if (callee.isReferencedIdentifier()) {
        const id = callee.node
        const ids = [id.name]
        if (t.isIdentifier(id) && id.name.startsWith('on')) {
          const funcExpr = path.findParent(p => p.isFunctionExpression())
          if (funcExpr && funcExpr.isFunctionExpression()) {
            const taroAPI = funcExpr.findParent(p => p.isCallExpression() && t.isMemberExpression(p.node.callee) && t.isIdentifier(p.node.callee.object, { name: 'Taro' }))
            if (taroAPI && taroAPI.isCallExpression()) {
              throw codeFrameError(funcExpr.node, '在回调函数使用从 props 传递的函数时,请把回调函数改造为箭头函数并一直使用 `this` 取值')
            }
          }
          const fullPath = buildFullPathThisPropsRef(id, ids, path)
          if (fullPath) {
            path.replaceWith(
              t.callExpression(
                fullPath,
                path.node.arguments
              )
            )
          }
        }
      }
    },
    // JSXIdentifier (path) {
github MuYunyun / reactSPA / node_modules / regenerator-transform / src / visit.js View on Github external
// Babylon represents directives like "use strict" as elements of
        // a bodyBlockPath.node.directives array. (#248)
        node.body.directives = oldDirectives;
      }

      let wasGeneratorFunction = node.generator;
      if (wasGeneratorFunction) {
        node.generator = false;
      }

      if (node.async) {
        node.async = false;
      }

      if (wasGeneratorFunction && t.isExpression(node)) {
        path.replaceWith(t.callExpression(util.runtimeProperty("mark"), [node]));
      }

      // Generators are processed in 'exit' handlers so that regenerator only has to run on
      // an ES5 AST, but that means traversal will not pick up newly inserted references
      // to things like 'regeneratorRuntime'. To avoid this, we explicitly requeue.
      path.requeue();
    }
  }
github Tencent / omi / packages / omip / my-app / scripts / taro-cli / src / h5.js View on Github external
})
          root = rootNode ? rootNode.value.value : ''
        }
        value.elements.forEach(v => {
          const pagePath = `${root}/${v.value}`.replace(/\/{2,}/g, '/')
          pages.push(pagePath.replace(/^\//, ''))
        })
      } else if (keyName === 'tabBar' && t.isObjectExpression(value)) {
        // tabBar
        tabBar = value
        value.properties.forEach(node => {
          if (node.keyName === 'position') tabbarPos = node.value.value
        })
      } else if ((keyName === 'iconPath' || keyName === 'selectedIconPath') && t.isStringLiteral(value)) {
        astPath.replaceWith(
          t.objectProperty(t.stringLiteral(keyName), t.callExpression(t.identifier('require'), [t.stringLiteral(`./${value.value}`)]))
        )
      }
    }
  }
github plasma-umass / Stopify / src / recursiveCPS.js View on Github external
const cpsBodyStatements = cps(body.body, path).map((x) => {
        if (t.isReturnStatement(x)) {
          return t.returnStatement(t.callExpression(continuation, x.argument));
        }
        return x;
      });
      const cpsBody = t.blockStatement(cpsBodyStatements);
github ben-eb / css-values / src / generators / property.js View on Github external
validIdentifier,
            t.booleanLiteral(true)
        ));

        if (validatorKeys.length) {
            body.unshift(
                firstValueParserNode,
                ifAllTruthy([
                    valueParserNodesLength(1),
                ], validatorList)
            );
        }

        body.push(
            t.expressionStatement(
                t.callExpression(
                    t.memberExpression(
                        valueParserASTIdentifier,
                        t.identifier('walk')
                    ), [
                        t.arrowFunctionExpression([
                            nodeIdentifier,
                            indexIdentifier,
                        ], t.blockStatement([
                            t.ifStatement(
                                t.binaryExpression(
                                    '!==',
                                    validIdentifier,
                                    t.booleanLiteral(true)
                                ),
                                t.blockStatement([
                                    t.returnStatement(),
github babel / babel / packages / babel-core / src / transformation / transformers / es7 / decorators.js View on Github external
if (prop.decorators) memoiseDecorators(prop.decorators, scope);


      if (prop.kind === "init" && !prop.method) {
        prop.kind = "";
        prop.value = t.functionExpression(null, [], t.blockStatement([
          t.returnStatement(prop.value)
        ]));
      }

      defineMap.push(mutatorMap, prop, "initializer", file);
    }

    var obj = defineMap.toClassObject(mutatorMap);
    obj = defineMap.toComputedObjectFromClass(obj);
    return t.callExpression(file.addHelper("create-decorated-object"), [obj]);
  }
};
github bradtraversy / youtube_es2015_source / 01_babel / node_modules / babel-plugin-transform-regenerator / src / emit.js View on Github external
keyIterNextFn,
      t.callExpression(
        util.runtimeProperty("keys"),
        [self.explodeExpression(path.get("right"))]
      )
    );

    self.mark(head);

    let keyInfoTmpVar = self.makeTempVar();
    self.jumpIf(
      t.memberExpression(
        t.assignmentExpression(
          "=",
          keyInfoTmpVar,
          t.callExpression(keyIterNextFn, [])
        ),
        t.identifier("done"),
        false
      ),
      after
    );

    self.emitAssign(
      stmt.left,
      t.memberExpression(
        keyInfoTmpVar,
        t.identifier("value"),
        false
      )
    );