本文整理汇总了Java中org.walkmod.javalang.ast.expr.Expression.setSymbolData方法的典型用法代码示例。如果您正苦于以下问题:Java Expression.setSymbolData方法的具体用法?Java Expression.setSymbolData怎么用?Java Expression.setSymbolData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.walkmod.javalang.ast.expr.Expression
的用法示例。
在下文中一共展示了Expression.setSymbolData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import org.walkmod.javalang.ast.expr.Expression; //导入方法依赖的package包/类
@Override
public void visit(VariableDeclarator n, A arg) {
n.getId().accept(this, arg);
Expression init = n.getInit();
if (init != null) {
Symbol<?> aux = symbolTable.findSymbol(n.getId().getName(), ReferenceType.VARIABLE);
Scope innerscope = new Scope(aux);
aux.setInnerScope(innerscope);
symbolTable.pushScope(innerscope);
if (init instanceof LambdaExpr || init instanceof MethodReferenceExpr) {
ArrayFilter<Method> filter = new ArrayFilter<Method>(null);
SymbolType scope = symbolTable.getType(n.getId().getName(), ReferenceType.VARIABLE);
filter.appendPredicate(
new CompatibleFunctionalMethodPredicate<A>(scope, this, null, arg, symbolTable, null, null));
SymbolData sd = null;
try {
sd = MethodInspector.findMethodType(scope, null, filter, null, null);
} catch (Exception e) {
throw new NoSuchExpressionTypeException(e);
}
if (init instanceof LambdaExpr) {
init.setSymbolData(sd);
} else {
init.setSymbolData(scope);
MethodReferenceExpr methodRef = (MethodReferenceExpr) init;
methodRef.accept(this, arg);
}
} else {
init.accept(this, arg);
}
symbolTable.popScope();
}
}
示例2: build
import org.walkmod.javalang.ast.expr.Expression; //导入方法依赖的package包/类
@Override
public MethodCallExpr build(MethodCallExpr n) throws Exception {
List<Expression> args = n.getArgs();
MethodSymbolData st = n.getSymbolData();
if (args != null) {
int i = 0;
if (st == null) {
Expression scope = n.getScope();
String scopeName = "empty";
if (scope != null) {
scopeName = scope.getSymbolData().toString();
}
String argsTypeName = "empty";
List<Expression> argExpr = n.getArgs();
if (argExpr != null) {
argsTypeName = "[";
Iterator<Expression> it = argExpr.iterator();
while (it.hasNext()) {
Expression arg = it.next();
if (arg != null && arg.getSymbolData() != null) {
argsTypeName += " " + arg.getSymbolData().toString();
} else {
argsTypeName += " null";
}
if (it.hasNext()) {
argsTypeName += ",";
}
}
argsTypeName += "]";
}
throw new Exception("Ops! The method call " + n.toString() + " is not resolved. The scope is ["
+ scopeName + "] , and the args are : " + argsTypeName);
}
java.lang.reflect.Type[] argClasses = st.getMethod().getGenericParameterTypes();
int paramCount = st.getMethod().getParameterTypes().length;
for (Expression argument : args) {
if (argument instanceof MethodReferenceExpr) {
SymbolType aux = null;
if (i < paramCount) {
aux = SymbolType.valueOf(argClasses[i], typeMapping);
} else {
java.lang.reflect.Type componentType = null;
java.lang.reflect.Type lastArg = argClasses[argClasses.length - 1];
if (lastArg instanceof Class<?>) {
componentType = ((Class<?>) lastArg).getComponentType();
} else if (lastArg instanceof GenericArrayType) {
componentType = ((GenericArrayType) lastArg).getGenericComponentType();
}
aux = SymbolType.valueOf(componentType, typeMapping);
}
argument.setSymbolData(aux);
argument.accept(visitor, ctxt);
}
i++;
}
}
return null;
}