How to use the babel-types.memberExpression 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 / taro-transformer-wx / __tests__ / utils.ts View on Github external
key
        ),
        value
      )))
      path.remove()
    }
  })

  for (const method of mainClass.body.body) {
    // constructor 即便没有被定义也会被加上
    if (t.isClassMethod(method) && method.kind === 'constructor') {
      const index = method.body.body.findIndex(node => t.isSuper(node))
      method.body.body.push(
        t.expressionStatement(t.assignmentExpression(
          '=',
          t.memberExpression(
            t.thisExpression(),
            t.identifier('state')
          ),
          t.callExpression(t.memberExpression(t.thisExpression(), t.identifier('_createData')), [])
        ))
      )
      method.body.body.splice(index, 0, ...statements)
    }
  }

  let code = `function f() {};` +
    generate(t.classDeclaration(t.identifier('Test'), t.identifier('f'), mainClass.body, [])).code +
    ';' + `new Test(${props})`

  code = internalFunction + code
github alibaba / rax / packages / sfc-loader / src / transform / script.js View on Github external
t.variableDeclaration('var', [
                t.variableDeclarator(
                  t.identifier(declarationName),
                  t.objectExpression([])
                )
              ])
            );
          }

          // 初始化 _global
          path.pushContainer(
            'body',
            t.expressionStatement(
              t.assignmentExpression(
                '=',
                t.memberExpression(
                  t.identifier(declarationName),
                  t.identifier('_global')
                ),
                t.objectExpression([])
              )
            )
          );

          Object.keys(scope.getAllBindings()).forEach(key => {
            path.pushContainer(
              'body',
              t.expressionStatement(
                t.assignmentExpression(
                  '=',
                  t.memberExpression(
                    t.memberExpression(
github babel / babel / packages / babel-helper-builder-react-jsx / src / index.js View on Github external
}
    }

    pushProps();

    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 plasma-umass / Stopify / src / callcc / stopifyCallCC.ts View on Github external
function appCallCC(receiver: t.Expression) {
  return t.callExpression(
    t.memberExpression(t.identifier("$__R"), t.identifier("callCC")),
    [receiver]);
}
github babel / babel / packages / babel-plugin-transform-regenerator / src / visit.js View on Github external
function getRuntimeMarkDecl(blockPath) {
  let block = blockPath.node;
  assert.ok(Array.isArray(block.body));

  let info = getMarkInfo(block);
  if (info.decl) {
    return info.decl;
  }

  info.decl = t.variableDeclaration("var", [
    t.variableDeclarator(
      blockPath.scope.generateUidIdentifier("marked"),
      t.callExpression(
        t.memberExpression(
          t.arrayExpression([]),
          t.identifier("map"),
          false
        ),
        [util.runtimeProperty("mark")]
      )
    )
  ]);

  blockPath.unshiftContainer("body", info.decl);

  return info.decl;
}
github babel / babel / packages / babel-plugin-transform-regenerator / src / visit.js View on Github external
return path.isProgram() || path.isBlockStatement();
    });

    if (!pp) {
      return node.id;
    }

    let markDecl = getRuntimeMarkDecl(pp);
    let markedArray = markDecl.declarations[0].id;
    let funDeclIdArray = markDecl.declarations[0].init.callee.object;
    t.assertArrayExpression(funDeclIdArray);

    let index = funDeclIdArray.elements.length;
    funDeclIdArray.elements.push(node.id);

    return t.memberExpression(
      markedArray,
      t.numericLiteral(index),
      true
    );
  }

  return node.id;
}
github whitecolor / babel-plugin-cycle-circular / src / rx.js View on Github external
const getSubFinallyExpression = function(proxyIdentifier, subIdentifier){
  const disposeExpression = t.callExpression(
    t.memberExpression(subIdentifier, t.identifier('dispose')),
    []
  )
  let observersCount = t.memberExpression(proxyIdentifier, t.identifier('observers.length'));
  const condition = t.ifStatement(
    t.binaryExpression("===", observersCount, t.identifier('0')),
    t.expressionStatement(disposeExpression)
  )
  return t.callExpression(
    t.memberExpression(proxyIdentifier, t.identifier('finally')),
    [t.arrowFunctionExpression([], t.blockStatement([condition]))]
  )
}
github NervJS / taro / packages / taroize / src / script.ts View on Github external
'method',
          t.identifier(Lifecycle.componentWillMount),
          [],
          t.blockStatement([globalData])
        )
      )
    }
  }

  const wxsNames = new Set(wxses ? wxses.map(w => w.module) : [])

  const renderFunc = buildRender(returned, stateKeys.filter(s => !wxsNames.has(s)), propsKeys)

  const classDecl = t.classDeclaration(
    t.identifier(componentType === 'App' ? 'App' : defaultClassName),
    t.memberExpression(t.identifier('Taro'), t.identifier('Component')),
    t.classBody(
      classBody.concat(renderFunc)
    ),
    []
  )

  if (weappConf) {
    classDecl.decorators = [buildDecorator(componentType || 'Page', weappConf)]
  }

  return classDecl
}
github zeit / styled-jsx / src / babel-external.js View on Github external
function addHash(exportIdentifier, hash) {
  const value = typeof hash === 'string' ? t.stringLiteral(hash) : hash
  return t.expressionStatement(
    t.assignmentExpression(
      '=',
      t.memberExpression(exportIdentifier, t.identifier('__hash')),
      value
    )
  )
}