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


Java ClassCodeExpressionTransformer类代码示例

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


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

示例1: makeMapTypedArgsTransformer

import org.codehaus.groovy.ast.ClassCodeExpressionTransformer; //导入依赖的package包/类
private static ClassCodeExpressionTransformer makeMapTypedArgsTransformer() {
    return new ClassCodeExpressionTransformer() {
        @Override
        public Expression transform(Expression exp) {
            if (exp instanceof ClosureExpression) {
                ClosureExpression ce = (ClosureExpression) exp;
                ce.getCode().visit(this);
            } else if (exp instanceof VariableExpression) {
                VariableExpression ve = (VariableExpression) exp;
                if (ve.getName().equals("args") && ve.getAccessedVariable() instanceof DynamicVariable) {
                    VariableExpression newVe = new VariableExpression(new Parameter(MAP_TYPE, "args"));
                    newVe.setSourcePosition(ve);
                    return newVe;
                }
            }
            return exp.transformExpression(this);
        }

        @Override
        protected SourceUnit getSourceUnit() {
            return null;
        }
    };
}
 
开发者ID:apache,项目名称:groovy,代码行数:25,代码来源:MapConstructorASTTransformation.java

示例2: popContext

import org.codehaus.groovy.ast.ClassCodeExpressionTransformer; //导入依赖的package包/类
protected TreeContext popContext() {
    final TreeContext treeContext = treeContextStack.pop();
    List<TreeContextAction> actions = treeContext.getOnPopHandlers();
    for (TreeContextAction contextAction : actions) {
        contextAction.call(treeContext);
    }
    lastContext = treeContext;
    ASTNode parentNode = treeContext.parent!=null?treeContext.parent.node:null;
    if (treeContext.node instanceof Expression && parentNode !=null) {
        ClassCodeExpressionTransformer trn = new ClassCodeExpressionTransformer() {
            @Override
            protected SourceUnit getSourceUnit() {
                return null;
            }

            @Override
            public Expression transform(final Expression exp) {
                if (exp==treeContext.node) {
                    Expression replacement = treeContext.getReplacement();
                    if (replacement!=null) {
                        return replacement;
                    }
                }
                return super.transform(exp);
            }
        };
        // todo: reliable way to call the transformer
        //parentNode.visit(trn);
    }
    return treeContext;
}
 
开发者ID:apache,项目名称:groovy,代码行数:32,代码来源:ContextualClassCodeVisitor.java

示例3: call

import org.codehaus.groovy.ast.ClassCodeExpressionTransformer; //导入依赖的package包/类
@Override
public void call(SourceUnit source, GeneratorContext context, ClassNode classNode) throws CompilationFailedException {
    new ClassCodeExpressionTransformer() {
        @Override
        protected SourceUnit getSourceUnit() {
            return source;
        }

        public Expression transform(Expression exp) {
            // System.out.println(exp);
            if (exp instanceof ConstantExpression) {
                Object value = ConstantExpression.class.cast(exp).getValue();
                if (value != null) {
                    if (value instanceof BigDecimal) {
                        return new ConstantExpression(BigDecimal.class.cast(value).doubleValue());
                    }
                    if (value instanceof BigInteger) {
                        return new ConstantExpression(BigInteger.class.cast(value).longValue());
                    }
                    if (intToLong && value instanceof Integer) {
                        return new ConstantExpression(Integer.class.cast(value).longValue());
                    }
                }
            } else if (exp instanceof VariableExpression) {
                if (literals) {
                    VariableExpression v = VariableExpression.class.cast(exp);
                    if (!vars.contains(v.getText())) {
                        return new ConstantExpression(v.getText());
                    }
                }
            }
            return super.transform(exp);
        }
    }.visitClass(classNode);
}
 
开发者ID:jurgendl,项目名称:hql-builder,代码行数:36,代码来源:GroovyCompiler.java

示例4: getTransformer

import org.codehaus.groovy.ast.ClassCodeExpressionTransformer; //导入依赖的package包/类
@Override
protected GroovyCodeVisitor getTransformer(final ASTNode[] nodes, final SourceUnit sourceUnit) {
    ClassCodeExpressionTransformer transformer = new MacroClassTransformer(sourceUnit);

    return new MacroClassTransformingCodeVisitor(transformer, sourceUnit);
}
 
开发者ID:apache,项目名称:groovy,代码行数:7,代码来源:MacroClassTransformation.java

示例5: MacroClassTransformingCodeVisitor

import org.codehaus.groovy.ast.ClassCodeExpressionTransformer; //导入依赖的package包/类
MacroClassTransformingCodeVisitor(ClassCodeExpressionTransformer transformer, SourceUnit sourceUnit) {
    super(transformer);
    this.sourceUnit = sourceUnit;
}
 
开发者ID:apache,项目名称:groovy,代码行数:5,代码来源:MacroClassTransformation.java


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