Search in sources :

Example 21 with XAnnotation

use of org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation in project xtext-xtend by eclipse.

the class CompilationUnitImpl method translate.

protected Object translate(final Object object) {
    if ((object instanceof XAnnotation[])) {
        final AnnotationReference[] result = new AnnotationReference[((Object[]) object).length];
        int _length = ((Object[]) object).length;
        ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, _length, true);
        for (final Integer i : _doubleDotLessThan) {
            result[(i).intValue()] = this.translateAnnotation(((XAnnotation[]) object)[(i).intValue()]);
        }
        return result;
    }
    if ((object instanceof XAnnotation)) {
        return this.translateAnnotation(((XAnnotation) object));
    }
    if ((object instanceof JvmTypeReference[])) {
        final TypeReference[] result_1 = new TypeReference[((Object[]) object).length];
        int _length_1 = ((Object[]) object).length;
        ExclusiveRange _doubleDotLessThan_1 = new ExclusiveRange(0, _length_1, true);
        for (final Integer i_1 : _doubleDotLessThan_1) {
            Object _translate = this.translate(((Object[]) object)[(i_1).intValue()]);
            result_1[(i_1).intValue()] = ((TypeReference) _translate);
        }
        return result_1;
    }
    if ((object instanceof JvmTypeReference)) {
        return this.toTypeReference(((JvmTypeReference) object));
    }
    if ((object instanceof JvmEnumerationLiteral[])) {
        final EnumerationValueDeclaration[] result_2 = new EnumerationValueDeclaration[((Object[]) object).length];
        int _length_2 = ((Object[]) object).length;
        ExclusiveRange _doubleDotLessThan_2 = new ExclusiveRange(0, _length_2, true);
        for (final Integer i_2 : _doubleDotLessThan_2) {
            Object _translate_1 = this.translate(((Object[]) object)[(i_2).intValue()]);
            result_2[(i_2).intValue()] = ((EnumerationValueDeclaration) _translate_1);
        }
        return result_2;
    }
    if ((object instanceof JvmEnumerationLiteral)) {
        return this.toMemberDeclaration(((JvmMember) object));
    }
    return object;
}
Also used : ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation) JvmEnumerationLiteral(org.eclipse.xtext.common.types.JvmEnumerationLiteral) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference) AnnotationReference(org.eclipse.xtend.lib.macro.declaration.AnnotationReference) EObject(org.eclipse.emf.ecore.EObject) JvmMember(org.eclipse.xtext.common.types.JvmMember) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) TypeReference(org.eclipse.xtend.lib.macro.declaration.TypeReference) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) EnumerationValueDeclaration(org.eclipse.xtend.lib.macro.declaration.EnumerationValueDeclaration)

Example 22 with XAnnotation

use of org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation in project xtext-xtend by eclipse.

the class CompilationUnitImpl method handleProcessingError.

public void handleProcessingError(final Iterable<? extends EObject> sourceElements, final Resource resource, final Throwable t) {
    if ((t instanceof VirtualMachineError)) {
        throw ((VirtualMachineError) t);
    }
    boolean _equals = Objects.equal(this.lastPhase, ActiveAnnotationContexts.AnnotationCallback.GENERATION);
    if (_equals) {
        Throwables.propagateIfPossible(t);
        String _messageWithoutStackTrace = this.getMessageWithoutStackTrace(t);
        throw new RuntimeException(_messageWithoutStackTrace, t);
    }
    final String msg = this.getMessageWithStackTrace(t);
    final EList<Resource.Diagnostic> errors = resource.getErrors();
    for (final EObject target : sourceElements) {
        boolean _matched = false;
        if (target instanceof XtendAnnotationTarget) {
            _matched = true;
            final EList<XAnnotation> annotations = ((XtendAnnotationTarget) target).getAnnotations();
            EObject _xifexpression = null;
            boolean _isEmpty = annotations.isEmpty();
            if (_isEmpty) {
                _xifexpression = target;
            } else {
                _xifexpression = IterableExtensions.<XAnnotation>head(annotations);
            }
            EObjectDiagnosticImpl _eObjectDiagnosticImpl = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.PROCESSING_ERROR, msg, _xifexpression, null, (-1), null);
            errors.add(_eObjectDiagnosticImpl);
        }
        if (!_matched) {
            EObjectDiagnosticImpl _eObjectDiagnosticImpl = new EObjectDiagnosticImpl(Severity.ERROR, IssueCodes.PROCESSING_ERROR, msg, target, null, (-1), null);
            errors.add(_eObjectDiagnosticImpl);
        }
    }
}
Also used : XtendAnnotationTarget(org.eclipse.xtend.core.xtend.XtendAnnotationTarget) EObjectDiagnosticImpl(org.eclipse.xtext.validation.EObjectDiagnosticImpl) EObject(org.eclipse.emf.ecore.EObject) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation)

Example 23 with XAnnotation

use of org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation in project xtext-xtend by eclipse.

the class CompilationUnitImpl method toAnnotationReference.

public AnnotationReference toAnnotationReference(final XAnnotation delegate) {
    final Function1<XAnnotation, XtendAnnotationReferenceImpl> _function = (XAnnotation it) -> {
        XtendAnnotationReferenceImpl _xtendAnnotationReferenceImpl = new XtendAnnotationReferenceImpl();
        final Procedure1<XtendAnnotationReferenceImpl> _function_1 = (XtendAnnotationReferenceImpl it_1) -> {
            it_1.setDelegate(delegate);
            it_1.setCompilationUnit(this);
        };
        return ObjectExtensions.<XtendAnnotationReferenceImpl>operator_doubleArrow(_xtendAnnotationReferenceImpl, _function_1);
    };
    return this.<XAnnotation, XtendAnnotationReferenceImpl>getOrCreate(delegate, _function);
}
Also used : Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation) XtendAnnotationReferenceImpl(org.eclipse.xtend.core.macro.declaration.XtendAnnotationReferenceImpl)

Example 24 with XAnnotation

use of org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation in project xtext-xtend by eclipse.

the class XtendHighlightingCalculator method highlightAnnotations.

protected void highlightAnnotations(IHighlightedPositionAcceptor acceptor, XtendAnnotationTarget target) {
    if (target != null) {
        for (XAnnotation annotation : target.getAnnotations()) {
            highlightRichStrings(annotation, acceptor);
            highlightDeprecatedXtendAnnotationTarget(acceptor, target, annotation);
        }
    }
}
Also used : XAnnotation(org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation)

Aggregations

XAnnotation (org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation)24 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)13 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)13 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)12 Test (org.junit.Test)12 IResolvedTypes (org.eclipse.xtext.xbase.typesystem.IResolvedTypes)11 EObject (org.eclipse.emf.ecore.EObject)4 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)4 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)4 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)4 XtendAnnotationTarget (org.eclipse.xtend.core.xtend.XtendAnnotationTarget)3 JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)3 XtendField (org.eclipse.xtend.core.xtend.XtendField)2 XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)2 JvmAnnotationType (org.eclipse.xtext.common.types.JvmAnnotationType)2 JvmEnumerationLiteral (org.eclipse.xtext.common.types.JvmEnumerationLiteral)2 EObjectDiagnosticImpl (org.eclipse.xtext.validation.EObjectDiagnosticImpl)2 Pair (org.eclipse.xtext.xbase.lib.Pair)2 List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1