本文整理汇总了Java中org.eclipse.xtext.xbase.XSetLiteral类的典型用法代码示例。如果您正苦于以下问题:Java XSetLiteral类的具体用法?Java XSetLiteral怎么用?Java XSetLiteral使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XSetLiteral类属于org.eclipse.xtext.xbase包,在下文中一共展示了XSetLiteral类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: _toJavaExpression
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
protected void _toJavaExpression(XSetLiteral 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.isType(Map.class)) {
LightweightTypeReference keyType = literalType.getTypeArguments().get(0);
LightweightTypeReference valueType = literalType.getTypeArguments().get(1);
b.append(Collections.class)
.append(".<").append(keyType).append(", ").append(valueType)
.append(">unmodifiableMap(");
b.append(CollectionLiterals.class).append(".<").append(keyType).append(", ").append(valueType).append(">newHashMap(");
Iterator<XExpression> elements = literal.getElements().iterator();
while(elements.hasNext()) {
XExpression element = elements.next();
internalToJavaExpression(element, b);
if (elements.hasNext()) {
b.append(", ");
}
}
b.append("))");
} else {
appendImmutableCollectionExpression(literal, b, "unmodifiableSet", CollectionLiterals.class, "newHashSet");
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:27,代码来源:XbaseCompiler.java
示例2: appendImmutableCollectionExpression
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
@Override
protected void appendImmutableCollectionExpression(final XCollectionLiteral literal, final ITreeAppendable b, final String collectionsMethod, final Class<?> guavaHelper, final String guavaHelperMethod) {
// This is a work-around for a bug in the xbase compiler, which always constructs empty list literals #[] as List<Object>,
// which then cannot be assigned (without cast) to any typed list. Note that this is not a problem in check; it also occurs
// in plain xtend.
if (literal.getElements().isEmpty()) {
JvmType collectionsClass = findKnownTopLevelType(Collections.class, literal);
if (collectionsClass != null) {
if (literal instanceof XListLiteral) {
b.append(collectionsClass).append(".emptyList()");
return;
} else if (literal instanceof XSetLiteral) {
b.append(collectionsClass).append(".emptySet()");
return;
}
}
}
super.appendImmutableCollectionExpression(literal, b, collectionsMethod, guavaHelper, guavaHelperMethod);
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:20,代码来源:CheckCompiler.java
示例3: computeType
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
/**
* Entry point from the {@link XbaseTypeComputer}.
*/
public void computeType(XSetLiteral literal, ITypeComputationState state) {
JvmGenericType setType = findDeclaredType(Set.class, state);
if (setType == null) {
handleCollectionTypeNotAvailable(literal, state, Set.class);
return;
}
JvmGenericType mapType = findDeclaredType(Map.class, state);
for(ITypeExpectation expectation: state.getExpectations()) {
computeType(literal, setType, mapType, expectation, state);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:15,代码来源:CollectionLiteralsTypeComputer.java
示例4: internalToConvertedExpression
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
@Override
protected void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) {
if (obj instanceof XBlockExpression) {
_toJavaExpression((XBlockExpression) obj, appendable);
} else if (obj instanceof XCastedExpression) {
_toJavaExpression((XCastedExpression) obj, appendable);
} else if (obj instanceof XClosure) {
_toJavaExpression((XClosure) obj, appendable);
} else if (obj instanceof XAnnotation) {
_toJavaExpression((XAnnotation) obj, appendable);
} else if (obj instanceof XConstructorCall) {
_toJavaExpression((XConstructorCall) obj, appendable);
} else if (obj instanceof XIfExpression) {
_toJavaExpression((XIfExpression) obj, appendable);
} else if (obj instanceof XInstanceOfExpression) {
_toJavaExpression((XInstanceOfExpression) obj, appendable);
} else if (obj instanceof XSwitchExpression) {
_toJavaExpression((XSwitchExpression) obj, appendable);
} else if (obj instanceof XTryCatchFinallyExpression) {
_toJavaExpression((XTryCatchFinallyExpression) obj, appendable);
} else if (obj instanceof XListLiteral) {
_toJavaExpression((XListLiteral) obj, appendable);
} else if (obj instanceof XSetLiteral) {
_toJavaExpression((XSetLiteral) obj, appendable);
} else if (obj instanceof XSynchronizedExpression) {
_toJavaExpression((XSynchronizedExpression) obj, appendable);
} else if (obj instanceof XReturnExpression) {
_toJavaExpression((XReturnExpression) obj, appendable);
} else if (obj instanceof XThrowExpression) {
_toJavaExpression((XThrowExpression) obj, appendable);
} else {
super.internalToConvertedExpression(obj, appendable);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:35,代码来源:XbaseCompiler.java
示例5: sequence_XSetLiteral
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
@Deprecated
protected void sequence_XSetLiteral(EObject context, XSetLiteral semanticObject) {
sequence_XSetLiteral(createContext(context, semanticObject), semanticObject);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:5,代码来源:AbstractXbaseSemanticSequencer.java
示例6: computeTypes
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
@Override
public void computeTypes(XExpression expression, ITypeComputationState state) {
if (expression instanceof XAssignment) {
_computeTypes((XAssignment)expression, state);
} else if (expression instanceof XAbstractFeatureCall) {
_computeTypes((XAbstractFeatureCall)expression, state);
} else if (expression instanceof XDoWhileExpression) {
_computeTypes((XDoWhileExpression)expression, state);
} else if (expression instanceof XWhileExpression) {
_computeTypes((XWhileExpression)expression, state);
} else if (expression instanceof XBlockExpression) {
_computeTypes((XBlockExpression)expression, state);
} else if (expression instanceof XBooleanLiteral) {
_computeTypes((XBooleanLiteral)expression, state);
} else if (expression instanceof XCastedExpression) {
_computeTypes((XCastedExpression)expression, state);
} else if (expression instanceof XClosure) {
_computeTypes((XClosure)expression, state);
} else if (expression instanceof XConstructorCall) {
_computeTypes((XConstructorCall)expression, state);
} else if (expression instanceof XForLoopExpression) {
_computeTypes((XForLoopExpression)expression, state);
} else if (expression instanceof XBasicForLoopExpression) {
_computeTypes((XBasicForLoopExpression)expression, state);
} else if (expression instanceof XIfExpression) {
_computeTypes((XIfExpression)expression, state);
} else if (expression instanceof XInstanceOfExpression) {
_computeTypes((XInstanceOfExpression)expression, state);
} else if (expression instanceof XNumberLiteral) {
_computeTypes((XNumberLiteral)expression, state);
} else if (expression instanceof XNullLiteral) {
_computeTypes((XNullLiteral)expression, state);
} else if (expression instanceof XReturnExpression) {
_computeTypes((XReturnExpression)expression, state);
} else if (expression instanceof XStringLiteral) {
_computeTypes((XStringLiteral)expression, state);
} else if (expression instanceof XSwitchExpression) {
_computeTypes((XSwitchExpression)expression, state);
} else if (expression instanceof XThrowExpression) {
_computeTypes((XThrowExpression)expression, state);
} else if (expression instanceof XTryCatchFinallyExpression) {
_computeTypes((XTryCatchFinallyExpression)expression, state);
} else if (expression instanceof XTypeLiteral) {
_computeTypes((XTypeLiteral)expression, state);
} else if (expression instanceof XVariableDeclaration) {
_computeTypes((XVariableDeclaration)expression, state);
} else if (expression instanceof XListLiteral) {
_computeTypes((XListLiteral)expression, state);
} else if (expression instanceof XSetLiteral) {
_computeTypes((XSetLiteral)expression, state);
} else if (expression instanceof XSynchronizedExpression) {
_computeTypes((XSynchronizedExpression)expression, state);
} else {
throw new UnsupportedOperationException("Missing type computation for expression type: " + expression.eClass().getName() + " / " + state);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:57,代码来源:XbaseTypeComputer.java
示例7: _computeTypes
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
protected void _computeTypes(XSetLiteral literal, ITypeComputationState state) {
collectionLiterals.computeType(literal, state);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:4,代码来源:XbaseTypeComputer.java
示例8: _toJavaStatement
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
/**
* @param isReferenced unused in this context but necessary for dispatch signature
*/
protected void _toJavaStatement(final XSetLiteral literal, ITreeAppendable b, boolean isReferenced) {
for(XExpression element: literal.getElements())
internalToJavaStatement(element, b, true);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:8,代码来源:XbaseCompiler.java
示例9: doInternalToJavaStatement
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
@Override
protected void doInternalToJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced) {
if (obj instanceof XBlockExpression) {
_toJavaStatement((XBlockExpression) obj, appendable, isReferenced);
} else if (obj instanceof XCastedExpression) {
_toJavaStatement((XCastedExpression) obj, appendable, isReferenced);
} else if (obj instanceof XClosure) {
_toJavaStatement((XClosure) obj, appendable, isReferenced);
} else if (obj instanceof XConstructorCall) {
_toJavaStatement((XConstructorCall) obj, appendable, isReferenced);
} else if (obj instanceof XDoWhileExpression) {
_toJavaStatement((XDoWhileExpression) obj, appendable, isReferenced);
} else if (obj instanceof XForLoopExpression) {
_toJavaStatement((XForLoopExpression) obj, appendable, isReferenced);
} else if (obj instanceof XBasicForLoopExpression) {
_toJavaStatement((XBasicForLoopExpression) obj, appendable, isReferenced);
} else if (obj instanceof XIfExpression) {
_toJavaStatement((XIfExpression) obj, appendable, isReferenced);
} else if (obj instanceof XInstanceOfExpression) {
_toJavaStatement((XInstanceOfExpression) obj, appendable, isReferenced);
} else if (obj instanceof XReturnExpression) {
_toJavaStatement((XReturnExpression) obj, appendable, isReferenced);
} else if (obj instanceof XSwitchExpression) {
_toJavaStatement((XSwitchExpression) obj, appendable, isReferenced);
} else if (obj instanceof XThrowExpression) {
_toJavaStatement((XThrowExpression) obj, appendable, isReferenced);
} else if (obj instanceof XTryCatchFinallyExpression) {
_toJavaStatement((XTryCatchFinallyExpression) obj, appendable, isReferenced);
} else if (obj instanceof XVariableDeclaration) {
_toJavaStatement((XVariableDeclaration) obj, appendable, isReferenced);
} else if (obj instanceof XWhileExpression) {
_toJavaStatement((XWhileExpression) obj, appendable, isReferenced);
} else if (obj instanceof XListLiteral) {
_toJavaStatement((XListLiteral) obj, appendable, isReferenced);
} else if (obj instanceof XSetLiteral) {
_toJavaStatement((XSetLiteral) obj, appendable, isReferenced);
} else if (obj instanceof XSynchronizedExpression) {
_toJavaStatement((XSynchronizedExpression) obj, appendable, isReferenced);
} else {
super.doInternalToJavaStatement(obj, appendable, isReferenced);
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:43,代码来源:XbaseCompiler.java
示例10: isVariableDeclarationRequired
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
@Override
protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) {
if (expr instanceof XAnnotation) {
return false;
}
if (expr instanceof XListLiteral) {
return false;
}
if (expr instanceof XSetLiteral) {
return false;
}
if (expr instanceof XCastedExpression) {
return false;
}
if (expr instanceof XInstanceOfExpression) {
return false;
}
if (expr instanceof XMemberFeatureCall && isVariableDeclarationRequired((XMemberFeatureCall) expr, b))
return true;
EObject container = expr.eContainer();
if ((container instanceof XVariableDeclaration)
|| (container instanceof XReturnExpression)
|| (container instanceof XThrowExpression)) {
return false;
}
if (container instanceof XIfExpression) {
XIfExpression ifExpression = (XIfExpression) container;
if (ifExpression.getThen() == expr || ifExpression.getElse() == expr) {
return false;
}
}
if (container instanceof XCasePart) {
XCasePart casePart = (XCasePart) container;
if (casePart.getThen() == expr) {
return false;
}
}
if (container instanceof XSwitchExpression) {
XSwitchExpression switchExpression = (XSwitchExpression) container;
if (switchExpression.getDefault() == expr) {
return false;
}
}
if (container instanceof XBlockExpression) {
List<XExpression> siblings = ((XBlockExpression) container).getExpressions();
if (siblings.get(siblings.size() - 1) == expr) {
return isVariableDeclarationRequired(getFeatureCall(expr), expr, b);
}
}
if (container instanceof XClosure) {
if (((XClosure) container).getExpression() == expr) {
return false;
}
}
if (expr instanceof XAssignment) {
XAssignment a = (XAssignment) expr;
for (XExpression arg : getActualArguments(a)) {
if (isVariableDeclarationRequired(arg, b, recursive)) {
return true;
}
}
}
return super.isVariableDeclarationRequired(expr, b, recursive);
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:65,代码来源:XbaseCompiler.java
示例11: doEvaluate
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
/**
* don't call this directly. Always call evaluate() internalEvaluate()
*/
protected Object doEvaluate(XExpression expression, IEvaluationContext context, CancelIndicator indicator) {
if (expression instanceof XAssignment) {
return _doEvaluate((XAssignment)expression, context, indicator);
} else if (expression instanceof XDoWhileExpression) {
return _doEvaluate((XDoWhileExpression)expression, context, indicator);
} else if (expression instanceof XMemberFeatureCall) {
return _doEvaluate((XMemberFeatureCall)expression, context, indicator);
} else if (expression instanceof XWhileExpression) {
return _doEvaluate((XWhileExpression)expression, context, indicator);
} else if (expression instanceof XFeatureCall) {
return _doEvaluate((XFeatureCall)expression, context, indicator);
} else if (expression instanceof XAbstractFeatureCall) {
return _doEvaluate((XAbstractFeatureCall)expression, context, indicator);
} else if (expression instanceof XBlockExpression) {
return _doEvaluate((XBlockExpression)expression, context, indicator);
} else if (expression instanceof XSynchronizedExpression) {
return _doEvaluate((XSynchronizedExpression)expression, context, indicator);
} else if (expression instanceof XBooleanLiteral) {
return _doEvaluate((XBooleanLiteral)expression, context, indicator);
} else if (expression instanceof XCastedExpression) {
return _doEvaluate((XCastedExpression)expression, context, indicator);
} else if (expression instanceof XClosure) {
return _doEvaluate((XClosure)expression, context, indicator);
} else if (expression instanceof XConstructorCall) {
return _doEvaluate((XConstructorCall)expression, context, indicator);
} else if (expression instanceof XForLoopExpression) {
return _doEvaluate((XForLoopExpression)expression, context, indicator);
} else if (expression instanceof XBasicForLoopExpression) {
return _doEvaluate((XBasicForLoopExpression)expression, context, indicator);
} else if (expression instanceof XIfExpression) {
return _doEvaluate((XIfExpression)expression, context, indicator);
} else if (expression instanceof XInstanceOfExpression) {
return _doEvaluate((XInstanceOfExpression)expression, context, indicator);
} else if (expression instanceof XNullLiteral) {
return _doEvaluate((XNullLiteral)expression, context, indicator);
} else if (expression instanceof XNumberLiteral) {
return _doEvaluate((XNumberLiteral)expression, context, indicator);
} else if (expression instanceof XReturnExpression) {
return _doEvaluate((XReturnExpression)expression, context, indicator);
} else if (expression instanceof XStringLiteral) {
return _doEvaluate((XStringLiteral)expression, context, indicator);
} else if (expression instanceof XSwitchExpression) {
return _doEvaluate((XSwitchExpression)expression, context, indicator);
} else if (expression instanceof XThrowExpression) {
return _doEvaluate((XThrowExpression)expression, context, indicator);
} else if (expression instanceof XTryCatchFinallyExpression) {
return _doEvaluate((XTryCatchFinallyExpression)expression, context, indicator);
} else if (expression instanceof XTypeLiteral) {
return _doEvaluate((XTypeLiteral)expression, context, indicator);
} else if (expression instanceof XVariableDeclaration) {
return _doEvaluate((XVariableDeclaration)expression, context, indicator);
} else if (expression instanceof XListLiteral) {
return _doEvaluate((XListLiteral)expression, context, indicator);
} else if (expression instanceof XSetLiteral) {
return _doEvaluate((XSetLiteral)expression, context, indicator);
} else {
throw new IllegalArgumentException("Unhandled parameter types: " +
Arrays.<Object>asList(expression, context, indicator).toString());
}
}
开发者ID:eclipse,项目名称:xtext-extras,代码行数:64,代码来源:XbaseInterpreter.java
示例12: sequence_XSetLiteral
import org.eclipse.xtext.xbase.XSetLiteral; //导入依赖的package包/类
/**
* Constraint:
* ((elements+=XExpression elements+=XExpression*)?)
*/
protected void sequence_XSetLiteral(EObject context, XSetLiteral semanticObject) {
genericSequencer.createSequence(context, semanticObject);
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:8,代码来源:AbstractCheckSemanticSequencer.java
注:本文中的org.eclipse.xtext.xbase.XSetLiteral类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论