use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-xtend by eclipse.
the class NonOverridableTypesProviderTest method testInheritMiddle_01.
@Test
public void testInheritMiddle_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("import types.OuterClass");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo extends OuterClass$MiddleClass {");
_builder.newLine();
_builder.append("\t");
_builder.append("def foo() ");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendClass xtendClass = this.clazz(_builder.toString());
final JvmGenericType inferredType = this.associations.getInferredType(xtendClass);
this.assertTypeInScope("Foo", inferredType);
this.assertTypeInScope("InnerMostClass", inferredType);
this.assertNotInScope("OuterClass.MiddleClass", inferredType);
this.assertNotInScope("MiddleClass", inferredType);
this.assertNotInScope("OuterClass", inferredType);
this.assertNotInScope("PrivateMiddleClass", inferredType);
final XtendMember method = xtendClass.getMembers().get(0);
final JvmOperation operation = this.associations.getDirectlyInferredOperation(((XtendFunction) method));
this.assertTypeInScope("Foo", operation);
this.assertTypeInScope("InnerMostClass", operation);
this.assertNotInScope("OuterClass.MiddleClass", operation);
this.assertNotInScope("MiddleClass", operation);
this.assertNotInScope("OuterClass", operation);
this.assertNotInScope("PrivateMiddleClass", inferredType);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-xtend by eclipse.
the class NonOverridableTypesProviderTest method testInheritMiddleParam_01.
@Test
public void testInheritMiddleParam_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("import types.OuterClass");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo<InnerMostClass, T> extends OuterClass$MiddleClass<String> {");
_builder.newLine();
_builder.append("\t");
_builder.append("def <InnerMostClass> foo() ");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar() ");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendClass xtendClass = this.clazz(_builder.toString());
final JvmGenericType inferredType = this.associations.getInferredType(xtendClass);
this.assertTypeInScope("Foo", inferredType);
this.assertTypeInScope("InnerMostClass", inferredType);
this.assertTypeParameterInScope("T", inferredType);
this.assertNotInScope("OuterClass.MiddleClass", inferredType);
this.assertNotInScope("MiddleClass", inferredType);
this.assertNotInScope("OuterClass", inferredType);
final XtendMember method = xtendClass.getMembers().get(0);
final JvmOperation operation = this.associations.getDirectlyInferredOperation(((XtendFunction) method));
this.assertTypeInScope("Foo", operation);
this.assertTypeParameterInScope("InnerMostClass", operation);
this.assertTypeParameterInScope("T", operation);
this.assertNotInScope("OuterClass.MiddleClass", operation);
this.assertNotInScope("MiddleClass", operation);
this.assertNotInScope("OuterClass", operation);
final XtendMember method2 = xtendClass.getMembers().get(0);
final JvmOperation operation2 = this.associations.getDirectlyInferredOperation(((XtendFunction) method2));
this.assertTypeInScope("Foo", operation2);
this.assertTypeInScope("InnerMostClass", operation2);
this.assertTypeParameterInScope("T", operation2);
this.assertNotInScope("OuterClass.MiddleClass", operation2);
this.assertNotInScope("MiddleClass", operation2);
this.assertNotInScope("OuterClass", operation2);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-xtend by eclipse.
the class NonOverridableTypesProviderTest method testInheritOuterTypeParam.
@Test
public void testInheritOuterTypeParam() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package foo");
_builder.newLine();
_builder.newLine();
_builder.append("import types.OuterClass");
_builder.newLine();
_builder.newLine();
_builder.append("class Foo<MiddleClass, T> extends OuterClass<String> {");
_builder.newLine();
_builder.append("\t");
_builder.append("def <MiddleClass> foo() ");
_builder.newLine();
_builder.append("\t");
_builder.append("def bar()");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendClass xtendClass = this.clazz(_builder.toString());
final JvmGenericType inferredType = this.associations.getInferredType(xtendClass);
this.assertTypeInScope("Foo", inferredType);
this.assertTypeInScope("MiddleClass", inferredType);
this.assertNotInScope("MiddleClass.InnerMostClass", inferredType);
this.assertTypeParameterInScope("T", inferredType);
this.assertNotInScope("OuterClass", inferredType);
final XtendMember method = xtendClass.getMembers().get(0);
final JvmOperation operation = this.associations.getDirectlyInferredOperation(((XtendFunction) method));
this.assertTypeInScope("Foo", operation);
this.assertTypeParameterInScope("MiddleClass", operation);
this.assertTypeParameterInScope("T", operation);
this.assertNotInScope("MiddleClass.InnerMostClass", operation);
this.assertNotInScope("OuterClass", operation);
final XtendMember method2 = xtendClass.getMembers().get(0);
final JvmOperation operation2 = this.associations.getDirectlyInferredOperation(((XtendFunction) method2));
this.assertTypeInScope("Foo", operation2);
this.assertTypeParameterInScope("MiddleClass", operation2);
this.assertTypeParameterInScope("T", operation2);
this.assertNotInScope("MiddleClass.InnerMostClass", operation2);
this.assertNotInScope("OuterClass", operation2);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmGenericType in project xtext-xtend by eclipse.
the class JvmModelTests method testInterfaceImplicitSuperType.
@Test
public void testInterfaceImplicitSuperType() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("interface Foo {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final JvmGenericType inferred = this._iXtendJvmAssociations.getInferredType(this.interfaze(_builder.toString()));
Assert.assertEquals(1, inferred.getSuperTypes().size());
Assert.assertEquals("java.lang.Object", IterableExtensions.<JvmTypeReference>head(inferred.getSuperTypes()).getIdentifier());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmGenericType 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);
}
}
Aggregations