@Check public void checkAnnotationIsBindingAnnotation(final XAnnotation it) { JvmType _annotationType = it.getAnnotationType(); final JvmType type = _annotationType; boolean _matched = false; if (!_matched) { if (type instanceof JvmAnnotationType) { final JvmAnnotationType _jvmAnnotationType = (JvmAnnotationType) type; _matched = true; EList<JvmAnnotationReference> _annotations = _jvmAnnotationType.getAnnotations(); final Function1<JvmAnnotationReference, Boolean> _function = new Function1<JvmAnnotationReference, Boolean>() { public Boolean apply(final JvmAnnotationReference it) { JvmAnnotationType _annotation = it.getAnnotation(); boolean _is = GuiceModulesValidator.this._typeReferences.is( _annotation, BindingAnnotation.class); return Boolean.valueOf(_is); } }; boolean _exists = IterableExtensions.<JvmAnnotationReference>exists(_annotations, _function); boolean _not = (!_exists); if (_not) { this.error( "The annotation is not annotated with @BindingAnnotation", Literals.XANNOTATION__ANNOTATION_TYPE); } } } }
@Test public void testEmptyListAsAnnotationValueDefault() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("annotation Foo {"); _builder.newLine(); _builder.append("\t"); _builder.append("String[] bar = #[]"); _builder.newLine(); _builder.append("}"); _builder.newLine(); String _string = _builder.toString(); XtendAnnotationType _annotationType = this.annotationType(_string); JvmAnnotationType _inferredAnnotationType = this._iXtendJvmAssociations.getInferredAnnotationType(_annotationType); EList<JvmMember> _members = _inferredAnnotationType.getMembers(); JvmMember _head = IterableExtensions.<JvmMember>head(_members); final JvmOperation inferred = ((JvmOperation) _head); JvmTypeReference _returnType = inferred.getReturnType(); String _identifier = _returnType.getIdentifier(); Assert.assertEquals("java.lang.String[]", _identifier); JvmAnnotationValue _defaultValue = inferred.getDefaultValue(); Assert.assertTrue((_defaultValue instanceof JvmStringAnnotationValue)); JvmAnnotationValue _defaultValue_1 = inferred.getDefaultValue(); EList<String> _values = ((JvmStringAnnotationValue) _defaultValue_1).getValues(); boolean _isEmpty = _values.isEmpty(); Assert.assertTrue(_isEmpty); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
@Test public void testAnnotationImplicitSuperType() { try { StringConcatenation _builder = new StringConcatenation(); _builder.append("annotation Foo {"); _builder.newLine(); _builder.append("}"); _builder.newLine(); String _string = _builder.toString(); XtendAnnotationType _annotationType = this.annotationType(_string); final JvmAnnotationType inferred = this._iXtendJvmAssociations.getInferredAnnotationType(_annotationType); EList<JvmTypeReference> _superTypes = inferred.getSuperTypes(); int _size = _superTypes.size(); Assert.assertEquals(1, _size); EList<JvmTypeReference> _superTypes_1 = inferred.getSuperTypes(); JvmTypeReference _head = IterableExtensions.<JvmTypeReference>head(_superTypes_1); String _identifier = _head.getIdentifier(); Assert.assertEquals("java.lang.annotation.Annotation", _identifier); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }