本文整理汇总了Java中org.codehaus.groovy.ast.expr.MethodCallExpression.getReceiver方法的典型用法代码示例。如果您正苦于以下问题:Java MethodCallExpression.getReceiver方法的具体用法?Java MethodCallExpression.getReceiver怎么用?Java MethodCallExpression.getReceiver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.codehaus.groovy.ast.expr.MethodCallExpression
的用法示例。
在下文中一共展示了MethodCallExpression.getReceiver方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inspectMethodCallExpression
import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
private void inspectMethodCallExpression(MethodCallExpression mc, int childIndent, String in) {
String name = mc.getMethodAsString();
System.out.println(in+"-method as string:"+name);
System.out.println("- generic types:"+ mc.getGenericsTypes());
System.out.println("- type:"+mc.getType().getName());
Expression method = mc.getMethod();
inspect(method, childIndent);
// System.out.println(in+"-type:"+mc.getType());
Expression args = mc.getArguments();
System.out.println(in + "-arguments:");
inspect(args, childIndent);
// System.out.println(in + "-method:");
// System.out.println(in + "-target:");
// inspect(mc.getMethodTarget(), childIndent);
ASTNode receiver = mc.getReceiver();
if (receiver!=null){
System.out.println(in+"// Receiver found ...");
inspect(receiver, childIndent);
}
}
示例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: transformMethodCallOnThisInClosure
import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
private Expression transformMethodCallOnThisInClosure(final MethodCallExpression call) {
MethodCallExpression transformed = new MethodCallExpression(
(Expression) call.getReceiver(),
call.getMethod(),
transform(call.getArguments())
);
transformed.setSourcePosition(call);
transformed.setSafe(call.isSafe());
transformed.setSpreadSafe(call.isSpreadSafe());
transformed.setImplicitThis(call.isImplicitThis());
return transformed;
}