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


Java XListLiteral.getElements方法代码示例

本文整理汇总了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);
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:CollectionLiteralsTypeComputer.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:XbaseInterpreter.java

示例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;
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseCompiler.java

示例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);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseCompiler.java

示例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");
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:49,代码来源:XbaseCompiler.java


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