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


Java MethodCallExpression.isImplicitThis方法代码示例

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


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

示例1: visitMethodCallExpression

import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(final MethodCallExpression call) {
    boolean old = inBuilderMethod;
    inBuilderMethod = false;
    if (call.isImplicitThis() && call.getArguments() instanceof TupleExpression) {
        List<Expression> expressions = ((TupleExpression) call.getArguments()).getExpressions();
        if (!expressions.isEmpty()) {
            Expression lastArg = expressions.get(expressions.size() - 1);
            if (lastArg instanceof ClosureExpression) {
                call.getObjectExpression().visit(this);
                call.getMethod().visit(this);
                for (Expression expression : expressions) {
                    inBuilderMethod =  (expression == lastArg);
                    expression.visit(this);
                }
            }
        }
    } else {
        super.visitMethodCallExpression(call);
    }
    inBuilderMethod = old;
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:AutoNewLineTransformer.java

示例2: visitMethodCallExpression

import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
public void visitMethodCallExpression(MethodCallExpression call) {
    if (call.isImplicitThis() && call.getMethod() instanceof ConstantExpression) {
        ConstantExpression methodNameConstant = (ConstantExpression) call.getMethod();
        Object value = methodNameConstant.getText();

        if (!(value instanceof String)) {
            throw new GroovyBugError("tried to make a method call with a non-String constant method name.");
        }

        String methodName = (String) value;
        Variable v = checkVariableNameForDeclaration(methodName, call);
        if (v != null && !(v instanceof DynamicVariable)) {
            checkVariableContextAccess(v, call);
        }

        if (v instanceof VariableExpression || v instanceof Parameter) {
            VariableExpression object = new VariableExpression(v);
            object.setSourcePosition(methodNameConstant);
            call.setObjectExpression(object);
            ConstantExpression method = new ConstantExpression("call");
            method.setSourcePosition(methodNameConstant); // important for GROOVY-4344
            call.setImplicitThis(false);
            call.setMethod(method);
        }

    }
    super.visitMethodCallExpression(call);
}
 
开发者ID:apache,项目名称:groovy,代码行数:29,代码来源:VariableScopeVisitor.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: 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

示例5: 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

示例6: isStaticInvocation

import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
private boolean isStaticInvocation(MethodCallExpression call) {
    if (!AsmClassGenerator.isThisExpression(call.getObjectExpression())) return false;
    if (controller.isStaticMethod()) return true;
    return controller.isStaticContext() && !call.isImplicitThis();
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:InvocationWriter.java

示例7: visitMethodCallExpression

import org.codehaus.groovy.ast.expr.MethodCallExpression; //导入方法依赖的package包/类
public void visitMethodCallExpression(MethodCallExpression methodCall) {
    if (defaultScriptMethods.contains(methodCall.getMethodAsString())) {
        visited = true;
        isImplicitThis = methodCall.isImplicitThis();
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:MethodCallExpressionTest.java


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