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


Java MethodCallExpression.getMethodAsString方法代码示例

本文整理汇总了Java中org.codehaus.groovy.ast.expr.MethodCallExpression.getMethodAsString方法的典型用法代码示例。如果您正苦于以下问题:Java MethodCallExpression.getMethodAsString方法的具体用法?Java MethodCallExpression.getMethodAsString怎么用?Java MethodCallExpression.getMethodAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.groovy.ast.expr.MethodCallExpression的用法示例。


在下文中一共展示了MethodCallExpression.getMethodAsString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: copyStatementsWithSuperAdjustment

import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
public static boolean copyStatementsWithSuperAdjustment(ClosureExpression pre, BlockStatement body) {
    Statement preCode = pre.getCode();
    boolean changed = false;
    if (preCode instanceof BlockStatement) {
        BlockStatement block = (BlockStatement) preCode;
        List<Statement> statements = block.getStatements();
        for (int i = 0; i < statements.size(); i++) {
            Statement statement = statements.get(i);
            // adjust the first statement if it's a super call
            if (i == 0 && statement instanceof ExpressionStatement) {
                ExpressionStatement es = (ExpressionStatement) statement;
                Expression preExp = es.getExpression();
                if (preExp instanceof MethodCallExpression) {
                    MethodCallExpression mce = (MethodCallExpression) preExp;
                    String name = mce.getMethodAsString();
                    if ("super".equals(name)) {
                        es.setExpression(new ConstructorCallExpression(ClassNode.SUPER, mce.getArguments()));
                        changed = true;
                    }
                }
            }
            body.addStatement(statement);
        }
    }
    return changed;
}
 
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:GeneralUtils.java

示例3: isClosureCall

import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
private boolean isClosureCall(MethodCallExpression call) {
    // are we a local variable?
    // it should not be an explicitly "this" qualified method call
    // and the current class should have a possible method

    ClassNode classNode = controller.getClassNode();
    String methodName = call.getMethodAsString();
    if (methodName==null) return false;
    if (!call.isImplicitThis()) return false;
    if (!AsmClassGenerator.isThisExpression(call.getObjectExpression())) return false;
    FieldNode field = classNode.getDeclaredField(methodName);
    if (field == null) return false;
    if (isStaticInvocation(call) && !field.isStatic()) return false;
    Expression arguments = call.getArguments();
    return ! classNode.hasPossibleMethod(methodName, arguments);
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:InvocationWriter.java

示例4: visitMethodCallExpression

import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(MethodCallExpression call) {
    if (null != call.getMethodAsString()) {
        switch (call.getMethodAsString()) {
            case "maven":
                call.getArguments().visit(new MavenVisitor());
                break;
            case "ivy":
                call.getArguments().visit(new IvyVisitor());
                break;
            case "mavenCentral":
                MavenCentralRepository centralRepository = new MavenCentralRepository();
                if (!repositories.contains(centralRepository)) {
                    repositories.add(centralRepository);
                }
                break;
            case "jcenter":
                JCenterRepository centerRepository = new JCenterRepository();
                if (!repositories.contains(centerRepository)) {
                    repositories.add(centerRepository);
                }
                break;
            default:
                break;
        }
    }
}
 
开发者ID:NBANDROIDTEAM,项目名称:NBANDROID-V2,代码行数:28,代码来源:FindRepositoriesVisitor.java

示例5: transformSuperMethodCall

import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
private Expression transformSuperMethodCall(final MethodCallExpression call) {
    String method = call.getMethodAsString();
    if (method == null) {
        throwSuperError(call);
    }

    Expression arguments = transform(call.getArguments());
    ArgumentListExpression superCallArgs = new ArgumentListExpression();
    if (arguments instanceof ArgumentListExpression) {
        ArgumentListExpression list = (ArgumentListExpression) arguments;
        for (Expression expression : list) {
            superCallArgs.addExpression(expression);
        }
    } else {
        superCallArgs.addExpression(arguments);
    }
    MethodCallExpression transformed = new MethodCallExpression(
            weaved,
            Traits.getSuperTraitMethodName(traitClass, method),
            superCallArgs
    );
    transformed.setSourcePosition(call);
    transformed.setSafe(call.isSafe());
    transformed.setSpreadSafe(call.isSpreadSafe());
    transformed.setImplicitThis(false);
    return transformed;
}
 
开发者ID:apache,项目名称:groovy,代码行数:28,代码来源:TraitReceiverTransformer.java

示例6: transformMethodCall

import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
private Expression transformMethodCall(final MethodCallExpression exp) {
    String name = exp.getMethodAsString();
    if (exp.isImplicitThis() && "include".equals(name)) {
        return tryTransformInclude(exp);
    } else if (exp.isImplicitThis() && name.startsWith(":")) {
        List<Expression> args;
        if (exp.getArguments() instanceof ArgumentListExpression) {
            args = ((ArgumentListExpression) exp.getArguments()).getExpressions();
        } else {
            args = Collections.singletonList(exp.getArguments());
        }
        Expression newArguments = transform(new ArgumentListExpression(new ConstantExpression(name.substring(1)), new ArrayExpression(ClassHelper.OBJECT_TYPE, args)));
        MethodCallExpression call = new MethodCallExpression(
                new VariableExpression("this"),
                "methodMissing",
                newArguments
        );
        call.setImplicitThis(true);
        call.setSafe(exp.isSafe());
        call.setSpreadSafe(exp.isSpreadSafe());
        call.setSourcePosition(exp);
        return call;
    } else if (name!=null && name.startsWith("$")) {
        MethodCallExpression reformatted = new MethodCallExpression(
                exp.getObjectExpression(),
                name.substring(1),
                exp.getArguments()
        );
        reformatted.setImplicitThis(exp.isImplicitThis());
        reformatted.setSafe(exp.isSafe());
        reformatted.setSpreadSafe(exp.isSpreadSafe());
        reformatted.setSourcePosition(exp);
        // wrap in a stringOf { ... } closure call
        ClosureExpression clos = new ClosureExpression(Parameter.EMPTY_ARRAY, new ExpressionStatement(reformatted));
        clos.setVariableScope(new VariableScope());
        MethodCallExpression stringOf = new MethodCallExpression(new VariableExpression("this"),
                "stringOf",
                clos);
        stringOf.setImplicitThis(true);
        stringOf.setSourcePosition(reformatted);
        return stringOf;
    }
    return super.transform(exp);
}
 
开发者ID:apache,项目名称:groovy,代码行数:45,代码来源:MarkupBuilderCodeTransformer.java


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