use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method initialize.
protected void initialize(XtendClass source, JvmGenericType inferredJvmType) {
inferredJvmType.setVisibility(source.getVisibility());
boolean isStatic = source.isStatic() && !isTopLevel(source);
if (!isStatic) {
JvmDeclaredType declaringType = inferredJvmType.getDeclaringType();
if (declaringType instanceof JvmGenericType) {
if (((JvmGenericType) declaringType).isInterface())
isStatic = true;
} else if (declaringType instanceof JvmAnnotationType) {
isStatic = true;
}
}
inferredJvmType.setStatic(isStatic);
inferredJvmType.setAbstract(source.isAbstract());
inferredJvmType.setStrictFloatingPoint(source.isStrictFloatingPoint());
if (!inferredJvmType.isAbstract()) {
inferredJvmType.setFinal(source.isFinal());
}
translateAnnotationsTo(source.getAnnotations(), inferredJvmType);
JvmTypeReference extendsClause = source.getExtends();
if (extendsClause == null || extendsClause.getType() == null) {
JvmTypeReference typeRefToObject = typeReferences.getTypeForName(Object.class, source);
if (typeRefToObject != null)
inferredJvmType.getSuperTypes().add(typeRefToObject);
} else {
inferredJvmType.getSuperTypes().add(jvmTypesBuilder.cloneWithProxies(extendsClause));
}
for (JvmTypeReference intf : source.getImplements()) {
inferredJvmType.getSuperTypes().add(jvmTypesBuilder.cloneWithProxies(intf));
}
fixTypeParameters(inferredJvmType);
addDefaultConstructor(source, inferredJvmType);
for (XtendMember member : source.getMembers()) {
if (member instanceof XtendField || (member instanceof XtendFunction && ((XtendFunction) member).getName() != null) || member instanceof XtendConstructor) {
transform(member, inferredJvmType, true);
}
}
appendSyntheticDispatchMethods(source, inferredJvmType);
jvmTypesBuilder.copyDocumentationTo(source, inferredJvmType);
nameClashResolver.resolveNameClashes(inferredJvmType);
}
use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.
the class JvmModelTests method testAnnotationImplicitSuperType.
@Test
public void testAnnotationImplicitSuperType() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotation Foo {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final JvmAnnotationType inferred = this._iXtendJvmAssociations.getInferredAnnotationType(this.annotationType(_builder.toString()));
Assert.assertEquals(1, inferred.getSuperTypes().size());
Assert.assertEquals("java.lang.annotation.Annotation", IterableExtensions.<JvmTypeReference>head(inferred.getSuperTypes()).getIdentifier());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.
the class JvmModelTests method testAnnotationAbstract.
@Test
public void testAnnotationAbstract() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotation Foo {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final JvmAnnotationType inferred = this._iXtendJvmAssociations.getInferredAnnotationType(this.annotationType(_builder.toString()));
Assert.assertTrue(inferred.isAbstract());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.
the class JvmModelTests method testClassInAnnotationIsStatic.
@Test
public void testClassInAnnotationIsStatic() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotation Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("class C {}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final JvmAnnotationType inferred = this._iXtendJvmAssociations.getInferredAnnotationType(this.annotationType(_builder.toString()));
JvmMember _head = IterableExtensions.<JvmMember>head(inferred.getMembers());
final JvmGenericType c = ((JvmGenericType) _head);
Assert.assertTrue(c.isStatic());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmAnnotationType in project xtext-xtend by eclipse.
the class JvmModelTests method testNestedClass_01.
@Test
public void testNestedClass_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo { ");
_builder.newLine();
_builder.append("\t");
_builder.append("static class Nested0 {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("interface Nested1 {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("annotation Nested2 {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("enum Nested3 {");
_builder.newLine();
_builder.append("\t\t\t\t");
_builder.append("X");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final JvmGenericType clazz = this._iXtendJvmAssociations.getInferredType(this.clazz(_builder.toString()));
Assert.assertEquals(2, clazz.getMembers().size());
JvmMember _head = IterableExtensions.<JvmMember>head(clazz.getMembers());
Assert.assertTrue((_head instanceof JvmGenericType));
JvmMember _head_1 = IterableExtensions.<JvmMember>head(clazz.getMembers());
final JvmGenericType nested0 = ((JvmGenericType) _head_1);
Assert.assertEquals("Nested0", nested0.getSimpleName());
Assert.assertTrue(nested0.isStatic());
Assert.assertEquals(2, nested0.getMembers().size());
JvmMember _head_2 = IterableExtensions.<JvmMember>head(nested0.getMembers());
Assert.assertTrue((_head_2 instanceof JvmGenericType));
JvmMember _head_3 = IterableExtensions.<JvmMember>head(nested0.getMembers());
final JvmGenericType nested1 = ((JvmGenericType) _head_3);
Assert.assertEquals("Nested1", nested1.getSimpleName());
Assert.assertTrue(nested1.isStatic());
Assert.assertEquals(2, nested1.getMembers().size());
JvmMember _head_4 = IterableExtensions.<JvmMember>head(nested1.getMembers());
Assert.assertTrue((_head_4 instanceof JvmAnnotationType));
JvmMember _head_5 = IterableExtensions.<JvmMember>head(nested1.getMembers());
final JvmAnnotationType nested2 = ((JvmAnnotationType) _head_5);
Assert.assertEquals("Nested2", nested2.getSimpleName());
Assert.assertTrue(nested2.isStatic());
Assert.assertEquals(2, nested1.getMembers().size());
JvmMember _last = IterableExtensions.<JvmMember>last(nested1.getMembers());
Assert.assertTrue((_last instanceof JvmEnumerationType));
JvmMember _last_1 = IterableExtensions.<JvmMember>last(nested1.getMembers());
final JvmEnumerationType nested3 = ((JvmEnumerationType) _last_1);
Assert.assertEquals("Nested3", nested3.getSimpleName());
Assert.assertTrue(nested3.isStatic());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations