Search in sources :

Example 6 with ConstantExpressionEvaluationException

use of org.eclipse.xtext.xbase.interpreter.ConstantExpressionEvaluationException in project xtext-xtend by eclipse.

the class JvmAnnotationReferenceImpl method getValue.

@Override
public Object getValue(final String property) {
    try {
        final JvmOperation op = this.findOperation(property);
        final Function1<JvmAnnotationValue, Boolean> _function = (JvmAnnotationValue it) -> {
            return Boolean.valueOf((Objects.equal(it.getOperation(), op) || ((it.getOperation() == null) && Objects.equal(op.getSimpleName(), "value"))));
        };
        final JvmAnnotationValue annotationValue = IterableExtensions.<JvmAnnotationValue>findFirst(this.getDelegate().getValues(), _function);
        final boolean isArrayType = ((op != null) && this.getCompilationUnit().getTypeReferences().isArray(op.getReturnType()));
        if ((annotationValue != null)) {
            return this.getCompilationUnit().translateAnnotationValue(annotationValue, isArrayType);
        }
    } catch (final Throwable _t) {
        if (_t instanceof ConstantExpressionEvaluationException) {
            final ConstantExpressionEvaluationException e = (ConstantExpressionEvaluationException) _t;
            this.getCompilationUnit().getProblemSupport().addError(this, e.getMessage());
        } else {
            throw Exceptions.sneakyThrow(_t);
        }
    }
    return null;
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) ConstantExpressionEvaluationException(org.eclipse.xtext.xbase.interpreter.ConstantExpressionEvaluationException) JvmAnnotationValue(org.eclipse.xtext.common.types.JvmAnnotationValue)

Aggregations

ConstantExpressionEvaluationException (org.eclipse.xtext.xbase.interpreter.ConstantExpressionEvaluationException)6 XtendField (org.eclipse.xtend.core.xtend.XtendField)2 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)2 XExpression (org.eclipse.xtext.xbase.XExpression)2 StackedConstantExpressionEvaluationException (org.eclipse.xtext.xbase.interpreter.StackedConstantExpressionEvaluationException)2 Test (org.junit.Test)2 EObject (org.eclipse.emf.ecore.EObject)1 InternalEObject (org.eclipse.emf.ecore.InternalEObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)1 JvmAnnotationValue (org.eclipse.xtext.common.types.JvmAnnotationValue)1 JvmEnumerationLiteral (org.eclipse.xtext.common.types.JvmEnumerationLiteral)1 JvmEnumerationType (org.eclipse.xtext.common.types.JvmEnumerationType)1 JvmField (org.eclipse.xtext.common.types.JvmField)1 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)1 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)1 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)1 JvmType (org.eclipse.xtext.common.types.JvmType)1