org.eclipse.xtext.xbase.XTypeLiteral Java Examples
The following examples show how to use
org.eclipse.xtext.xbase.XTypeLiteral.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractConstantExpressionsInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public Object internalEvaluate(final XExpression it, final Context ctx) { if (it instanceof XBinaryOperation) { return _internalEvaluate((XBinaryOperation)it, ctx); } else if (it instanceof XUnaryOperation) { return _internalEvaluate((XUnaryOperation)it, ctx); } else if (it instanceof XBooleanLiteral) { return _internalEvaluate((XBooleanLiteral)it, ctx); } else if (it instanceof XCastedExpression) { return _internalEvaluate((XCastedExpression)it, ctx); } else if (it instanceof XStringLiteral) { return _internalEvaluate((XStringLiteral)it, ctx); } else if (it instanceof XTypeLiteral) { return _internalEvaluate((XTypeLiteral)it, ctx); } else if (it instanceof XAnnotation) { return _internalEvaluate((XAnnotation)it, ctx); } else if (it != null) { return _internalEvaluate(it, ctx); } else if (it == null) { return _internalEvaluate((Void)null, ctx); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, ctx).toString()); } }
Example #2
Source File: ResolvedFeaturesTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public ResolvedFeatures toResolvedOperations(final Class<?> type) { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("typeof("); String _canonicalName = type.getCanonicalName(); _builder.append(_canonicalName); _builder.append(")"); XExpression _expression = this.expression(_builder); final XTypeLiteral typeLiteral = ((XTypeLiteral) _expression); JvmType _type = typeLiteral.getType(); final ResolvedFeatures result = this.overrideHelper.getResolvedFeatures(((JvmDeclaredType) _type)); return result; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
Example #3
Source File: XbaseTypeComputer.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void _computeTypes(XTypeLiteral object, ITypeComputationState state) { JvmType type = object.getType(); if (type == null) { return; } checkTypeParameterNotAllowedAsLiteral(object, type, state); ITypeReferenceOwner owner = state.getReferenceOwner(); LightweightTypeReference clazz = owner.newParameterizedTypeReference(type); for (int i = 0; i < object.getArrayDimensions().size(); i++) { clazz = owner.newArrayTypeReference(clazz); } if (object.getArrayDimensions().isEmpty()) { if (clazz.isPrimitiveVoid()) { clazz = state.getReferenceOwner().newReferenceTo(Void.class); } else { clazz = clazz.getWrapperTypeIfPrimitive(); } } LightweightTypeReference result = owner.newReferenceTo(Class.class); if (result instanceof ParameterizedTypeReference) { ParameterizedTypeReference parameterizedTypeReference = (ParameterizedTypeReference) result; parameterizedTypeReference.addTypeArgument(clazz); } state.acceptActualType(result); }
Example #4
Source File: LiteralsCompiler.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override protected void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) { if (obj instanceof XStringLiteral) { _toJavaExpression((XStringLiteral) obj, appendable); } else if (obj instanceof XNumberLiteral) { _toJavaExpression((XNumberLiteral) obj, appendable); } else if (obj instanceof XNullLiteral) { _toJavaExpression((XNullLiteral) obj, appendable); } else if (obj instanceof XBooleanLiteral) { _toJavaExpression((XBooleanLiteral) obj, appendable); } else if (obj instanceof XTypeLiteral) { _toJavaExpression((XTypeLiteral) obj, appendable); } else { super.internalToConvertedExpression(obj, appendable); } }
Example #5
Source File: LiteralsCompiler.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override protected void doInternalToJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced) { if (obj instanceof XStringLiteral) { _toJavaStatement((XStringLiteral) obj, appendable, isReferenced); } else if (obj instanceof XNumberLiteral) { _toJavaStatement((XNumberLiteral) obj, appendable, isReferenced); } else if (obj instanceof XNullLiteral) { _toJavaStatement((XNullLiteral) obj, appendable, isReferenced); } else if (obj instanceof XBooleanLiteral) { _toJavaStatement((XBooleanLiteral) obj, appendable, isReferenced); } else if (obj instanceof XTypeLiteral) { _toJavaStatement((XTypeLiteral) obj, appendable, isReferenced); } else { super.doInternalToJavaStatement(obj, appendable, isReferenced); } }
Example #6
Source File: ConstantExpressionValidator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public boolean isConstant(final XExpression expression) { if (expression instanceof XAbstractFeatureCall) { return _isConstant((XAbstractFeatureCall)expression); } else if (expression instanceof XBooleanLiteral) { return _isConstant((XBooleanLiteral)expression); } else if (expression instanceof XCastedExpression) { return _isConstant((XCastedExpression)expression); } else if (expression instanceof XNumberLiteral) { return _isConstant((XNumberLiteral)expression); } else if (expression instanceof XStringLiteral) { return _isConstant((XStringLiteral)expression); } else if (expression instanceof XTypeLiteral) { return _isConstant((XTypeLiteral)expression); } else if (expression != null) { return _isConstant(expression); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(expression).toString()); } }
Example #7
Source File: UIStringsTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testReferenceToString_1() throws Exception { XExpression expr = expression("typeof(String)", true); assertTrue(expr instanceof XTypeLiteral); XTypeLiteral operator = (XTypeLiteral) expr; JvmType type = operator.getType(); JvmTypeReference reference = this.typeReferences.createTypeRef(type); assertEquals("String", this.uiStrings.referenceToString(reference, "the-default-value")); }
Example #8
Source File: UIStringsTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testReferenceToString_0() throws Exception { XExpression expr = expression("typeof(foo.String)", true); assertTrue(expr instanceof XTypeLiteral); XTypeLiteral operator = (XTypeLiteral) expr; JvmType type = operator.getType(); JvmTypeReference reference = this.typeReferences.createTypeRef(type); assertEquals("String", this.uiStrings.referenceToString(reference, "the-default-value")); }
Example #9
Source File: ErrorTreeAppendableTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Test public void testAppendUnresolvedType() throws Exception { XTypeLiteral e = ((XTypeLiteral) expression("typeof( \tUnresolved\n)")); ErrorTreeAppendable app = createErrorTreeAppendable(e); app.append(e.getType()); Assert.assertEquals("Unresolved", app.getContent()); }
Example #10
Source File: JvmAnnotationReferencePrinter.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected String internalToString(Object obj) { if (obj instanceof XBinaryOperation) { return _internalToString((XBinaryOperation) obj); } else if (obj instanceof XFeatureCall) { return _internalToString((XFeatureCall) obj); } else if (obj instanceof XListLiteral) { return _internalToString((XListLiteral) obj); } else if (obj instanceof XMemberFeatureCall) { return _internalToString((XMemberFeatureCall) obj); } else if (obj instanceof XBooleanLiteral) { return _internalToString((XBooleanLiteral) obj); } else if (obj instanceof XNumberLiteral) { return _internalToString((XNumberLiteral) obj); } else if (obj instanceof XStringLiteral) { return _internalToString((XStringLiteral) obj); } else if (obj instanceof XTypeLiteral) { return _internalToString((XTypeLiteral) obj); } else if (obj instanceof XAnnotation) { return _internalToString((XAnnotation) obj); } else if (obj instanceof JvmAnnotationReference) { return _internalToString((JvmAnnotationReference) obj); } else if (obj instanceof JvmAnnotationValue) { return _internalToString((JvmAnnotationValue) obj); } else { return _internalToString(obj); } }
Example #11
Source File: ImportsCollector.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public void visit(final EObject jvmType, final INode originNode, final ImportsAcceptor acceptor) { if (jvmType instanceof JvmGenericType) { _visit((JvmGenericType)jvmType, originNode, acceptor); return; } else if (jvmType instanceof JvmDeclaredType) { _visit((JvmDeclaredType)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XFeatureCall) { _visit((XFeatureCall)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XMemberFeatureCall) { _visit((XMemberFeatureCall)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XAbstractFeatureCall) { _visit((XAbstractFeatureCall)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XConstructorCall) { _visit((XConstructorCall)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XTypeLiteral) { _visit((XTypeLiteral)jvmType, originNode, acceptor); return; } else if (jvmType instanceof XAnnotation) { _visit((XAnnotation)jvmType, originNode, acceptor); return; } else if (jvmType instanceof JvmTypeReference) { _visit((JvmTypeReference)jvmType, originNode, acceptor); return; } else if (jvmType != null) { _visit(jvmType, originNode, acceptor); return; } else if (jvmType == null) { _visit((Void)null, originNode, acceptor); return; } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(jvmType, originNode, acceptor).toString()); } }
Example #12
Source File: XbaseInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * @param context unused in this context but required for dispatching * @param indicator unused in this context but required for dispatching */ protected Object _doEvaluate(XTypeLiteral literal, IEvaluationContext context, CancelIndicator indicator) { if (literal.getType() == null || literal.getType().eIsProxy()) { List<INode> nodesForFeature = NodeModelUtils.findNodesForFeature(literal, XbasePackage.Literals.XTYPE_LITERAL__TYPE); // TODO cleanup if (nodesForFeature.isEmpty()) throw new EvaluationException(new ClassNotFoundException()); throw new EvaluationException(new ClassNotFoundException(nodesForFeature.get(0).getText())); } JvmType type = literal.getType(); Object result = translateJvmTypeToResult(type, literal.getArrayDimensions().size()); return result; }
Example #13
Source File: ConstantConditionsInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public EvaluationResult internalEvaluate(final XExpression it, final EvaluationContext context) { if (it instanceof XBinaryOperation) { return _internalEvaluate((XBinaryOperation)it, context); } else if (it instanceof XUnaryOperation) { return _internalEvaluate((XUnaryOperation)it, context); } else if (it instanceof XAbstractFeatureCall) { return _internalEvaluate((XAbstractFeatureCall)it, context); } else if (it instanceof XBooleanLiteral) { return _internalEvaluate((XBooleanLiteral)it, context); } else if (it instanceof XCastedExpression) { return _internalEvaluate((XCastedExpression)it, context); } else if (it instanceof XNullLiteral) { return _internalEvaluate((XNullLiteral)it, context); } else if (it instanceof XNumberLiteral) { return _internalEvaluate((XNumberLiteral)it, context); } else if (it instanceof XStringLiteral) { return _internalEvaluate((XStringLiteral)it, context); } else if (it instanceof XTypeLiteral) { return _internalEvaluate((XTypeLiteral)it, context); } else if (it != null) { return _internalEvaluate(it, context); } else if (it == null) { return _internalEvaluate((Void)null, context); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, context).toString()); } }
Example #14
Source File: LiteralsCompiler.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Override protected boolean isVariableDeclarationRequired(XExpression expr, ITreeAppendable b, boolean recursive) { if (expr instanceof XBooleanLiteral || expr instanceof XStringLiteral || expr instanceof XNumberLiteral || expr instanceof XTypeLiteral || expr instanceof XClosure || expr instanceof XNullLiteral) return false; return super.isVariableDeclarationRequired(expr,b, recursive); }
Example #15
Source File: ConstantExpressionsInterpreter.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public Object internalEvaluate(final XExpression it, final Context ctx) { if (it instanceof XBinaryOperation) { return _internalEvaluate((XBinaryOperation)it, ctx); } else if (it instanceof XFeatureCall) { return _internalEvaluate((XFeatureCall)it, ctx); } else if (it instanceof XListLiteral) { return _internalEvaluate((XListLiteral)it, ctx); } else if (it instanceof XMemberFeatureCall) { return _internalEvaluate((XMemberFeatureCall)it, ctx); } else if (it instanceof XUnaryOperation) { return _internalEvaluate((XUnaryOperation)it, ctx); } else if (it instanceof XBooleanLiteral) { return _internalEvaluate((XBooleanLiteral)it, ctx); } else if (it instanceof XCastedExpression) { return _internalEvaluate((XCastedExpression)it, ctx); } else if (it instanceof XNumberLiteral) { return _internalEvaluate((XNumberLiteral)it, ctx); } else if (it instanceof XStringLiteral) { return _internalEvaluate((XStringLiteral)it, ctx); } else if (it instanceof XTypeLiteral) { return _internalEvaluate((XTypeLiteral)it, ctx); } else if (it instanceof XAnnotation) { return _internalEvaluate((XAnnotation)it, ctx); } else if (it != null) { return _internalEvaluate(it, ctx); } else if (it == null) { return _internalEvaluate((Void)null, ctx); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, ctx).toString()); } }
Example #16
Source File: ShouldExtensions.java From sarl with Apache License 2.0 | 5 votes |
/** Ensure that the given type literal is equal to the given type. * * @param actual the type literal to test. * @param expected the name of the expected type. * @return the validation status */ public static boolean shouldBe(XTypeLiteral actual, Object expected) { if (actual == null) { return false; } final String fqn; if (expected instanceof Class) { fqn = ((Class<?>) expected).getName(); } else { fqn = expected.toString(); } return actual.getType() != null && Objects.equals(fqn, actual.getType().getQualifiedName()); }
Example #17
Source File: XExpressionHelper.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * @return whether the expression itself (not its children) possibly causes a side-effect */ public boolean hasSideEffects(XExpression expr) { if (expr instanceof XClosure || expr instanceof XStringLiteral || expr instanceof XTypeLiteral || expr instanceof XBooleanLiteral || expr instanceof XNumberLiteral || expr instanceof XNullLiteral || expr instanceof XAnnotation ) return false; if(expr instanceof XCollectionLiteral) { for(XExpression element: ((XCollectionLiteral)expr).getElements()) { if(hasSideEffects(element)) return true; } return false; } if (expr instanceof XAbstractFeatureCall) { XAbstractFeatureCall featureCall = (XAbstractFeatureCall) expr; return hasSideEffects(featureCall, true); } if (expr instanceof XConstructorCall) { XConstructorCall constrCall = (XConstructorCall) expr; return findPureAnnotation(constrCall.getConstructor()) == null; } return true; }
Example #18
Source File: SwitchConstantExpressionsInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public Object internalEvaluate(final XExpression it, final Context ctx) { if (it instanceof XBinaryOperation) { return _internalEvaluate((XBinaryOperation)it, ctx); } else if (it instanceof XUnaryOperation) { return _internalEvaluate((XUnaryOperation)it, ctx); } else if (it instanceof XAbstractFeatureCall) { return _internalEvaluate((XAbstractFeatureCall)it, ctx); } else if (it instanceof XBooleanLiteral) { return _internalEvaluate((XBooleanLiteral)it, ctx); } else if (it instanceof XCastedExpression) { return _internalEvaluate((XCastedExpression)it, ctx); } else if (it instanceof XNumberLiteral) { return _internalEvaluate((XNumberLiteral)it, ctx); } else if (it instanceof XStringLiteral) { return _internalEvaluate((XStringLiteral)it, ctx); } else if (it instanceof XTypeLiteral) { return _internalEvaluate((XTypeLiteral)it, ctx); } else if (it instanceof XAnnotation) { return _internalEvaluate((XAnnotation)it, ctx); } else if (it != null) { return _internalEvaluate(it, ctx); } else if (it == null) { return _internalEvaluate((Void)null, ctx); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(it, ctx).toString()); } }
Example #19
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Check public void checkDeprecated(XTypeLiteral expression) { if (!isIgnored(DEPRECATED_MEMBER_REFERENCE)) { JvmType jvmType = expression.getType(); checkDeprecated( jvmType, expression, XbasePackage.Literals.XTYPE_LITERAL__TYPE); } }
Example #20
Source File: ImportsCollector.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected void _visit(final XTypeLiteral semanticElement, final INode originNode, final ImportsAcceptor acceptor) { final List<INode> elementNode = NodeModelUtils.findNodesForFeature(semanticElement, XbasePackage.Literals.XTYPE_LITERAL__TYPE); this.visit(semanticElement.getType(), IterableExtensions.<INode>head(elementNode), acceptor); }
Example #21
Source File: JvmAnnotationReferencePrinter.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
protected String _internalToString(XTypeLiteral typeLiteral) { String text = createLinkWithLabel(XtextElementLinks.XTEXTDOC_SCHEME, EcoreUtil.getURI(typeLiteral.getType()), typeLiteral.getType().getSimpleName()); return text + String.join("", typeLiteral.getArrayDimensions()); }
Example #22
Source File: XbaseParserTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Test public void testTypeLiteral() throws Exception { XTypeLiteral expression = (XTypeLiteral) expression("typeof(String)"); doTestTypeLiteral(expression); }
Example #23
Source File: XbaseParserTest.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected void doTestTypeLiteral(XTypeLiteral expression) { assertEquals("java.lang.String",expression.getType().getIdentifier()); }
Example #24
Source File: AbstractXbaseSemanticSequencer.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Deprecated protected void sequence_XTypeLiteral(EObject context, XTypeLiteral semanticObject) { sequence_XTypeLiteral(createContext(context, semanticObject), semanticObject); }
Example #25
Source File: XtendImplicitReturnFinder.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public void findImplicitReturns(final XExpression expression, final ImplicitReturnFinder.Acceptor acceptor) { if (expression instanceof AnonymousClass) { _findImplicitReturns((AnonymousClass)expression, acceptor); return; } else if (expression instanceof RichString) { _findImplicitReturns((RichString)expression, acceptor); return; } else if (expression instanceof XAbstractFeatureCall) { _findImplicitReturns((XAbstractFeatureCall)expression, acceptor); return; } else if (expression instanceof XBlockExpression) { _findImplicitReturns((XBlockExpression)expression, acceptor); return; } else if (expression instanceof XBooleanLiteral) { _findImplicitReturns((XBooleanLiteral)expression, acceptor); return; } else if (expression instanceof XCastedExpression) { _findImplicitReturns((XCastedExpression)expression, acceptor); return; } else if (expression instanceof XClosure) { _findImplicitReturns((XClosure)expression, acceptor); return; } else if (expression instanceof XCollectionLiteral) { _findImplicitReturns((XCollectionLiteral)expression, acceptor); return; } else if (expression instanceof XConstructorCall) { _findImplicitReturns((XConstructorCall)expression, acceptor); return; } else if (expression instanceof XIfExpression) { _findImplicitReturns((XIfExpression)expression, acceptor); return; } else if (expression instanceof XInstanceOfExpression) { _findImplicitReturns((XInstanceOfExpression)expression, acceptor); return; } else if (expression instanceof XNullLiteral) { _findImplicitReturns((XNullLiteral)expression, acceptor); return; } else if (expression instanceof XNumberLiteral) { _findImplicitReturns((XNumberLiteral)expression, acceptor); return; } else if (expression instanceof XStringLiteral) { _findImplicitReturns((XStringLiteral)expression, acceptor); return; } else if (expression instanceof XSwitchExpression) { _findImplicitReturns((XSwitchExpression)expression, acceptor); return; } else if (expression instanceof XSynchronizedExpression) { _findImplicitReturns((XSynchronizedExpression)expression, acceptor); return; } else if (expression instanceof XTryCatchFinallyExpression) { _findImplicitReturns((XTryCatchFinallyExpression)expression, acceptor); return; } else if (expression instanceof XTypeLiteral) { _findImplicitReturns((XTypeLiteral)expression, acceptor); return; } else if (expression != null) { _findImplicitReturns(expression, acceptor); return; } else if (expression == null) { _findImplicitReturns((Void)null, acceptor); return; } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.<Object>asList(expression, acceptor).toString()); } }
Example #26
Source File: ShouldExtensions.java From sarl with Apache License 2.0 | 4 votes |
/** Ensure that the given type literal is equal to the given type. * * @param actual the type literal to test. * @param expected the name of the expected type. * @return the validation status */ @SuppressWarnings({"checkstyle:returncount", "checkstyle:npathcomplexity"}) public static boolean shouldBeLiteral(XExpression actual, Object expected) { if (actual instanceof XNumberLiteral) { return shouldBe((XNumberLiteral) actual, expected); } if (actual instanceof XBooleanLiteral) { return shouldBe((XBooleanLiteral) actual, expected); } if (actual instanceof XStringLiteral) { return shouldBe((XStringLiteral) actual, expected); } if (actual instanceof XTypeLiteral) { return shouldBe((XTypeLiteral) actual, expected); } if (actual instanceof XNullLiteral) { return Objects.equals("null", expected); //$NON-NLS-1$ } if (actual instanceof XCollectionLiteral) { return shouldBe((XCollectionLiteral) actual, expected); } if (actual instanceof XBinaryOperation) { final XBinaryOperation op = (XBinaryOperation) actual; if ("operator_mappedTo".equals(op.getFeature().getSimpleName())) { //$NON-NLS-1$ final Object key; final Object value; if (expected instanceof Pair<?, ?>) { key = ((Pair<?, ?>) expected).getKey(); value = ((Pair<?, ?>) expected).getValue(); } else if (expected instanceof Entry<?, ?>) { key = ((Entry<?, ?>) expected).getKey(); value = ((Entry<?, ?>) expected).getValue(); } else { return false; } return shouldBeLiteral(op.getLeftOperand(), key) && shouldBeLiteral(op.getRightOperand(), value); } } return false; }
Example #27
Source File: SarlCompiler.java From sarl with Apache License 2.0 | 4 votes |
@SuppressWarnings({"checkstyle:returncount", "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity"}) private static String getAnnotationStringValue(JvmAnnotationValue value) { if (value instanceof JvmAnnotationAnnotationValue) { return ((JvmAnnotationAnnotationValue) value).getValues().get(0).getAnnotation().getIdentifier(); } if (value instanceof JvmBooleanAnnotationValue) { return ((JvmBooleanAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmByteAnnotationValue) { return ((JvmByteAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmCharAnnotationValue) { return ((JvmCharAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmCustomAnnotationValue) { final EObject evalue = ((JvmCustomAnnotationValue) value).getValues().get(0); if (evalue instanceof XStringLiteral) { return ((XStringLiteral) evalue).getValue(); } if (evalue instanceof XNumberLiteral) { return ((XNumberLiteral) evalue).getValue(); } if (evalue instanceof XBooleanLiteral) { return ((XNumberLiteral) evalue).getValue(); } if (evalue instanceof XTypeLiteral) { return ((XTypeLiteral) evalue).getType().getIdentifier(); } } if (value instanceof JvmDoubleAnnotationValue) { return ((JvmDoubleAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmEnumAnnotationValue) { return ((JvmEnumAnnotationValue) value).getValues().get(0).getSimpleName(); } if (value instanceof JvmFloatAnnotationValue) { return ((JvmFloatAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmIntAnnotationValue) { return ((JvmIntAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmLongAnnotationValue) { return ((JvmLongAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmShortAnnotationValue) { return ((JvmShortAnnotationValue) value).getValues().get(0).toString(); } if (value instanceof JvmStringAnnotationValue) { return ((JvmStringAnnotationValue) value).getValues().get(0); } if (value instanceof JvmTypeAnnotationValue) { return ((JvmTypeAnnotationValue) value).getValues().get(0).getIdentifier(); } return null; }
Example #28
Source File: SarlCompiler.java From sarl with Apache License 2.0 | 4 votes |
private static boolean isLiteral(XExpression expr) { return expr instanceof XBooleanLiteral || expr instanceof XStringLiteral || expr instanceof XNumberLiteral || expr instanceof XCollectionLiteral || expr instanceof XSetLiteral || expr instanceof XNullLiteral || expr instanceof XTypeLiteral; }
Example #29
Source File: ConstantConditionsInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected EvaluationResult _internalEvaluate(final XTypeLiteral it, final EvaluationContext context) { return new EvaluationResult(it, false); }
Example #30
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
@Check public void checkTypeLiteral(XTypeLiteral typeLiteral) { if (!typeLiteral.getArrayDimensions().isEmpty() && typeLiteral.getType().getIdentifier().equals("void")) { error("'void"+Joiner.on("").join(typeLiteral.getArrayDimensions()) +"' is not a valid type", null, INVALID_TYPE); } }