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

Java ListExpression类代码示例

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

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



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

示例1: getConstantExpressions

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private List<ConstantExpression> getConstantExpressions(
		ListExpression valueExpression) {
	List<ConstantExpression> expressions = new ArrayList<ConstantExpression>();
	for (Expression expression : valueExpression.getExpressions()) {
		if (expression instanceof ConstantExpression
				&& ((ConstantExpression) expression).getValue() instanceof String) {
			expressions.add((ConstantExpression) expression);
		}
		else {
			reportError(
					"Each entry in the array must be an " + "inline string constant",
					expression);
		}
	}
	return expressions;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:DependencyManagementBomTransformation.java


示例2: getValue

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private List<String> getValue() {
	Expression expression = findAnnotation().getMember("value");
	if (expression instanceof ListExpression) {
		List<String> list = new ArrayList<String>();
		for (Expression ex : ((ListExpression) expression).getExpressions()) {
			list.add((String) ((ConstantExpression) ex).getValue());
		}
		return list;
	}
	else if (expression == null) {
		return null;
	}
	else {
		throw new IllegalStateException("Member 'value' is not a ListExpression");
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:17,代码来源:GenericBomAstTransformationTests.java


示例3: transformInlineConstants

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private Expression transformInlineConstants(Expression exp) {
    if (exp instanceof PropertyExpression) {
        PropertyExpression pe = (PropertyExpression) exp;
        if (pe.getObjectExpression() instanceof ClassExpression) {
            ClassExpression ce = (ClassExpression) pe.getObjectExpression();
            ClassNode type = ce.getType();
            if (type.isEnum()) return exp;
            Expression constant = findConstant(getField(type, pe.getPropertyAsString()));
            if (constant != null) return constant;
        }
    } else if (exp instanceof ListExpression) {
        ListExpression le = (ListExpression) exp;
        ListExpression result = new ListExpression();
        for (Expression e : le.getExpressions()) {
            result.addExpression(transformInlineConstants(e));
        }
        return result;
    }

    return exp;
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:StaticImportVisitor.java


示例4: serialize

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private Expression serialize(Expression e) {
    if (e instanceof AnnotationConstantExpression) {
        AnnotationConstantExpression ace = (AnnotationConstantExpression) e;
        return serialize((AnnotationNode) ace.getValue());
    } else if (e instanceof ListExpression) {
        boolean annotationConstant = false;
        ListExpression le = (ListExpression) e;
        List<Expression> list = le.getExpressions();
        List<Expression> newList = new ArrayList<Expression>(list.size());
        for (Expression exp: list) {
            annotationConstant = annotationConstant || exp instanceof AnnotationConstantExpression;
            newList.add(serialize(exp));
        }
        ClassNode type = ClassHelper.OBJECT_TYPE;
        if (annotationConstant) type = type.makeArray();
        return new ArrayExpression(type, newList);
    }
    return e;
}
 
开发者ID:apache,项目名称:groovy,代码行数:20,代码来源:AnnotationCollectorTransform.java


示例5: getTargetListFromValue

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private List<AnnotationNode> getTargetListFromValue(AnnotationNode collector, AnnotationNode aliasAnnotationUsage, SourceUnit source) {
    Expression memberValue = collector.getMember("value");
    if (memberValue == null) {
        return Collections.emptyList();
    }
    if (!(memberValue instanceof ListExpression)) {
        addError("Annotation collector expected a list of classes, but got a "+memberValue.getClass(), collector, source);
        return Collections.emptyList();
    }
    ListExpression memberListExp = (ListExpression) memberValue;
    List<Expression> memberList = memberListExp.getExpressions();
    if (memberList.isEmpty()) {
        return Collections.emptyList();
    }
    List<AnnotationNode> ret = new ArrayList<AnnotationNode>();
    for (Expression e : memberList) {
        AnnotationNode toAdd = new AnnotationNode(e.getType());
        toAdd.setSourcePosition(aliasAnnotationUsage);
        ret.add(toAdd);
    }
    return ret;
}
 
开发者ID:apache,项目名称:groovy,代码行数:23,代码来源:AnnotationCollectorTransform.java


示例6: getMemberStringList

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
public static List<String> getMemberStringList(AnnotationNode anno, String name) {
    Expression expr = anno.getMember(name);
    if (expr == null) {
        return null;
    }
    if (expr instanceof ListExpression) {
        List<String> list = new ArrayList<String>();
        final ListExpression listExpression = (ListExpression) expr;
        if (isUndefinedMarkerList(listExpression)) {
            return null;
        }
        for (Expression itemExpr : listExpression.getExpressions()) {
            if (itemExpr != null && itemExpr instanceof ConstantExpression) {
                Object value = ((ConstantExpression) itemExpr).getValue();
                if (value != null) list.add(value.toString());
            }
        }
        return list;
    }
    return tokenize(getMemberStringValue(anno, name));
}
 
开发者ID:apache,项目名称:groovy,代码行数:22,代码来源:AbstractASTTransformation.java


示例7: getMemberList

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
@Deprecated
public List<String> getMemberList(AnnotationNode anno, String name) {
    List<String> list;
    Expression expr = anno.getMember(name);
    if (expr != null && expr instanceof ListExpression) {
        list = new ArrayList<String>();
        final ListExpression listExpression = (ListExpression) expr;
        for (Expression itemExpr : listExpression.getExpressions()) {
            if (itemExpr != null && itemExpr instanceof ConstantExpression) {
                Object value = ((ConstantExpression) itemExpr).getValue();
                if (value != null) list.add(value.toString());
            }
        }
    } else {
        list = tokenize(getMemberStringValue(anno, name));
    }
    return list;
}
 
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:AbstractASTTransformation.java


示例8: convertToStringArray

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private static String[] convertToStringArray(final Expression options) {
    if (options==null) {
        return EMPTY_STRING_ARRAY;
    }
    if (options instanceof ConstantExpression) {
        return new String[] { options.getText() };
    }
    if (options instanceof ListExpression) {
        List<Expression> list = ((ListExpression) options).getExpressions();
        List<String> result = new ArrayList<String>(list.size());
        for (Expression expression : list) {
            result.add(expression.getText());
        }
        return result.toArray(new String[result.size()]);
    }
    throw new IllegalArgumentException("Unexpected options for @ClosureParams:"+options);
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:StaticTypeCheckingVisitor.java


示例9: getKnownImmutableClasses

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private List<String> getKnownImmutableClasses(AnnotationNode node) {
    final List<String> immutableClasses = new ArrayList<String>();

    final Expression expression = node.getMember(MEMBER_KNOWN_IMMUTABLE_CLASSES);
    if (expression == null) return immutableClasses;

    if (!(expression instanceof ListExpression)) {
        addError("Use the Groovy list notation [el1, el2] to specify known immutable classes via \"" + MEMBER_KNOWN_IMMUTABLE_CLASSES + "\"", node);
        return immutableClasses;
    }

    final ListExpression listExpression = (ListExpression) expression;
    for (Expression listItemExpression : listExpression.getExpressions()) {
        if (listItemExpression instanceof ClassExpression) {
            immutableClasses.add(listItemExpression.getType().getName());
        }
    }

    return immutableClasses;
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:ImmutableASTTransformation.java


示例10: getKnownImmutables

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private List<String> getKnownImmutables(AnnotationNode node) {
    final List<String> immutables = new ArrayList<String>();

    final Expression expression = node.getMember(MEMBER_KNOWN_IMMUTABLES);
    if (expression == null) return immutables;

    if (!(expression instanceof ListExpression)) {
        addError("Use the Groovy list notation [el1, el2] to specify known immutable property names via \"" + MEMBER_KNOWN_IMMUTABLES + "\"", node);
        return immutables;
    }

    final ListExpression listExpression = (ListExpression) expression;
    for (Expression listItemExpression : listExpression.getExpressions()) {
        if (listItemExpression instanceof ConstantExpression) {
            immutables.add((String) ((ConstantExpression) listItemExpression).getValue());
        }
    }

    return immutables;
}
 
开发者ID:apache,项目名称:groovy,代码行数:21,代码来源:ImmutableASTTransformation.java


示例11: indexExpression

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
protected Expression indexExpression(AST indexNode) {
    AST bracket = indexNode.getFirstChild();
    AST leftNode = bracket.getNextSibling();
    Expression leftExpression = expression(leftNode);

    AST rightNode = leftNode.getNextSibling();
    Expression rightExpression = expression(rightNode);
    // easier to massage here than in the grammar
    if (rightExpression instanceof SpreadExpression) {
        ListExpression wrapped = new ListExpression();
        wrapped.addExpression(rightExpression);
        rightExpression = wrapped;
    }

    BinaryExpression binaryExpression = new BinaryExpression(leftExpression, makeToken(Types.LEFT_SQUARE_BRACKET, bracket), rightExpression);
    configureAST(binaryExpression, indexNode);
    return binaryExpression;
}
 
开发者ID:apache,项目名称:groovy,代码行数:19,代码来源:AntlrParserPlugin.java


示例12: containsSpreadExpression

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
public static boolean containsSpreadExpression(Expression arguments) {
    List args = null;
    if (arguments instanceof TupleExpression) {
        TupleExpression tupleExpression = (TupleExpression) arguments;
        args = tupleExpression.getExpressions();
    } else if (arguments instanceof ListExpression) {
        ListExpression le = (ListExpression) arguments;
        args = le.getExpressions();
    } else {
        return arguments instanceof SpreadExpression;
    }
    for (Iterator iter = args.iterator(); iter.hasNext();) {
        if (iter.next() instanceof SpreadExpression) return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:groovy,代码行数:17,代码来源:AsmClassGenerator.java


示例13: annotationValueToExpression

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private Expression annotationValueToExpression (Object value) {
    if (value == null || value instanceof String || value instanceof Number || value instanceof Character || value instanceof Boolean)
        return new ConstantExpression(value);

    if (value instanceof Class)
        return new ClassExpression(ClassHelper.makeWithoutCaching((Class)value));

    if (value.getClass().isArray()) {
        ListExpression elementExprs = new ListExpression();
        int len = Array.getLength(value);
        for (int i = 0; i != len; ++i)
            elementExprs.addExpression(annotationValueToExpression(Array.get(value, i)));
        return elementExprs;
    }

    return null;
}
 
开发者ID:apache,项目名称:groovy,代码行数:18,代码来源:Java5.java


示例14: addDependencyManagementBom

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private void addDependencyManagementBom(ModuleNode node, String module) {
	AnnotatedNode annotated = getAnnotatedNode(node);
	if (annotated != null) {
		AnnotationNode bom = getAnnotation(annotated);
		List<Expression> expressions = new ArrayList<Expression>(
				getConstantExpressions(bom.getMember("value")));
		expressions.add(new ConstantExpression(module));
		bom.setMember("value", new ListExpression(expressions));
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:GenericBomAstTransformation.java


示例15: getConstantExpressions

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private List<ConstantExpression> getConstantExpressions(Expression valueExpression) {
	if (valueExpression instanceof ListExpression) {
		return getConstantExpressions((ListExpression) valueExpression);
	}
	if (valueExpression instanceof ConstantExpression
			&& ((ConstantExpression) valueExpression).getValue() instanceof String) {
		return Arrays.asList((ConstantExpression) valueExpression);
	}
	return Collections.emptyList();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:GenericBomAstTransformation.java


示例16: visitList

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
@Override
public ListExpression visitList(ListContext ctx) {
    if (asBoolean(ctx.COMMA()) && !asBoolean(ctx.expressionList())) {
        throw createParsingFailedException("Empty list constructor should not contain any comma(,)", ctx.COMMA());
    }

    return configureAST(
            new ListExpression(
                    this.visitExpressionList(ctx.expressionList())),
            ctx);
}
 
开发者ID:apache,项目名称:groovy,代码行数:12,代码来源:AstBuilder.java


示例17: checkAnnotationMemberValue

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private void checkAnnotationMemberValue(Expression newValue) {
    if (newValue instanceof PropertyExpression) {
        PropertyExpression pe = (PropertyExpression) newValue;
        if (!(pe.getObjectExpression() instanceof ClassExpression)) {
            addError("unable to find class '" + pe.getText() + "' for annotation attribute constant", pe.getObjectExpression());
        }
    } else if (newValue instanceof ListExpression) {
        ListExpression le = (ListExpression) newValue;
        for (Expression e : le.getExpressions()) {
            checkAnnotationMemberValue(e);
        }
    }
}
 
开发者ID:apache,项目名称:groovy,代码行数:14,代码来源:ResolveVisitor.java


示例18: isUndefinedMarkerList

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private static boolean isUndefinedMarkerList(ListExpression listExpression) {
    if (listExpression.getExpressions().size() != 1) return false;
    Expression itemExpr = listExpression.getExpression(0);
    if (itemExpr == null) return false;
    if (itemExpr instanceof ConstantExpression) {
        Object value = ((ConstantExpression) itemExpr).getValue();
        if (value instanceof String && isUndefined((String)value)) return true;
    } else if (itemExpr instanceof ClassExpression && isUndefined(itemExpr.getType())) {
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:groovy,代码行数:13,代码来源:AbstractASTTransformation.java


示例19: typeCheckMultipleAssignmentAndContinue

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
private boolean typeCheckMultipleAssignmentAndContinue(Expression leftExpression, Expression rightExpression) {
    // multiple assignment check
    if (!(leftExpression instanceof TupleExpression)) return true;

    if (!(rightExpression instanceof ListExpression)) {
        addStaticTypeError("Multiple assignments without list expressions on the right hand side are unsupported in static type checking mode", rightExpression);
        return false;
    }

    TupleExpression tuple = (TupleExpression) leftExpression;
    ListExpression list = (ListExpression) rightExpression;
    List<Expression> listExpressions = list.getExpressions();
    List<Expression> tupleExpressions = tuple.getExpressions();
    if (listExpressions.size() < tupleExpressions.size()) {
        addStaticTypeError("Incorrect number of values. Expected:" + tupleExpressions.size() + " Was:" + listExpressions.size(), list);
        return false;
    }
    for (int i = 0, tupleExpressionsSize = tupleExpressions.size(); i < tupleExpressionsSize; i++) {
        Expression tupleExpression = tupleExpressions.get(i);
        Expression listExpression = listExpressions.get(i);
        ClassNode elemType = getType(listExpression);
        ClassNode tupleType = getType(tupleExpression);
        if (!isAssignableTo(elemType, tupleType)) {
            addStaticTypeError("Cannot assign value of type " + elemType.toString(false) + " to variable of type " + tupleType.toString(false), rightExpression);
            return false; // avoids too many errors
        } else {
            storeType(tupleExpression, elemType);
        }
    }

    return true;
}
 
开发者ID:apache,项目名称:groovy,代码行数:33,代码来源:StaticTypeCheckingVisitor.java


示例20: inferListExpressionType

import org.codehaus.groovy.ast.expr.ListExpression; //导入依赖的package包/类
protected ClassNode inferListExpressionType(final ListExpression list) {
    List<Expression> expressions = list.getExpressions();
    if (expressions.isEmpty()) {
        // cannot infer, return list type
        return list.getType();
    }
    ClassNode listType = list.getType();
    GenericsType[] genericsTypes = listType.getGenericsTypes();
    if ((genericsTypes == null
            || genericsTypes.length == 0
            || (genericsTypes.length == 1 && OBJECT_TYPE.equals(genericsTypes[0].getType())))
            && (!expressions.isEmpty())) {
        // maybe we can infer the component type
        List<ClassNode> nodes = new LinkedList<ClassNode>();
        for (Expression expression : expressions) {
            if (isNullConstant(expression)) {
                // a null element is found in the list, skip it because we'll use the other elements from the list
            } else {
                nodes.add(getType(expression));
            }
        }
        if (nodes.isEmpty()) {
            // every element was the null constant
            return listType;
        }
        ClassNode superType = getWrapper(lowestUpperBound(nodes)); // to be used in generics, type must be boxed
        ClassNode inferred = listType.getPlainNodeReference();
        inferred.setGenericsTypes(new GenericsType[]{new GenericsType(wrapTypeIfNecessary(superType))});
        return inferred;
    }
    return listType;
}
 
开发者ID:apache,项目名称:groovy,代码行数:33,代码来源:StaticTypeCheckingVisitor.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ImmutableDataManipulator类代码示例发布时间:2022-05-23
下一篇:
Java ClickHandler类代码示例发布时间: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