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


Java VilException.ID_SEMANTIC属性代码示例

本文整理汇总了Java中net.ssehub.easy.instantiation.core.model.common.VilException.ID_SEMANTIC属性的典型用法代码示例。如果您正苦于以下问题:Java VilException.ID_SEMANTIC属性的具体用法?Java VilException.ID_SEMANTIC怎么用?Java VilException.ID_SEMANTIC使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在net.ssehub.easy.instantiation.core.model.common.VilException的用法示例。


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

示例1: inferType

@Override
public TypeDescriptor<?> inferType() throws VilException {
    TypeDescriptor<?> result = super.inferType();
    if (null != specifiedType && !specifiedType.isAssignableFrom(result)) {
        boolean ok = checkEmptyContainerIntializerCompliance(result, specifiedType);
        if (!ok && specifiedType.getBaseType() instanceof TypeDescriptor) {
            ok = checkEmptyContainerIntializerCompliance(result, (TypeDescriptor<?>) specifiedType.getBaseType());
        }
        if (!ok) {
            throw new VilException("resulting type of block " + result.getVilName() 
                + " does not fit to specified type " + specifiedType.getVilName(), 
                VilException.ID_SEMANTIC);
        }
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:16,代码来源:Def.java

示例2: MapExpression

/**
 * Creates a map statement.
 * 
 * @param variables the variables to iterate over (including values)
 * @param expr the expression denoting on what to iterate / map
 * @param body the body elements
 * @param givenTypes the given types in addition to the inferred types
 *   of the <code>variable</code> (may be <b>null</b>; if given must have
 *   same length as <code>variables</code>, may contain <b>null</b> if no type
 *   is given, types must at least be supertypes of those in <code>variables</code>)
 * @param colon <code>true</code> it it was a colon, <code>else</code> if it was an equals character
 * @throws VilException in case of syntactic or semantic problems
 */
public MapExpression(VariableDeclaration[] variables, Expression expr, IRuleElement[] body, 
    TypeDescriptor<?>[] givenTypes, boolean colon) throws VilException {
    if (null == variables || variables.length < 1) {
        throw new VilException("no iterator variables given", VilException.ID_SEMANTIC);
    }
    if (null != givenTypes && variables.length != givenTypes.length) {
        throw new VilException("given types length does not match to variables length", 
            VilException.ID_SEMANTIC);
    }
    this.variables = variables;
    this.colon = colon;
    if (null == expr) {
        throw new VilException("no expression given", VilException.ID_SEMANTIC);
    }
    this.expr = expr;
    this.body = body;
    this.givenTypes = givenTypes;
    this.colon = colon;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:32,代码来源:MapExpression.java

示例3: ensureType

/**
 * Ensures a collection type for <code>type</code>.
 * @param type the type to be checked and ensured
 * @return the collection type
 * @throws VilException in case that <code>type</code> cannot be converted into a collection type
 */
@SuppressWarnings("unchecked")
protected static TypeDescriptor<? extends Collection<? extends IArtifact>> ensureType(
    TypeDescriptor<?> type) throws VilException {
    if (!type.isCollection()) {
        throw new VilException(type.getVilName() + "is not a collection", 
            VilException.ID_SEMANTIC);
    }
    if (type.getGenericParameterCount() != 1) {
        throw new VilException("collection in " + type.getVilName() + "is not generic over one type", 
            VilException.ID_SEMANTIC);
    }
    if (!ArtifactTypes.artifactType().isAssignableFrom(type.getGenericParameterType(0))) {
        throw new VilException("collection in " + type.getVilName() + "is not generic over one type", 
            VilException.ID_SEMANTIC);
    }
    TypeDescriptor<? extends Collection<? extends IArtifact>> result;
    try {
        result = (TypeDescriptor<? extends Collection<? extends IArtifact>>) type;
    } catch (ClassCastException e) { // just to be sure
        throw new VilException(e.getMessage(), VilException.ID_SEMANTIC);
    }
    return result;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:29,代码来源:AbstractRuleMatchExpression.java

示例4: Template

/**
 * Creates a VIL template instance.
 * 
 * @param name the name
 * @param extension the extended template (may be <b>null</b>)
 * @param descriptor information to create the template from
 * @param registry the registry responsible for this template
 * @throws VilException in case of erroneous input
 */
public Template(String name, ModelImport<Template> extension, TemplateDescriptor descriptor, TypeRegistry registry) 
    throws VilException {
    super(descriptor.getImports(), registry, descriptor.getAdvices());
    if (null == name || name.length() == 0) {
        throw new VilException("no name given", VilException.ID_SEMANTIC);
    }
    this.name = name;
    this.extension = extension;
    this.javaExtensions = descriptor.getJavaExtensions();
    this.param = descriptor.getParameter();
    this.namedParams = VariableDeclaration.mapDefaultedParameters(this.namedParams, this.param);
    this.indentationConfiguration = descriptor.getIndentationConfiguration();
    this.formattingConfiguration = descriptor.getFormattingConfiguration();
    adjustParents();
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:24,代码来源:Template.java

示例5: inferType

@Override
public TypeDescriptor<?> inferType() throws VilException {
    if (null == type) {
        TypeDescriptor<?>[] parameter;
        if (getInitExpressionsCount() > 0) {
            List<TypeDescriptor<?>> params = new ArrayList<TypeDescriptor<?>>();
            List<TypeDescriptor<?>> local = new ArrayList<TypeDescriptor<?>>();
            for (int e = 0; e < getInitExpressionsCount(); e++) {
                Expression ex = getInitExpression(e);
                local.clear();
                if (ex instanceof ContainerInitializerExpression) {
                    ContainerInitializerExpression initEx = (ContainerInitializerExpression) ex;
                    for (int i = 0; i < initEx.getInitExpressionsCount(); i++) {
                        local.add(initEx.getInitExpression(i).inferType());
                    }
                } else {
                    local.add(ex.inferType());
                }
                if (0 == e) {
                    params.addAll(local);
                } else {
                    if (params.size() != local.size()) {
                        throw new VilException("parameter size does not match", 
                            VilException.ID_SEMANTIC);
                    } else {
                        for (int p = 0; p < params.size(); p++) {
                            params.set(p, moreCommon(params.get(p), local.get(p)));
                        }
                    }
                }
            }
            parameter = TypeDescriptor.createArray(params.size());
            params.toArray(parameter);
        } else {
            parameter = null;
        }
        type = TypeRegistry.getSequenceType(parameter); // allow duplicates, map will convert automatically
    }
    return type;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:40,代码来源:ContainerInitializerExpression.java

示例6: ConstructorCallExpression

/**
 * Creates a constructor call.
 * 
 * @param type the type to obtain the constructor from
 * @param arguments the arguments
 * @throws VilException in case that determining the type fails
 */
public ConstructorCallExpression(TypeDescriptor<?> type, Expression... arguments) 
    throws VilException {
    super(null, OperationDescriptor.CONSTRUCTOR_NAME, arguments);
    if (null == type) {
        throw new VilException("cannot resolve type", VilException.ID_SEMANTIC);
    }
    this.type = type;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:15,代码来源:ConstructorCallExpression.java

示例7: ContentStatement

/**
 * Creates a new content statement.
 * 
 * @param content the content
 * @param terminal the limiting terminal (at start and end)
 * @param indentExpression an optional integer expression determining the additional 
 *     indentation, e.g., in loops or recursions
 * @param lineEndType the line end type
 * @param parent the parent language element
 * @throws VilException in case that the expression cannot be resolved or does not evaluate to an integer
 */
public ContentStatement(CompositeExpression content, String terminal, Expression indentExpression, 
    LineEndType lineEndType, ILanguageElement parent) throws VilException {
    setParent(parent);
    this.lineEndType = lineEndType;
    this.content = content;
    this.terminal = terminal;
    this.indentExpression = indentExpression;
    if (null != this.indentExpression) {
        if (this.indentExpression.inferType() != TypeRegistry.integerType()) {
            throw new VilException("indent expression must result in an Integer", 
                VilException.ID_SEMANTIC);
        }
    }
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:25,代码来源:ContentStatement.java

示例8: PathMatchExpression

/**
 * Creates a path match expression.
 * 
 * @param expression the path expression
 * @throws VilException in case that the expression is invalid
 */
public PathMatchExpression(Expression expression) throws VilException {
    if (TypeRegistry.DEFAULT.getType(Path.class) != expression.inferType()) {
        throw new VilException("expression does not evaluate to a path", VilException.ID_SEMANTIC);
    }
    this.pathExpression = expression;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:12,代码来源:PathMatchExpression.java

示例9: ArtifactMatchExpression

/**
 * Creates a new collection match expression.
 * 
 * @param expression an expression which evaluates to a collection
 * @throws VilException in case that the expression does not evaluate to a collection
 */
public ArtifactMatchExpression(Expression expression) throws VilException {
    if (!ArtifactTypes.artifactType().isAssignableFrom(expression.inferType())) {
        throw new VilException("expression does not evaluate to an artifact", 
            VilException.ID_SEMANTIC);
    }
    this.expression = expression;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:13,代码来源:ArtifactMatchExpression.java

示例10: BooleanMatchExpression

/**
 * Creates a new Boolean match expression.
 * 
 * @param expression an expression which evaluates to a Boolean
 * @throws VilException in case that the expression does not evaluate to a Boolean
 */
public BooleanMatchExpression(Expression expression) throws VilException {
    if (TypeRegistry.booleanType() != expression.inferType()) {
        throw new VilException("expression does not evaluate to a Boolean", 
            VilException.ID_SEMANTIC);
    }
    this.expression = expression;        
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:13,代码来源:BooleanMatchExpression.java

示例11: checkConstants

/**
 * Checks the constant values for proper initialization.
 * 
 * @param script the project to process the properties for
 * @throws VilException in case that something goes wrong
 */
private void checkConstants(Script script) throws VilException {
    for (int v = 0; v < script.getVariableDeclarationCount(); v++) {
        VariableDeclaration var = script.getVariableDeclaration(v);
        if (var.isConstant()) {
            if (!environment.isDefined(var)) {
                throw new VilException("constant '" + var.getName() + "' must be assigned a value " 
                    + "(either in script or via loaded properties)", VilException.ID_SEMANTIC);
            }
        }
    }        
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:17,代码来源:BuildlangExecution.java

示例12: AlternativeExpression

/**
 * Creates an alternative expression.
 * 
 * @param condition the condition to be evaluated
 * @param ifPart the if-part to be executed if the alternative is true
 * @param elsePart the optional else-part to be executed if the alternative is false
 * @throws VilException in case of syntactic or semantic problems
 */
public AlternativeExpression(Expression condition, IRuleBlock ifPart, IRuleBlock elsePart) 
    throws VilException {
    if (null == condition) {
        throw new VilException("no condition given", VilException.ID_SEMANTIC);
    }
    if (null == ifPart) {
        throw new VilException("no if-part given", VilException.ID_SEMANTIC);
    }
    this.condition = condition;
    this.ifPart = ifPart;
    this.elsePart = elsePart;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:20,代码来源:AlternativeExpression.java

示例13: inferType

@Override
public TypeDescriptor<?> inferType() throws VilException {
    if (null == type) {
        Expression thenExpr = Utils.findLastExpression(ifPart);
        Expression elseExpr = null == elsePart ? null : Utils.findLastExpression(elsePart);
        if (null == elseExpr) { // then may be null, else part or else expr is null
            if (null == thenExpr) {
                type = TypeRegistry.voidType();
            } else {
                type = thenExpr.inferType();
            }
        } else {
            if (null == thenExpr) {
                type = elseExpr.inferType();
            } else {
                TypeDescriptor<?> thenType = thenExpr.inferType();
                TypeDescriptor<?> elseType = elseExpr.inferType();
                if (thenType.isAssignableFrom(elseType)) {
                    type = thenType;
                } else if (elseType.isAssignableFrom(thenType)) {
                    type = elseType;
                } else {
                    throw new VilException("if given, both paths must lead to compatible types", 
                        VilException.ID_SEMANTIC);
                }
            }
        }
    } 
    return type;
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:30,代码来源:AlternativeExpression.java

示例14: getJoinVariableType

/**
 * Determine the type of the join variable from the initializing expression.
 * 
 * @param expr the expression used for the initialization
 * @return the actual type of the join variable
 * @throws VilException in case that <code>expr</code> is not a collection or does not have exactly 
 *   one parameter
 */
private static TypeDescriptor<?> getJoinVariableType(Expression expr) throws VilException {
    TypeDescriptor<?> exprType = expr.inferType();
    if (exprType.isCollection() && 1 != exprType.getGenericParameterCount()) {
        throw new VilException("parameter must be set or sequence with one generic type", 
            VilException.ID_SEMANTIC);
    }
    return exprType.getGenericParameterType(0);
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:16,代码来源:JoinVariableDeclaration.java

示例15: visitLoop

@Override
public Object visitLoop(LoopStatement loop) throws VilException {
    Object object;
    Expression expr = loop.getContainerExpression();
    object = convertToContainer(expr, expr.accept(this), "loop");
    String separator = getSeparatorFromExpression(loop.getSeparatorExpression());
    String finalSeparator = getSeparatorFromExpression(loop.getFinalSeparatorExpression());

    Object bodyResult = NullValue.VALUE;
    if (object instanceof Collection<?>) {
        VariableDeclaration iterVar = loop.getIteratorVariable();
        environment.pushLevel();
        Collection<?> collection = (Collection<?>) object;
        Iterator<?> iter = collection.iterator();
        tracer.visitLoop(iterVar);
        while (iter.hasNext() && !stop) {
            Object value = iter.next();
            environment.addValue(iterVar, value);
            tracer.valueDefined(iterVar, null, value);
            ITemplateElement loopStmt = loop.getLoopStatement();
            increaseIndentation(loopStmt);
            bodyResult = loopStmt.accept(this);
            decreaseIndentation(loopStmt);
            if (null != separator && iter.hasNext()) {
                appendContent(separator);
            }
            if (null != finalSeparator && !iter.hasNext()) {
                appendContent(finalSeparator);
            }
        }
        tracer.visitedLoop(iterVar);
        environment.popLevel();
    } else {
        if (null != object) {
            throw new VilException("loop must iterate over collection", VilException.ID_SEMANTIC);
        }
    }
    return checkContentStatement(bodyResult, NullValue.VALUE, loop.getLoopStatement());
}
 
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:39,代码来源:TemplateLangExecution.java


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