Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
names.push(name);
}
else {
name = names[i];
}
let replacement;
let useBinding = false;
if (i === firstRest) {
if (param.isRest) {
replacement = t.identifier(name);
}
else {
// take the first element of the param.
replacement = t.memberExpression(
t.identifier(name),
t.NumericLiteral(0),
true
);
useBinding = true;
}
}
else if (i > firstRest) {
// this param appears somewhere after the first rest param
const relativeIndex = i - firstRest;
if (param.isRest) {
// this is rest too so we need to slice the existing rest param
// we only want to do this once though so we keep a cache
if (sliceNames[i]) {
// we've already sliced this.
replacement = t.identifier(sliceNames[i]);
MemberExpression(path: NodePath, file) {
//props.xxx
if (t.isIdentifier(path.node.object)) {
const searchName = path.node.object.name;
const argument =
args[
params.findIndex(p => t.isIdentifier(p) && p.name == searchName)
];
let listItem = null;
if (
argument &&
t.isIdentifier(argument) &&
check.isTrackedVariable(scope, path.node.property)
) {
listItem = t.memberExpression(argument, path.node.property);
} else if (check.isTrackedVariable(scope, path.node.object)) {
const variableBinding = found.variableBindingInScope(
scope,
searchName
);
// assuming that local variables cannot be found in passed scope
// if the variableBinding is found it is not local variable in this function
if (variableBinding) {
listItem = path.node.object;
}
} else if (check.isTrackedVariable(scope, path.node.property)) {
listItem = t.memberExpression(path.node.object, path.node.property);
}
if (listItem && !listIncludes(list, listItem)) {
list.push(listItem);
}
i -= 1;
}
}
} else {
// root 节点没有 children,则在外面套一层
replace(
t.isJSXElement(node)
? t.jsxFragment(t.jsxOpeningFragment(), t.jsxClosingFragment(), [
buildGUmiUIFlag({ index: 0, filename, jsx: true }) as any,
node,
buildGUmiUIFlag({ index: 1, filename, jsx: true }),
])
: t.callExpression(
t.memberExpression(t.identifier('React'), t.identifier('createElement')),
[
t.memberExpression(t.identifier('React'), t.identifier('Fragment')),
t.nullLiteral(),
buildGUmiUIFlag({ index: 0, filename, jsx: false }),
node,
buildGUmiUIFlag({ index: 1, filename, jsx: false }),
],
),
);
}
} else {
// throw new Error(`Add umi ui flag failed, unsupported node type ${node.type}.`);
}
}
let [decl] = path.getStatementParent().insertBefore(
DEFAULT_INTEROP_TEMPLATE({
NAME: t.identifier(name),
MODULE: node
})
);
let binding = path.scope.getBinding(getName(mod, 'exports'));
if (binding) {
binding.reference(decl.get('declarations.0.init'));
}
path.scope.registerDeclaration(decl);
}
return t.memberExpression(t.identifier(name), t.identifier('d'));
}
// if there is a CommonJS export return $id$exports.name
if (originalName !== '*') {
return t.memberExpression(node, t.identifier(originalName));
}
return node;
}
function buildAssignmentWidthThis(left, right) {
return t.assignmentExpression("=", t.memberExpression(t.thisExpression(), left), right);
}
_serializeCallAbstractFuncThis(
{ }: OperationDescriptorData,
nodes: Array
): BabelNodeExpression {
let fun_args = ((nodes.slice(1): any): Array);
return t.callExpression(t.memberExpression(nodes[0], t.identifier("call")), fun_args);
}
_serializeUnknownArrayMethodPropertyCall(
{ }: OperationDescriptorData,
[objNode, propName, ..._args]: Array
): BabelNodeExpression {
let propString = ((propName: any): BabelNodeStringLiteral).value;
return t.callExpression(t.memberExpression(objNode, t.identifier(propString)), ((_args: any): Array));
}
.reduce((object, property) => t.memberExpression(object, property));
};