public static boolean isDeprecated(JvmAnnotationType jvmAnnotationType) { return jvmAnnotationType.getQualifiedName().equals(Deprecated.class.getName()); } }
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; } }
private JvmOperation findOperation(final String name) { ConditionUtils.checkJavaIdentifier(name, "name"); AnnotationTypeDeclaration _annotationTypeDeclaration = this.getAnnotationTypeDeclaration(); final JvmAnnotationType jvmAnnoType = ((JvmAnnotationTypeDeclarationImpl) _annotationTypeDeclaration).getDelegate(); final Function1<JvmOperation, Boolean> _function = (JvmOperation it) -> { String _simpleName = it.getSimpleName(); return Boolean.valueOf(Objects.equal(_simpleName, name)); }; final JvmOperation jvmOperation = IterableExtensions.<JvmOperation>findFirst(jvmAnnoType.getDeclaredOperations(), _function); if ((jvmOperation == null)) { String _identifier = jvmAnnoType.getIdentifier(); String _plus = ((("The annotation property \'" + name) + "\' is not declared on the annotation type \'") + _identifier); String _plus_1 = (_plus + "\'."); throw new IllegalArgumentException(_plus_1); } return jvmOperation; }
public static boolean isDeprecatedAnnotation(JvmAnnotationType jvmAnnotationType) { return !jvmAnnotationType.eIsProxy() && Deprecated.class.getName().equals(jvmAnnotationType.getIdentifier()); }
protected boolean isActiveAnnotation(final JvmAnnotationType annotationType) { EList<JvmAnnotationReference> _annotations = annotationType.getAnnotations(); for (final JvmAnnotationReference anno : _annotations) { String _identifier = anno.getAnnotation().getIdentifier(); String _name = Active.class.getName(); boolean _equals = Objects.equal(_identifier, _name); if (_equals) { return true; } } return false; } }
private boolean containsAnnotation(JvmAnnotationTarget annotationTarget, Class<? extends Annotation> annotationClass) { for (JvmAnnotationReference annotationRef : annotationTarget.getAnnotations()) { if (annotationClass.getName().equals(annotationRef.getAnnotation().getIdentifier())) { return true; } } return false; }
protected JvmAnnotationType createAnnotationType(Class<?> clazz) { JvmAnnotationType result = TypesFactory.eINSTANCE.createJvmAnnotationType(); result.internalSetIdentifier(clazz.getName()); result.setSimpleName(clazz.getSimpleName()); if (clazz.getDeclaringClass() == null && clazz.getPackage() != null) result.setPackageName(clazz.getPackage().getName()); setVisibility(clazz, result); setTypeModifiers(clazz, result); createNestedTypes(clazz, result); createMethods(clazz, result); setSuperTypes(clazz, result); createAnnotationValues(clazz, result); return result; }
public JvmOperation findSingleValueAttribute(JvmAnnotationType type) { Iterable<JvmOperation> operations = type.getDeclaredOperations(); for (JvmOperation operation : operations) { if (operation.getSimpleName().equals("value")) { return operation; } } return null; }
/** * Creates a public annotation declaration, associated to the given sourceElement. It sets the given name, which might be * fully qualified using the standard Java notation. * * @param sourceElement * the sourceElement the resulting element is associated with. * @param name * the qualified name of the resulting class. * @param initializer * the initializer to apply on the created annotation. If <code>null</code>, the annotation won't be initialized. * * @return a {@link JvmAnnotationType} representing a Java annotation of the given name, <code>null</code> * if sourceElement or name are <code>null</code>. */ /* @Nullable */ public JvmAnnotationType toAnnotationType(/* @Nullable */ EObject sourceElement, /* @Nullable */ String name, /* @Nullable */ Procedure1<? super JvmAnnotationType> initializer) { if (sourceElement == null || name == null) return null; Pair<String, String> fullName = splitQualifiedName(name); JvmAnnotationType annotationType = typesFactory.createJvmAnnotationType(); annotationType.setSimpleName(fullName.getSecond()); annotationType.setAbstract(true); if (fullName.getFirst() != null) annotationType.setPackageName(fullName.getFirst()); associate(sourceElement, annotationType); return initializeSafely(annotationType, initializer); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public JvmAnnotationType getAnnotation() { if (annotation != null && annotation.eIsProxy()) { InternalEObject oldAnnotation = (InternalEObject)annotation; annotation = (JvmAnnotationType)eResolveProxy(oldAnnotation); if (annotation != oldAnnotation) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, TypesPackage.JVM_ANNOTATION_REFERENCE__ANNOTATION, oldAnnotation, annotation)); } } return annotation; }
this.generateAnnotations(it.getAnnotations(), childAppendable, true, config); this.generateModifier(it, childAppendable, config); childAppendable.append("@interface "); this._treeAppendableUtil.traceSignificant(childAppendable, it).append(this.makeJavaIdentifier(it.getSimpleName())); childAppendable.append(" {"); Iterable<JvmDeclaredType> _filter = Iterables.<JvmDeclaredType>filter(this.getMembersToBeCompiled(it), JvmDeclaredType.class); EObject _eContainer = it.eContainer(); boolean _not = (!(_eContainer instanceof JvmType)); if (_not) {
JvmTypeReference _xblockexpression = null; final JvmOperation defaultOp = IterableExtensions.<JvmOperation>head(Iterables.<JvmOperation>filter(((JvmAnnotationReference)container).getAnnotation().findAllFeaturesByName("value"), JvmOperation.class)); JvmTypeReference _xifexpression = null; if ((defaultOp != null)) {
/** * @return <code>true</code> if this annotation is annotated with Java8 Repeatable meta-annotation. */ public boolean isRepeatable(final JvmAnnotationType annotationType) { for (Iterator<JvmAnnotationReference> iterator = annotationType.getAnnotations().iterator(); iterator.hasNext();) { JvmAnnotationReference metaAnnotation = iterator.next(); if ("java.lang.annotation.Repeatable".equals(metaAnnotation.getAnnotation().getIdentifier())) { return true; } } return false; }
protected boolean isRelevant(JvmAnnotationReference annotationReference) { if (annotationReference == null || annotationReference.getAnnotation() == null || annotationReference.getAnnotation().getIdentifier() == null) return false; return getRelevantAnnotations().contains(annotationReference.getAnnotation().getIdentifier()); }
protected JvmAnnotationType createAnnotationType(Class<?> clazz) { JvmAnnotationType result = TypesFactory.eINSTANCE.createJvmAnnotationType(); result.internalSetIdentifier(clazz.getName()); result.setSimpleName(clazz.getSimpleName()); if (clazz.getDeclaringClass() == null && clazz.getPackage() != null) result.setPackageName(clazz.getPackage().getName()); setVisibility(clazz, result); setTypeModifiers(clazz, result); createNestedTypes(clazz, result); createMethods(clazz, result); createFields(clazz, result); setSuperTypes(clazz, result); createAnnotationValues(clazz, result); return result; }
private JvmOperation getOperation(JvmAnnotationType annotationType, String operationName) { for (JvmOperation operation : annotationType.getDeclaredOperations()) { if (operationName.equals(operation.getSimpleName())) return operation; } return null; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public JvmAnnotationType getAnnotation() { if (annotation != null && annotation.eIsProxy()) { InternalEObject oldAnnotation = (InternalEObject)annotation; annotation = (JvmAnnotationType)eResolveProxy(oldAnnotation); if (annotation != oldAnnotation) { if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.RESOLVE, TypesPackage.JVM_ANNOTATION_REFERENCE__ANNOTATION, oldAnnotation, annotation)); } } return annotation; }
XExpression expression = object.getValue(); if (expression != null) { Iterable<JvmFeature> iterable = ((JvmAnnotationType) annotationType).findAllFeaturesByName("value"); JvmFeature value = Iterables.getOnlyElement(iterable, null); if (value != null) { List<XAnnotationElementValuePair> valuePairs = object.getElementValuePairs(); if (valuePairs.isEmpty()) { Iterable<JvmFeature> iterable = ((JvmAnnotationType) annotationType).findAllFeaturesByName("value"); JvmFeature value = Iterables.getOnlyElement(iterable, null); if (value != null) {
@Override public Boolean apply(final JvmAnnotationReference it) { JvmAnnotationType _annotation = it.getAnnotation(); String _qualifiedName = _annotation.getQualifiedName(); String _name = Pure.class.getName(); return Boolean.valueOf(Objects.equal(_qualifiedName, _name)); } };
public Set<ElementType> getAnnotationTargets(JvmAnnotationType annotation) { EList<JvmAnnotationReference> annotations = annotation.getAnnotations(); for (JvmAnnotationReference annoRef : annotations) { if (Target.class.getName().equals(annoRef.getAnnotation().getIdentifier())) { EList<JvmAnnotationValue> values = annoRef.getValues(); JvmAnnotationValue value = values.isEmpty() ? null : values.get(0); if (value instanceof JvmEnumAnnotationValue) { Set<ElementType> result = newHashSet(); for (JvmEnumerationLiteral elementType : ((JvmEnumAnnotationValue) value).getValues()) { final String simpleName = elementType.getSimpleName(); result.add(ElementType.valueOf(simpleName)); } return result; } } } return emptySet(); }