当前位置: 首页>>代码示例>>Java>>正文


Java MethodCallExpression.getReceiver方法代码示例

本文整理汇总了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);
		}
	}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:21,代码来源:GradleBuildScriptResultInspector.java

示例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;
}
 
开发者ID:apache,项目名称:groovy,代码行数:41,代码来源:TraitTypeCheckingExtension.java

示例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;
}
 
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:TraitReceiverTransformer.java


注:本文中的org.codehaus.groovy.ast.expr.MethodCallExpression.getReceiver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。