本文整理匯總了TypeScript中@babel/types.isMemberExpression函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript isMemberExpression函數的具體用法?TypeScript isMemberExpression怎麽用?TypeScript isMemberExpression使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了isMemberExpression函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: matchesCallExpression
export function matchesCallExpression(
expression: babel.MemberExpression, path: string[]): boolean {
if (!expression.property || !expression.object) {
return false;
}
assert(path.length >= 2);
if (!babel.isIdentifier(expression.property)) {
return false;
}
// Unravel backwards, make sure properties match each step of the way.
if (expression.property.name !== path[path.length - 1]) {
return false;
}
// We've got ourselves a final member expression.
if (path.length === 2 && babel.isIdentifier(expression.object)) {
return expression.object.name === path[0];
}
// Nested expressions.
if (path.length > 2 && babel.isMemberExpression(expression.object)) {
return matchesCallExpression(
expression.object, path.slice(0, path.length - 1));
}
return false;
}
示例2: isVariableCall
export function isVariableCall(node: Expression): node is VariableCallAST {
return (
isCallExpression(node) &&
isMemberExpression(node.callee, { computed: false }) &&
isVariable(node.callee.object) &&
isIdentifier(node.callee.property)
);
}
示例3: isVariable
export function isVariable(node: Expression): node is VariableAST {
return (
isCallExpression(node) &&
isMemberExpression(node.callee, { computed: false }) &&
isIdentifier(node.callee.object, { name: 'Variable' }) &&
isIdentifier(node.callee.property, { name: 'find' }) &&
isIdentifier(node.arguments[0], { name: 'gameModel' }) &&
isStringLiteral(node.arguments[1])
);
}
示例4: extractGlobalMethod
export function extractGlobalMethod(node: CallExpression) {
let ret: Identifier[] = [];
let depth = node.callee;
while (isMemberExpression(depth)) {
if (!isIdentifier(depth.property)) {
throw Error('Unhandled');
}
ret.push(depth.property);
depth = depth.object;
}
if (!isIdentifier(depth)) {
throw Error('Unhandled');
}
ret.push(depth);
return ret
.reverse()
.map(i => i.name)
.join('.');
}