Java Code Examples for org.eclipse.xtext.common.types.JvmAnnotationReference#getAnnotation()
The following examples show how to use
org.eclipse.xtext.common.types.JvmAnnotationReference#getAnnotation() .
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: JvmModelGenerator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
/** * @deprecated Additional annotations should be created in the JVM model. */ @Deprecated public ITreeAppendable generateAnnotationsWithSyntheticSuppressWarnings(final JvmDeclaredType it, final ITreeAppendable appendable, final GeneratorConfig config) { ITreeAppendable _xblockexpression = null; { final Function1<JvmAnnotationReference, Boolean> _function = (JvmAnnotationReference it_1) -> { JvmAnnotationType _annotation = it_1.getAnnotation(); String _identifier = null; if (_annotation!=null) { _identifier=_annotation.getIdentifier(); } String _name = SuppressWarnings.class.getName(); return Boolean.valueOf((!Objects.equal(_identifier, _name))); }; final Function1<JvmAnnotationReference, Boolean> noSuppressWarningsFilter = _function; this.generateAnnotations(IterableExtensions.<JvmAnnotationReference>filter(it.getAnnotations(), noSuppressWarningsFilter), appendable, true, config); ITreeAppendable _xifexpression = null; EObject _eContainer = it.eContainer(); boolean _tripleEquals = (_eContainer == null); if (_tripleEquals) { StringConcatenation _builder = new StringConcatenation(); _builder.append("@SuppressWarnings(\"all\")"); _xifexpression = appendable.append(_builder).newLine(); } _xblockexpression = _xifexpression; } return _xblockexpression; }
Example 2
Source File: DeprecationUtil.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public static boolean isDeprecatedMember(JvmMember member) { if (member.isSetDeprecated()) { return member.isDeprecated(); } List<JvmAnnotationReference> annotations = member.getAnnotations(); for(JvmAnnotationReference annotation: annotations) { JvmAnnotationType annotationType = annotation.getAnnotation(); if (annotationType != null && Deprecated.class.getName().equals(annotationType.getIdentifier())) { return true; } } return false; }
Example 3
Source File: AnnotationLookup.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
public JvmAnnotationReference findAnnotation(/* @NonNull */ JvmAnnotationTarget annotationTarget, /* @NonNull */ String lookupType) { // avoid creating an empty list for all given targets but check for #eIsSet first if (annotationTarget.eIsSet(TypesPackage.Literals.JVM_ANNOTATION_TARGET__ANNOTATIONS)) { for(JvmAnnotationReference annotation: annotationTarget.getAnnotations()) { JvmAnnotationType annotationType = annotation.getAnnotation(); if (annotationType != null && lookupType.equals(annotationType.getQualifiedName())) { return annotation; } } } return null; }
Example 4
Source File: AnnotationSignatureRelevanceUtil.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected boolean isRelevant(JvmAnnotationReference annotationReference) { if (annotationReference == null || annotationReference.getAnnotation() == null || annotationReference.getAnnotation().getIdentifier() == null) return false; return getRelevantAnnotations().contains(annotationReference.getAnnotation().getIdentifier()); }
Example 5
Source File: JvmAnnotationReferencePrinter.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
/** * @return the HTML representation for the passed {@code reference} * @throws NullPointerException * if the {@code reference} is {@code null} */ public String toHtmlString(JvmAnnotationReference reference) { Preconditions.checkNotNull(reference); try { return internalToString(reference); } catch (RuntimeException e) { LOG.error(e.getMessage(), e); return reference.getAnnotation() != null ? reference.getAnnotation().getSimpleName() : null; } }
Example 6
Source File: XtendHighlightingCalculator.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected void highlightAnnotation(XAnnotation annotation, IHighlightedPositionAcceptor acceptor) { JvmType annotationType = annotation.getAnnotationType(); if (annotationType instanceof JvmAnnotationTarget) { for(JvmAnnotationReference annotationReference: ((JvmAnnotationTarget) annotationType).getAnnotations()) { JvmAnnotationType otherAnnotation = annotationReference.getAnnotation(); if (otherAnnotation != null && !otherAnnotation.eIsProxy() && Active.class.getName().equals(otherAnnotation.getIdentifier())) { highlightAnnotation(annotation, acceptor, ACTIVE_ANNOTATION); return; } } } super.highlightAnnotation(annotation, acceptor); }
Example 7
Source File: XtendResourceDescriptionStrategy.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
protected boolean isActiveAnnotation(JvmAnnotationType annotationType) { for (JvmAnnotationReference anno : annotationType.getAnnotations()) { JvmAnnotationType annotation = anno.getAnnotation(); if (annotation != null && !annotation.eIsProxy()) { if ("org.eclipse.xtend.lib.macro.Active".equals(annotation.getIdentifier())) { return true; } } } return false; }
Example 8
Source File: SARLAnnotationUtil.java From sarl with Apache License 2.0 | 5 votes |
/** Find an annotation. * * @param annotationTarget the annotation target. * @param lookupType the name of the type to look for. * @return the annotation or {@code null}. * @see AnnotationLookup#findAnnotation(JvmAnnotationTarget, Class) */ @SuppressWarnings("static-method") public JvmAnnotationReference findAnnotation(JvmAnnotationTarget annotationTarget, String lookupType) { // avoid creating an empty list for all given targets but check for #eIsSet first if (annotationTarget.eIsSet(TypesPackage.Literals.JVM_ANNOTATION_TARGET__ANNOTATIONS)) { for (final JvmAnnotationReference annotation: annotationTarget.getAnnotations()) { final JvmAnnotationType annotationType = annotation.getAnnotation(); if (annotationType != null && Objects.equals(lookupType, annotationType.getQualifiedName())) { return annotation; } } } return null; }