• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClassCodeVisitorSupport类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.codehaus.groovy.ast.ClassCodeVisitorSupport的典型用法代码示例。如果您正苦于以下问题:Java ClassCodeVisitorSupport类的具体用法?Java ClassCodeVisitorSupport怎么用?Java ClassCodeVisitorSupport使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ClassCodeVisitorSupport类属于org.codehaus.groovy.ast包,在下文中一共展示了ClassCodeVisitorSupport类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: call

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
@Override
public void call(final SourceUnit source) throws CompilationFailedException {
    // currently we only look in script code; could extend this to build script classes
    AstUtils.visitScriptCode(source, new ClassCodeVisitorSupport() {
        @Override
        protected SourceUnit getSourceUnit() {
            return source;
        }

        @Override
        protected void visitStatement(Statement statement) {
            if (statement.getStatementLabel() != null) {
                String message = String.format("Statement labels may not be used in build scripts.%nIn case you tried to configure a property named '%s', replace ':' with '=' or ' ', otherwise it will not have the desired effect.",
                        statement.getStatementLabel());
                addError(message, statement);
            }
        }
    });
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:StatementLabelsScriptTransformer.java


示例2: process

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
private void process(ASTNode[] nodes, final ClassCodeVisitorSupport visitor) {
    candidate = (AnnotatedNode) nodes[1];
    AnnotationNode node = (AnnotationNode) nodes[0];
    if (!MY_TYPE.equals(node.getClassNode())) return;

    if (candidate instanceof ClassNode) {
        processClass((ClassNode) candidate, visitor);
    } else if (candidate instanceof MethodNode) {
        processConstructorOrMethod((MethodNode) candidate, visitor);
    } else if (candidate instanceof FieldNode) {
        processField((FieldNode) candidate, visitor);
    } else if (candidate instanceof DeclarationExpression) {
        processLocalVariable((DeclarationExpression) candidate, visitor);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:16,代码来源:AutoFinalASTTransformation.java


示例3: processClass

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
private void processClass(ClassNode cNode, final ClassCodeVisitorSupport visitor) {
    if (!isEnabled(cNode)) return;
    if (cNode.isInterface()) {
        addError("Error processing interface '" + cNode.getName() +
                "'. " + MY_TYPE_NAME + " only allowed for classes.", cNode);
        return;
    }

    for (ConstructorNode cn : cNode.getDeclaredConstructors()) {
        if (hasNoExplicitAutoFinal(cn)) {
            processConstructorOrMethod(cn, visitor);
        }
    }

    for (MethodNode mn : cNode.getAllDeclaredMethods()) {
        if (hasNoExplicitAutoFinal(mn)) {
            processConstructorOrMethod(mn, visitor);
        }
    }

    Iterator<InnerClassNode> it = cNode.getInnerClasses();
    while (it.hasNext()) {
        InnerClassNode in = it.next();
        if (in.getAnnotations(MY_TYPE).isEmpty()) {
            processClass(in, visitor);
        }
    }

    visitor.visitClass(cNode);
}
 
开发者ID:apache,项目名称:groovy,代码行数:31,代码来源:AutoFinalASTTransformation.java


示例4: processConstructorOrMethod

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
private void processConstructorOrMethod(MethodNode mNode, ClassCodeVisitorSupport visitor) {
    if (!isEnabled(mNode)) return;
    if (mNode.isSynthetic()) return;
    Parameter[] origParams = mNode.getParameters();
    for (Parameter p : origParams) {
        p.setModifiers(p.getModifiers() | Modifier.FINAL);
    }
    visitor.visitMethod(mNode);
}
 
开发者ID:apache,项目名称:groovy,代码行数:10,代码来源:AutoFinalASTTransformation.java


示例5: storeField

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
private boolean storeField(FieldNode field, boolean returnTrueIfFieldExists, PropertyExpression expressionToStoreOn, ClassNode receiver, ClassCodeVisitorSupport visitor, String delegationData, boolean lhsOfAssignment) {
    if (field==null || !returnTrueIfFieldExists) return false;
    if (visitor != null) visitor.visitField(field);
    storeWithResolve(field.getOriginType(), receiver, field.getDeclaringClass(), field.isStatic(), expressionToStoreOn);
    checkOrMarkPrivateAccess(expressionToStoreOn, field, lhsOfAssignment);
    if (delegationData!=null) {
        expressionToStoreOn.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, delegationData);
    }
    return true;
}
 
开发者ID:apache,项目名称:groovy,代码行数:11,代码来源:StaticTypeCheckingVisitor.java


示例6: storeProperty

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
private boolean storeProperty(PropertyNode propertyNode, PropertyExpression expressionToStoreOn, ClassNode receiver, ClassCodeVisitorSupport visitor, String delegationData) {
    if (propertyNode == null) return false;
    if (visitor != null) visitor.visitProperty(propertyNode);
    storeWithResolve(propertyNode.getOriginType(), receiver, propertyNode.getDeclaringClass(), propertyNode.isStatic(), expressionToStoreOn);
    if (delegationData!=null) {
        expressionToStoreOn.putNodeMetaData(StaticTypesMarker.IMPLICIT_RECEIVER, delegationData);
    }
    return true;
}
 
开发者ID:apache,项目名称:groovy,代码行数:10,代码来源:StaticTypeCheckingVisitor.java


示例7: doAddConstructor

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
private static void doAddConstructor(final ClassNode cNode, final ConstructorNode constructorNode) {
    cNode.addConstructor(constructorNode);
    // GROOVY-5814: Immutable is not compatible with @CompileStatic
    Parameter argsParam = null;
    for (Parameter p : constructorNode.getParameters()) {
        if ("args".equals(p.getName())) {
            argsParam = p;
            break;
        }
    }
    if (argsParam!=null) {
        final Parameter arg = argsParam;
        ClassCodeVisitorSupport variableExpressionFix = new ClassCodeVisitorSupport() {
            @Override
            protected SourceUnit getSourceUnit() {
                return cNode.getModule().getContext();
            }

            @Override
            public void visitVariableExpression(final VariableExpression expression) {
                super.visitVariableExpression(expression);
                if ("args".equals(expression.getName())) {
                    expression.setAccessedVariable(arg);
                }
            }
        };
        variableExpressionFix.visitConstructor(constructorNode);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:30,代码来源:ImmutableASTTransformation.java


示例8: call

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
@Override
public void call(final SourceUnit source) throws CompilationFailedException {
    final List<Statement> logStats = Lists.newArrayList();

    // currently we only look in script code; could extend this to build script classes
    AstUtils.visitScriptCode(source, new ClassCodeVisitorSupport() {
        @Override
        protected SourceUnit getSourceUnit() {
            return source;
        }

        @Override
        protected void visitStatement(Statement statement) {
            if (statement.getStatementLabel() != null) {
                // Because we aren't failing the build, the script will be cached and this transformer won't run the next time.
                // In order to make the deprecation warning stick, we have to weave the call to StatementLabelsDeprecationLogger
                // into the build script.
                String label = statement.getStatementLabel();
                String sample = source.getSample(statement.getLineNumber(), statement.getColumnNumber(), null);
                Expression logExpr = new StaticMethodCallExpression(ClassHelper.makeWithoutCaching(StatementLabelsDeprecationLogger.class), "log",
                        new ArgumentListExpression(new ConstantExpression(label), new ConstantExpression(sample)));
                logStats.add(new ExpressionStatement(logExpr));
            }
        }
    });

    source.getAST().getStatementBlock().addStatements(logStats);
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:29,代码来源:StatementLabelsScriptTransformer.java


示例9: buildSubstitutions

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
public static ListExpression buildSubstitutions(final SourceUnit source, final ASTNode expr) {
    final ListExpression listExpression = new ListExpression();

    ClassCodeVisitorSupport visitor = new ClassCodeVisitorSupport() {
        @Override
        protected SourceUnit getSourceUnit() {
            return null;
        }

        @Override
        public void visitClass(final ClassNode node) {
            super.visitClass(node);
            Iterator<InnerClassNode> it = node.getInnerClasses();
            while (it.hasNext()) {
                InnerClassNode next = it.next();
                visitClass(next);
            }
        }

        @Override
        public void visitMethodCallExpression(MethodCallExpression call) {
            super.visitMethodCallExpression(call);

            if (DOLLAR_VALUE.equals(call.getMethodAsString())) {
                ClosureExpression substitutionClosureExpression = getClosureArgument(source, call);

                if (substitutionClosureExpression == null) {
                    return;
                }

                Statement code = substitutionClosureExpression.getCode();
                if (code instanceof BlockStatement) {
                    ((BlockStatement) code).setVariableScope(null);
                }

                listExpression.addExpression(substitutionClosureExpression);
            }
        }
    };
    if (expr instanceof ClassNode) {
        visitor.visitClass((ClassNode) expr);
    } else {
        expr.visit(visitor);
    }
    return listExpression;
}
 
开发者ID:apache,项目名称:groovy,代码行数:47,代码来源:MacroGroovyMethods.java


示例10: visit

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
public void visit(ASTNode[] nodes, SourceUnit source) {
    init(nodes, source);
    final ClassCodeVisitorSupport visitor = createVisitor();
    process(nodes, visitor);
}
 
开发者ID:apache,项目名称:groovy,代码行数:6,代码来源:AutoFinalASTTransformation.java


示例11: processLocalVariable

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
private void processLocalVariable(DeclarationExpression de, ClassCodeVisitorSupport visitor) {
    if (!isEnabled(de)) return;
    if (de.getRightExpression() instanceof ClosureExpression) {
        visitor.visitDeclarationExpression(de);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:AutoFinalASTTransformation.java


示例12: processField

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
private void processField(FieldNode fNode, ClassCodeVisitorSupport visitor) {
    if (!isEnabled(fNode)) return;
    if (fNode.hasInitialExpression() && fNode.getInitialExpression() instanceof ClosureExpression) {
        visitor.visitField(fNode);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:AutoFinalASTTransformation.java


示例13: existsProperty

import org.codehaus.groovy.ast.ClassCodeVisitorSupport; //导入依赖的package包/类
public boolean existsProperty(final PropertyExpression pexp, final boolean checkForReadOnly, final ClassCodeVisitorSupport visitor) {
    return typeCheckingVisitor.existsProperty(pexp, checkForReadOnly, visitor);
}
 
开发者ID:apache,项目名称:groovy,代码行数:4,代码来源:TypeCheckingExtension.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RpcDefinition类代码示例发布时间:2022-05-23
下一篇:
Java Compare类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap