public JvmOperation findSingleValueAttribute(JvmAnnotationType type) { Iterable<JvmOperation> operations = type.getDeclaredOperations(); for (JvmOperation operation : operations) { if (operation.getSimpleName().equals("value")) { return operation; } } return null; }
private JvmOperation getOperation(JvmAnnotationType annotationType, String operationName) { for (JvmOperation operation : annotationType.getDeclaredOperations()) { if (operationName.equals(operation.getSimpleName())) return operation; } return null; }
JvmOperation statement = null; final Iterator<JvmOperation> operationIterator = annotationReference.getAnnotation() .getDeclaredOperations().iterator(); while ((value == null || imported == null || constant == null || statement == null) && operationIterator.hasNext()) {
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; }
@Override public EList<JvmAnnotationValue> getValues() { EList<JvmAnnotationValue> explicitValues = getExplicitValues(); List<JvmOperation> operations = Lists.newArrayList(getAnnotation().getDeclaredOperations()); if (operations.size() <= explicitValues.size()) { return ECollections.unmodifiableEList(explicitValues); } Set<JvmOperation> seenOperations = Sets.newHashSetWithExpectedSize(operations.size()); BasicEList<JvmAnnotationValue> result = new BasicEList<JvmAnnotationValue>(operations.size()); for(JvmAnnotationValue value: explicitValues) { seenOperations.add(value.getOperation()); result.add(value); } for(JvmOperation operation: operations) { if (seenOperations.add(operation)) { JvmAnnotationValue defaultValue = operation.getDefaultValue(); if (defaultValue != null) { result.add(defaultValue); } } } return ECollections.unmodifiableEList(result); }
@Override public IScope getScope(EObject context, EReference reference) { if (reference == XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT) { XAnnotation annotation = EcoreUtil2.getContainerOfType(context, XAnnotation.class); JvmType annotationType = annotation.getAnnotationType(); if (annotationType == null || annotationType.eIsProxy() || !(annotationType instanceof JvmAnnotationType)) { return IScope.NULLSCOPE; } Iterable<JvmOperation> operations = ((JvmAnnotationType) annotationType).getDeclaredOperations(); Iterable<IEObjectDescription> descriptions = transform(operations, new Function<JvmOperation, IEObjectDescription>() { @Override public IEObjectDescription apply(JvmOperation from) { return EObjectDescription.create(QualifiedName.create(from.getSimpleName()), from); } }); return MapBasedScope.createScope(IScope.NULLSCOPE, descriptions); } return super.getScope(context, reference); }
protected JvmOperation findOperation(final String name) { ConditionUtils.checkJavaIdentifier(name, "name"); final JvmAnnotationType annotationType = this.delegate.getAnnotation(); final Function1<JvmOperation, Boolean> _function = (JvmOperation it) -> { String _simpleName = it.getSimpleName(); return Boolean.valueOf(Objects.equal(_simpleName, name)); }; final JvmOperation jvmOperation = IterableExtensions.<JvmOperation>findFirst(annotationType.getDeclaredOperations(), _function); if ((jvmOperation == null)) { StringConcatenation _builder = new StringConcatenation(); _builder.append("The annotation property \'"); _builder.append(name); _builder.append("\' is not declared on the annotation type \'"); String _identifier = annotationType.getIdentifier(); _builder.append(_identifier); _builder.append("\'."); throw new IllegalArgumentException(_builder.toString()); } return jvmOperation; }
@Check public void checkAllAttributesConfigured(XAnnotation annotation) { JvmType annotationType = annotation.getAnnotationType(); if (annotationType == null || annotationType.eIsProxy() || !(annotationType instanceof JvmAnnotationType)) return; Iterable<JvmOperation> attributes = ((JvmAnnotationType) annotationType).getDeclaredOperations(); for (JvmOperation jvmOperation : attributes) { XExpression value = annotationUtil.findValue(annotation, jvmOperation); if(value == null) { if (jvmOperation.getDefaultValue() == null) { error("The annotation must define the attribute '"+jvmOperation.getSimpleName()+"'.", annotation, null, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, ANNOTATIONS_MISSING_ATTRIBUTE_DEFINITION); } } else annotationValueValidator.validateAnnotationValue(value, this); } }