本文整理汇总了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('.');
}