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


Java MethodCallExpression.getNodeMetaData方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:groovy,代码行数:25,代码来源:MethodCallExpressionTransformer.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: 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);
}
 
开发者ID:apache,项目名称:groovy,代码行数:9,代码来源:MethodCallExpressionTransformer.java

示例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);
    }

}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:StaticCompilationVisitor.java

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


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