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


Java Expression.setSourcePosition方法代码示例

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


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

示例1: transform

import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
public Expression transform(Expression exp) {
    if (exp == null) return null;
    Expression ret = null;
    if (exp instanceof VariableExpression) {
        ret = transformVariableExpression((VariableExpression) exp);
    } else if (exp.getClass() == PropertyExpression.class) {
        ret = transformPropertyExpression((PropertyExpression) exp);
    } else if (exp instanceof DeclarationExpression) {
        ret = transformDeclarationExpression((DeclarationExpression) exp);
    } else if (exp instanceof BinaryExpression) {
        ret = transformBinaryExpression((BinaryExpression) exp);
    } else if (exp instanceof MethodCallExpression) {
        ret = transformMethodCallExpression((MethodCallExpression) exp);
    } else if (exp instanceof ClosureExpression) {
        ret = transformClosureExpression((ClosureExpression) exp);
    } else if (exp instanceof ConstructorCallExpression) {
        ret = transformConstructorCallExpression((ConstructorCallExpression) exp);
    } else if (exp instanceof AnnotationConstantExpression) {
        ret = transformAnnotationConstantExpression((AnnotationConstantExpression) exp);
    } else {
        resolveOrFail(exp.getType(), exp);
        ret = exp.transformExpression(this);
    }
    if (ret!=null && ret!=exp) ret.setSourcePosition(exp);
    return ret;
}
 
开发者ID:apache,项目名称:groovy,代码行数:27,代码来源:ResolveVisitor.java

示例2: tryOptimizeCharComparison

import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
private static BinaryExpression tryOptimizeCharComparison(final Expression left, final Expression right, final BinaryExpression bin) {
    int op = bin.getOperation().getType();
    if (isCompareToBoolean(op) || op == COMPARE_EQUAL || op == COMPARE_NOT_EQUAL) {
        Character cLeft = tryCharConstant(left);
        Character cRight = tryCharConstant(right);
        if (cLeft != null || cRight != null) {
            Expression oLeft = cLeft == null ? left : new ConstantExpression(cLeft, true);
            oLeft.setSourcePosition(left);
            Expression oRight = cRight == null ? right : new ConstantExpression(cRight, true);
            oRight.setSourcePosition(right);
            bin.setLeftExpression(oLeft);
            bin.setRightExpression(oRight);
            return bin;
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:BinaryExpressionTransformer.java

示例3: setSourcePosition

import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
/**
 * Set the source position of toSet including its property expression if it has one.
 *
 * @param toSet resulting node
 * @param origNode original node
 */
private static void setSourcePosition(Expression toSet, Expression origNode) {
    toSet.setSourcePosition(origNode);
    if (toSet instanceof PropertyExpression) {
        ((PropertyExpression) toSet).getProperty().setSourcePosition(origNode);
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:StaticImportVisitor.java

示例4: transformPropertyExpression

import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
protected Expression transformPropertyExpression(PropertyExpression pe) {
    if (currentMethod!=null && currentMethod.isStatic()
            && pe.getObjectExpression() instanceof VariableExpression
            && ((VariableExpression) pe.getObjectExpression()).isSuperExpression()) {
        PropertyExpression pexp = new PropertyExpression(
                new ClassExpression(currentClass.getSuperClass()),
                transform(pe.getProperty())
        );
        pexp.setSourcePosition(pe);
        return pexp;
    }
    boolean oldInPropertyExpression = inPropertyExpression;
    Expression oldFoundArgs = foundArgs;
    Expression oldFoundConstant = foundConstant;
    inPropertyExpression = true;
    foundArgs = null;
    foundConstant = null;
    Expression objectExpression = transform(pe.getObjectExpression());
    boolean candidate = false;
    if (objectExpression instanceof MethodCallExpression) {
        candidate = ((MethodCallExpression)objectExpression).isImplicitThis();
    }

    if (foundArgs != null && foundConstant != null && candidate) {
        Expression result = findStaticMethodImportFromModule(foundConstant, foundArgs);
        if (result != null) {
            objectExpression = result;
            objectExpression.setSourcePosition(pe);
        }
    }
    inPropertyExpression = oldInPropertyExpression;
    foundArgs = oldFoundArgs;
    foundConstant = oldFoundConstant;
    pe.setObjectExpression(objectExpression);
    return pe;
}
 
开发者ID:apache,项目名称:groovy,代码行数:37,代码来源:StaticImportVisitor.java

示例5: transformExpression

import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
@Override
public Expression transformExpression(final ExpressionTransformer transformer) {
    Expression ret = new OptimizingBooleanExpression(transformer.transform(expression), type);
    ret.setSourcePosition(this);
    ret.copyNodeMetaData(this);
    return ret;
}
 
开发者ID:apache,项目名称:groovy,代码行数:8,代码来源:BooleanExpressionTransformer.java

示例6: configure

import org.codehaus.groovy.ast.expr.Expression; //导入方法依赖的package包/类
private static Expression configure(Expression orig, Expression result) {
    result.setSourcePosition(orig);
    return result;
}
 
开发者ID:apache,项目名称:groovy,代码行数:5,代码来源:AnnotationConstantsVisitor.java


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