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


Java XVariableDeclaration.getType方法代码示例

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


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

示例1: appendVariableTypeAndName

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
protected LightweightTypeReference appendVariableTypeAndName(XVariableDeclaration varDeclaration, ITreeAppendable appendable) {
    if (!varDeclaration.isWriteable()) {
        appendable.append("final ");
    }
    LightweightTypeReference type = null;
    if (varDeclaration.getType() != null) {
        serialize(varDeclaration.getType(), varDeclaration, appendable);
        type = getLightweightType((JvmIdentifiableElement) varDeclaration);
    } else {
        type = getLightweightType(varDeclaration.getRight());
        if (type.isAny()) {
            type = getTypeForVariableDeclaration(varDeclaration.getRight());
        }
        appendable.append(type);
    }
    appendable.append(" ");
    appendable.append(appendable.declareVariable(varDeclaration, makeJavaIdentifier(varDeclaration.getName())));
    return type;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:XbaseCompiler.java

示例2: createVarFeatures

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
private Collection<? extends IEObjectDescription> createVarFeatures(Resource resource) {
    List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>();

    if(resource.getContents().size()>0 && resource.getContents().get(0) instanceof RuleModel) {
        RuleModel ruleModel = (RuleModel) resource.getContents().get(0);
        for(XExpression expr : ruleModel.getVariables()) {
            if (expr instanceof XVariableDeclaration) {
                XVariableDeclaration var = (XVariableDeclaration) expr;
                if(var.getName()!=null && var.getType()!=null) {
                    descriptions.add(createLocalVarDescription(var));
                }
            }
        }
    }
    
    return descriptions;
}
 
开发者ID:andrey-desman,项目名称:openhab-hdl,代码行数:18,代码来源:RulesScopeProvider.java

示例3: checkVariableIsNotInferredAsVoid

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Check
public void checkVariableIsNotInferredAsVoid(XVariableDeclaration declaration) {
    if (declaration.getType() != null)
        return;
    LightweightTypeReference variableType = typeResolver.resolveTypes(declaration).getActualType((JvmIdentifiableElement) declaration);
    // TODO move to type resolver
    if (variableType != null && variableType.isPrimitiveVoid()) {
        error("void is an invalid type for the variable " + declaration.getName(), declaration,
                XbasePackage.Literals.XVARIABLE_DECLARATION__NAME, INVALID_USE_OF_TYPE);
    }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:XbaseValidator.java

示例4: checkVariableDeclaration

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Check
public void checkVariableDeclaration(XVariableDeclaration declaration) {
    if (declaration.getRight() == null) {
        if (!declaration.isWriteable())
            error("Value must be initialized", Literals.XVARIABLE_DECLARATION__WRITEABLE,
                    ValidationMessageAcceptor.INSIGNIFICANT_INDEX, MISSING_INITIALIZATION);
        if (declaration.getType() == null)
            error("Type cannot be derived", Literals.XVARIABLE_DECLARATION__NAME,
                    ValidationMessageAcceptor.INSIGNIFICANT_INDEX, MISSING_TYPE);
    }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:12,代码来源:XbaseValidator.java

示例5: _assignValueTo

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
/**
 * @param assignment unused in this context but required for dispatching
 * @param indicator unused in this context but required for dispatching
 */
protected Object _assignValueTo(XVariableDeclaration variable, XAbstractFeatureCall assignment, Object value,
        IEvaluationContext context, CancelIndicator indicator) {
    if (variable.getType() != null) {
        JvmTypeReference type = variable.getType();
        Object coerced = coerceArgumentType(value, type);
        context.assignValue(QualifiedName.create(variable.getName()), coerced);
    } else {
        context.assignValue(QualifiedName.create(variable.getName()), value);
    }
    return value;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:16,代码来源:XbaseInterpreter.java

示例6: testReferenceToString_3

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
@Test
public void testReferenceToString_3() throws Exception {
    XExpression expr = expression("{ var foo.String x }", false);
    assertNotNull(expr);
    XVariableDeclaration declaration = (XVariableDeclaration) (((XBlockExpression) expr).getExpressions().get(0));
    JvmTypeReference reference = declaration.getType();
    assertEquals("String", this.uiStrings.referenceToString(reference, "the-default-value"));
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:UIStringsTest.java

示例7: _applyRuleXVariableDeclarationType_1

import org.eclipse.xtext.xbase.XVariableDeclaration; //导入方法依赖的package包/类
private JvmTypeReference _applyRuleXVariableDeclarationType_1(final RuleEnvironment G, final XVariableDeclaration e) throws RuleFailedException {
  JvmTypeReference _type = e.getType();
  return _type;
}
 
开发者ID:eclipse,项目名称:xsemantics,代码行数:5,代码来源:XsemanticsTypeSystemGen.java


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