protected boolean isExtensionProvider(JvmAnnotationTarget annotatedElement) { // coding style to simplify debugging if (annotationLookup.findAnnotation(annotatedElement, Extension.class) != null) { return true; } return false; }
public JvmAnnotationReference findOrAddAnnotation(/* @NonNull */ JvmAnnotationTarget annotationTarget, /* @NonNull */ Notifier context, /* @NonNull */ Class<? extends Annotation> type) { JvmAnnotationReference result = findAnnotation(annotationTarget, type); if (result != null) return result; JvmAnnotationType annotationType = findAnnotationType(type, context); if (annotationType != null) { result = typesFactory.createJvmAnnotationReference(); result.setAnnotation(annotationType); return result; } return null; }
protected void internalSetExtension(JvmAnnotationTarget annotationTarget, EObject sourceElement, boolean value) { if (value) { annotationLookup.findOrAddAnnotation(annotationTarget, sourceElement, Extension.class); } else { annotationLookup.removeAnnotation(annotationTarget, Extension.class); } }
boolean generateSuppressWarnings = !(jvmType instanceof JvmAnnotationType) && generatorConfig.isGenerateSyntheticSuppressWarnings() && annotationLookup.findAnnotation(jvmType, SuppressWarnings.class) == null && references.findDeclaredType(SuppressWarnings.class, jvmType) instanceof JvmAnnotationType; JvmType generatedJvmType = references.findDeclaredType("javax.annotation.Generated", jvmType); annotationLookup.removeAnnotation(jvmType, Generated.class); jvmType.getAnnotations().add(annotationRef);
@Check public void checkMultipleAnnotations(final XtendAnnotationTarget annotationTarget) { if (annotationTarget.getAnnotations().size() <= 1 || !isRelevantAnnotationTarget(annotationTarget)) { return; } ImmutableListMultimap<String, XAnnotation> groupByIdentifier = Multimaps.index(annotationTarget.getAnnotations(), new Function<XAnnotation, String>() { @Override public String apply(XAnnotation input) { return input.getAnnotationType().getIdentifier(); } }); for (String qName : groupByIdentifier.keySet()) { ImmutableList<XAnnotation> sameType = groupByIdentifier.get(qName); if (sameType.size() > 1) { JvmType type = sameType.get(0).getAnnotationType(); if (type instanceof JvmAnnotationType && !type.eIsProxy() && !annotationLookup.isRepeatable((JvmAnnotationType) type)) { for (XAnnotation xAnnotation : sameType) { error("Multiple annotations of non-repeatable type @" + xAnnotation.getAnnotationType().getSimpleName() + ". Only annotation types marked @Repeatable can be used multiple times at one target.", xAnnotation, XAnnotationsPackage.Literals.XANNOTATION__ANNOTATION_TYPE, INSIGNIFICANT_INDEX, ANNOTATION_MULTIPLE); } } } } }
protected boolean isExtension(JvmIdentifiableElement jvmIdentifiableElement){ if(jvmIdentifiableElement instanceof JvmAnnotationTarget){ return annotationLookup.findAnnotation((JvmAnnotationTarget) jvmIdentifiableElement, Extension.class) != null; } return false; }
@Nullable public JvmAnnotationReference findOrAddAnnotation(@NonNull JvmAnnotationTarget annotationTarget, @NonNull Notifier context, @NonNull Class<? extends Annotation> type) { JvmAnnotationReference result = findAnnotation(annotationTarget, type); if (result != null) return result; JvmAnnotationType annotationType = findAnnotationType(type, context); if (annotationType != null) { result = typesFactory.createJvmAnnotationReference(); result.setAnnotation(annotationType); return result; } return null; }
@Override public boolean isEarlyExitAnnotatedElement(Object element) { return (element instanceof JvmAnnotationTarget) && (this.annotations.findAnnotation((JvmAnnotationTarget) element, EarlyExit.class) != null); }
@Override public boolean hasFormalParameterDefaultValue(int position) { final JvmFormalParameter parameter = this.parameters.get(position); return this.annotationFinder.findAnnotation(parameter, DefaultValue.class) != null; }
@Override public boolean isPureOperation(JvmOperation operation) { if (operation == null) { return false; } return this.annotations.findAnnotation(operation, Pure.class) != null || evaluatePureAnnotationAdapters(operation); }
/** Extract the type values of the given annotation, if they exist. * * @param op the annotated element. * @param annotationType the type of the annotation to consider * @return the values of the annotation, never {@code null}. */ public List<JvmTypeReference> findTypeValues(JvmAnnotationTarget op, Class<? extends Annotation> annotationType) { final JvmAnnotationReference reference = this.lookup.findAnnotation(op, annotationType); if (reference != null) { return findTypeValues(reference); } return null; }
/** Extract the string value of the given annotation, if it exists. * * @param op the annotated element. * @param annotationType the type of the annotation to consider * @return the value of the annotation, or {@code null} if no annotation or no * value. */ public String findStringValue(JvmAnnotationTarget op, Class<? extends Annotation> annotationType) { final JvmAnnotationReference reference = this.lookup.findAnnotation(op, annotationType); if (reference != null) { return findStringValue(reference); } return null; }
/** Extract the boolean values of the given annotation, if they exist. * * @param op the annotated element. * @param annotationType the type of the annotation to consider * @return the values of the annotation, never {@code null}. * @since 0.6 */ public List<Boolean> findBooleanValues(JvmAnnotationTarget op, Class<? extends Annotation> annotationType) { final JvmAnnotationReference reference = this.lookup.findAnnotation(op, annotationType); if (reference != null) { return findBooleanValues(reference); } return null; }
/** Extract the string values of the given annotation, if they exist. * * @param op the annotated element. * @param annotationType the type of the annotation to consider * @return the values of the annotation, never {@code null}. */ public List<String> findStringValues(JvmAnnotationTarget op, Class<? extends Annotation> annotationType) { final JvmAnnotationReference reference = this.lookup.findAnnotation(op, annotationType); if (reference != null) { return findStringValues(reference); } return null; }
/** Extract the integer values of the given annotation, if they exist. * * @param op the annotated element. * @param annotationType the type of the annotation to consider * @return the values of the annotation, never {@code null}. * @since 0.6 */ public List<Integer> findIntValues(JvmAnnotationTarget op, Class<? extends Annotation> annotationType) { final JvmAnnotationReference reference = this.lookup.findAnnotation(op, annotationType); if (reference != null) { return findIntValues(reference); } return null; }
/** Extract the integer value of the given annotation, if it exists. * * @param op the annotated element. * @param annotationType the type of the annotation to consider * @return the value of the annotation, or {@code null} if no annotation or no * value. * @since 0.6 */ public Integer findIntValue(JvmAnnotationTarget op, Class<? extends Annotation> annotationType) { final JvmAnnotationReference reference = this.lookup.findAnnotation(op, annotationType); if (reference != null) { return findIntValue(reference); } return null; }
/** Extract the boolean value of the given annotation, if it exists. * * @param op the annotated element. * @param annotationType the type of the annotation to consider * @return the value of the annotation, or {@code null} if no annotation or no * value. * @since 0.6 */ public Boolean findBooleanValue(JvmAnnotationTarget op, Class<? extends Annotation> annotationType) { final JvmAnnotationReference reference = this.lookup.findAnnotation(op, annotationType); if (reference != null) { return findBooleanValue(reference); } return null; }
public JvmAnnotationReference removeAnnotation(/* @NonNull */ JvmAnnotationTarget annotationTarget, /* @NonNull */ Class<? extends Annotation> type) { JvmAnnotationReference result = findAnnotation(annotationTarget, type); if (result != null) { annotationTarget.getAnnotations().remove(result); return result; } return null; }
/** Append the @FunctionalInterface to the given type if it is a functional interface according * to the Java 8 specification definition. * * @param type the type to update. */ protected void appendFunctionalInterfaceAnnotation(JvmGenericType type) { if (type != null && Utils.isFunctionalInterface(type, this.sarlSignatureProvider) && this.annotationFinder.findAnnotation(type, FunctionalInterface.class) == null) { addAnnotationSafe(type, FunctionalInterface.class); } }
/** Replies if ambiguity could be removed for the given feature. * * @param candidate the candidate. * @return {@code true} if ambiguity could be removed. */ @SuppressWarnings({"checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity"}) protected boolean isIgnorableCallToFeature(ILinkingCandidate candidate) { final JvmIdentifiableElement feature = candidate.getFeature(); // // @Deprecated // if (feature instanceof JvmOperation) { JvmAnnotationTarget target = (JvmOperation) feature; JvmAnnotationReference reference = this.annotationLookup.findAnnotation(target, Deprecated.class); if (reference == null) { do { target = EcoreUtil2.getContainerOfType(target.eContainer(), JvmAnnotationTarget.class); if (target != null) { reference = this.annotationLookup.findAnnotation(target, Deprecated.class); } } while (reference == null && target != null); } if (reference != null) { return true; } } return false; }