use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class NonOverridableTypesProviderTest method assertTypeParameterInScope.
protected void assertTypeParameterInScope(final String typeName, final JvmMember context) {
final JvmIdentifiableElement visibleType = this.typesFromHierarchy.getVisibleType(context, typeName);
Assert.assertNotNull(visibleType);
Assert.assertTrue((visibleType instanceof JvmTypeParameter));
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class JavaConverterTest method testSimpleTypeParameterCase.
@Test
public void testSimpleTypeParameterCase() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("public class TestTypeParameter <T,U extends T> {");
_builder.newLine();
_builder.append("\t");
_builder.append("<D extends T> T doStuff(Iterable<? super U> us, Iterable<? extends D> d, T t) {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("return t;");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
XtendClass xtendClazz = this.toValidXtendClass(_builder);
JvmTypeParameter typeParameter = xtendClazz.getTypeParameters().get(0);
Assert.assertEquals("T", typeParameter.getName());
typeParameter = xtendClazz.getTypeParameters().get(1);
Assert.assertEquals("U", typeParameter.getName());
Assert.assertEquals("extends T", typeParameter.getConstraints().get(0).getSimpleName());
XtendFunction xtendMember = this.method(xtendClazz, 0);
Assert.assertEquals("doStuff", xtendMember.getName());
typeParameter = xtendMember.getTypeParameters().get(0);
Assert.assertEquals("D", typeParameter.getName());
Assert.assertEquals("extends T", typeParameter.getConstraints().get(0).getSimpleName());
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class JvmModelTests method testJvmTypeParameter_06.
@Test
public void testJvmTypeParameter_06() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def <> foo() {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.file(_builder.toString(), false, false).getXtendTypes());
final JvmGenericType clazz = this._iXtendJvmAssociations.getInferredType(((XtendClass) _head));
final JvmOperation member = IterableExtensions.<JvmOperation>head(Iterables.<JvmOperation>filter(clazz.getMembers(), JvmOperation.class));
EList<JvmTypeParameter> _typeParameters = member.getTypeParameters();
String _plus = ("" + _typeParameters);
Assert.assertTrue(_plus, member.getTypeParameters().isEmpty());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class JvmModelTests method testJvmTypeParameter_02.
@Test
public void testJvmTypeParameter_02() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo<T> {");
_builder.newLine();
_builder.append("}");
_builder.newLine();
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.file(_builder.toString(), false, false).getXtendTypes());
final JvmGenericType clazz = this._iXtendJvmAssociations.getInferredType(((XtendClass) _head));
EList<JvmTypeParameter> _typeParameters = clazz.getTypeParameters();
String _plus = ("" + _typeParameters);
Assert.assertEquals(_plus, 1, clazz.getTypeParameters().size());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.
the class JvmModelTests method testJvmTypeParameter_04.
@Test
public void testJvmTypeParameter_04() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("new <T>() {");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
XtendTypeDeclaration _head = IterableExtensions.<XtendTypeDeclaration>head(this.file(_builder.toString(), false, false).getXtendTypes());
final JvmGenericType clazz = this._iXtendJvmAssociations.getInferredType(((XtendClass) _head));
final JvmConstructor member = IterableExtensions.<JvmConstructor>head(Iterables.<JvmConstructor>filter(clazz.getMembers(), JvmConstructor.class));
EList<JvmTypeParameter> _typeParameters = member.getTypeParameters();
String _plus = ("" + _typeParameters);
Assert.assertEquals(_plus, 1, member.getTypeParameters().size());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations