本文整理汇总了Java中org.codehaus.groovy.ast.expr.MethodCallExpression.getNodeMetaData方法的典型用法代码示例。如果您正苦于以下问题:Java MethodCallExpression.getNodeMetaData方法的具体用法?Java MethodCallExpression.getNodeMetaData怎么用?Java MethodCallExpression.getNodeMetaData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.expr.MethodCallExpression
的用法示例。
在下文中一共展示了MethodCallExpression.getNodeMetaData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformToMopSuperCall
import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
private static MethodCallExpression transformToMopSuperCall(final ClassNode superCallReceiver, final MethodCallExpression expr) {
MethodNode mn = expr.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET);
String mopName = MopWriter.getMopMethodName(mn, false);
MethodNode direct = new MethodNode(
mopName,
ACC_PUBLIC | ACC_SYNTHETIC,
mn.getReturnType(),
mn.getParameters(),
mn.getExceptions(),
EmptyStatement.INSTANCE
);
direct.setDeclaringClass(superCallReceiver);
MethodCallExpression result = new MethodCallExpression(
new VariableExpression("this"),
mopName,
expr.getArguments()
);
result.setImplicitThis(true);
result.setSpreadSafe(false);
result.setSafe(false);
result.setSourcePosition(expr);
result.setMethodTarget(direct);
return result;
}
示例2: handleMissingMethod
import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
@Override
public List<MethodNode> handleMissingMethod(final ClassNode receiver, final String name, final ArgumentListExpression argumentList, final ClassNode[] argumentTypes, final MethodCall call) {
String[] decomposed = Traits.decomposeSuperCallName(name);
if (decomposed != null) {
return convertToDynamicCall(call, receiver, decomposed, argumentTypes);
}
if (call instanceof MethodCallExpression) {
MethodCallExpression mce = (MethodCallExpression) call;
if (mce.getReceiver() instanceof VariableExpression) {
VariableExpression var = (VariableExpression) mce.getReceiver();
// GROOVY-7322
// static method call in trait?
ClassNode type = null;
if (isStaticTraitReceiver(receiver, var)) {
type = receiver.getGenericsTypes()[0].getType();
} else if (isThisTraitReceiver(var)) {
type = receiver;
}
if (type != null && Traits.isTrait(type)) {
ClassNode helper = Traits.findHelper(type);
Parameter[] params = new Parameter[argumentTypes.length + 1];
params[0] = new Parameter(ClassHelper.CLASS_Type.getPlainNodeReference(), "staticSelf");
for (int i = 1; i < params.length; i++) {
params[i] = new Parameter(argumentTypes[i-1], "p" + i);
}
MethodNode method = helper.getDeclaredMethod(name, params);
if (method != null) {
return Collections.singletonList(makeDynamic(call, method.getReturnType()));
}
}
}
ClassNode dynamic = mce.getNodeMetaData(TraitASTTransformation.DO_DYNAMIC);
if (dynamic!=null) {
return Collections.singletonList(makeDynamic(call, dynamic));
}
}
return NOTFOUND;
}
示例3: isCallOnClosure
import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
private static boolean isCallOnClosure(final MethodCallExpression expr) {
MethodNode target = expr.getNodeMetaData(StaticTypesMarker.DIRECT_METHOD_CALL_TARGET);
return expr.isImplicitThis()
&& !"call".equals(expr.getMethodAsString())
&& (target == StaticTypeCheckingVisitor.CLOSURE_CALL_VARGS
|| target == StaticTypeCheckingVisitor.CLOSURE_CALL_NO_ARG
|| target == StaticTypeCheckingVisitor.CLOSURE_CALL_ONE_ARG);
}
示例4: visitMethodCallExpression
import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(final MethodCallExpression call) {
super.visitMethodCallExpression(call);
MethodNode target = (MethodNode) call.getNodeMetaData(DIRECT_METHOD_CALL_TARGET);
if (target!=null) {
call.setMethodTarget(target);
memorizeInitialExpressions(target);
}
if (call.getMethodTarget()==null && call.getLineNumber()>0) {
addError("Target method for method call expression hasn't been set", call);
}
}
示例5: visitMethodCallExpression
import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(MethodCallExpression expression) {
if (expression.getNodeMetaData(StatementMeta.class)!=null) return;
super.visitMethodCallExpression(expression);
Expression object = expression.getObjectExpression();
boolean setTarget = AsmClassGenerator.isThisExpression(object);
if (!setTarget) {
if (!(object instanceof ClassExpression)) return;
setTarget = object.equals(node);
}
if (!setTarget) return;
setMethodTarget(expression, expression.getMethodAsString(), expression.getArguments(), true);
}