use of org.eclipse.xtext.common.types.JvmOperation 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.JvmOperation 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.JvmOperation 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.JvmOperation in project xtext-xtend by eclipse.
the class JvmModelTests method testEnumArtificialMethods.
@Test
public void testEnumArtificialMethods() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("package bar");
_builder.newLine();
_builder.newLine();
_builder.append("enum Foo {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final EList<JvmMember> inferred = this._iXtendJvmAssociations.getInferredEnumerationType(this.enumeration(_builder.toString())).getMembers();
Assert.assertEquals(2, inferred.size());
JvmMember _get = inferred.get(0);
final JvmOperation values = ((JvmOperation) _get);
Assert.assertEquals("bar.Foo.values()", values.getIdentifier());
Assert.assertTrue(values.isStatic());
Assert.assertEquals(JvmVisibility.PUBLIC, values.getVisibility());
JvmMember _get_1 = inferred.get(1);
final JvmOperation valueOf = ((JvmOperation) _get_1);
Assert.assertEquals("bar.Foo.valueOf(java.lang.String)", valueOf.getIdentifier());
Assert.assertTrue(valueOf.isStatic());
Assert.assertEquals(JvmVisibility.PUBLIC, valueOf.getVisibility());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class JvmModelTests method testEmptyListAsAnnotationValueDefault.
@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();
JvmMember _head = IterableExtensions.<JvmMember>head(this._iXtendJvmAssociations.getInferredAnnotationType(this.annotationType(_builder.toString())).getMembers());
final JvmOperation inferred = ((JvmOperation) _head);
Assert.assertEquals("java.lang.String[]", inferred.getReturnType().getIdentifier());
JvmAnnotationValue _defaultValue = inferred.getDefaultValue();
Assert.assertTrue((_defaultValue instanceof JvmCustomAnnotationValue));
JvmAnnotationValue _defaultValue_1 = inferred.getDefaultValue();
EObject _head_1 = IterableExtensions.<EObject>head(((JvmCustomAnnotationValue) _defaultValue_1).getValues());
Assert.assertTrue((_head_1 instanceof XListLiteral));
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations