本文整理汇总了Java中org.eclipse.xtext.xbase.XListLiteral.getElements方法的典型用法代码示例。如果您正苦于以下问题:Java XListLiteral.getElements方法的具体用法?Java XListLiteral.getElements怎么用?Java XListLiteral.getElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.xtext.xbase.XListLiteral
的用法示例。
在下文中一共展示了XListLiteral.getElements方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeArrayLiteralType
import org.eclipse.xtext.xbase.XListLiteral; //导入方法依赖的package包/类
protected void computeArrayLiteralType(XListLiteral literal, LightweightTypeReference expectedArrayType, ITypeExpectation expectation,
ITypeComputationState state) {
LightweightTypeReference elementTypeExpectation = getElementOrComponentType(expectedArrayType, state);
int allFlags = 0;
for(XExpression element: literal.getElements()) {
ITypeComputationResult elementTypeResult = computeTypes(element, elementTypeExpectation, state);
deferredBindTypeArgument(elementTypeExpectation, elementTypeResult.getActualExpressionType(), state);
allFlags |= elementTypeResult.getCheckedConformanceFlags();
}
if ((allFlags & ConformanceFlags.INCOMPATIBLE) != 0) {
allFlags &= (~ConformanceFlags.SUCCESS);
allFlags |= ConformanceFlags.SEALED | ConformanceFlags.CHECKED | ConformanceFlags.PROPAGATED_TYPE;
expectation.acceptActualType(expectedArrayType, allFlags);
} else if ((allFlags & ConformanceFlags.SUCCESS) != 0) {
allFlags |= ConformanceFlags.SEALED | ConformanceFlags.CHECKED;
expectation.acceptActualType(expectedArrayType, allFlags);
} else {
expectation.acceptActualType(expectedArrayType, ConformanceFlags.CHECKED_SUCCESS | ConformanceFlags.SEALED);
}
}
示例2: _doEvaluate
import org.eclipse.xtext.xbase.XListLiteral; //导入方法依赖的package包/类
protected Object _doEvaluate(XListLiteral literal, IEvaluationContext context, CancelIndicator indicator) {
IResolvedTypes resolveTypes = typeResolver.resolveTypes(literal);
LightweightTypeReference type = resolveTypes.getActualType(literal);
List<Object> list = newArrayList();
for(XExpression element: literal.getElements()) {
if (indicator.isCanceled())
throw new InterpreterCanceledException();
list.add(internalEvaluate(element, context, indicator));
}
if(type != null && type.isArray()) {
try {
LightweightTypeReference componentType = type.getComponentType();
return Conversions.unwrapArray(list, getJavaType(componentType.getType()));
} catch (ClassNotFoundException e) {
}
}
return Collections.unmodifiableList(list);
}
示例3: canUseArrayInitializerImpl
import org.eclipse.xtext.xbase.XListLiteral; //导入方法依赖的package包/类
protected boolean canUseArrayInitializerImpl(XListLiteral literal, ITreeAppendable appendable) {
for(XExpression element: literal.getElements()) {
if (isVariableDeclarationRequired(element, appendable, true))
return false;
}
return true;
}
示例4: _toJavaStatement
import org.eclipse.xtext.xbase.XListLiteral; //导入方法依赖的package包/类
/**
* @param isReferenced unused in this context but necessary for dispatch signature
*/
protected void _toJavaStatement(XListLiteral literal, ITreeAppendable b, boolean isReferenced) {
for(XExpression element: literal.getElements())
internalToJavaStatement(element, b, true);
}
示例5: _toJavaExpression
import org.eclipse.xtext.xbase.XListLiteral; //导入方法依赖的package包/类
protected void _toJavaExpression(XListLiteral literal, ITreeAppendable b) {
LightweightTypeReference literalType = batchTypeResolver.resolveTypes(literal).getActualType(literal);
if (literalType == null) {
b.append("error - couldn't compute type for literal : "+literal);
return;
}
if (literalType.isArray()) {
LightweightTypeReference expectedType = batchTypeResolver.resolveTypes(literal).getExpectedType(literal);
boolean skipTypeName = false;
if (expectedType != null && expectedType.isArray()) {
if (canUseArrayInitializer(literal, b)) {
skipTypeName = true;
}
}
if (!skipTypeName) {
if (literalType instanceof CompoundTypeReference) {
for (LightweightTypeReference c : literalType.getMultiTypeComponents()) {
if (c.isArray()) {
b.append("new ")
.append(c.getType()) // append raw type since we cannot create generic arrays
.append(" ");
break;
}
}
} else {
b.append("new ")
.append(literalType.getType()) // append raw type since we cannot create generic arrays
.append(" ");
}
}
if (literal.getElements().isEmpty()) {
b.append("{}");
} else {
b.append("{ ");
boolean isFirst = true;
for(XExpression element: literal.getElements()) {
if(!isFirst)
b.append(", ");
isFirst = false;
internalToJavaExpression(element, b);
}
b.append(" }");
}
return;
} else {
appendImmutableCollectionExpression(literal, b, "unmodifiableList", CollectionLiterals.class, "newArrayList");
}
}