本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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"));
}
示例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;
}