use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class ValidationBug433213Test method test_02.
@Test
public void test_02() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class C {");
_builder.newLine();
_builder.append("\t");
_builder.append("def <T> m() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new Object {");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("def T m2() {}");
_builder.newLine();
_builder.append("\t\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.parser.parse(_builder);
final XtendTypeDeclaration c = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head = IterableExtensions.<XtendMember>head(c.getMembers());
final XtendFunction m = ((XtendFunction) _head);
XExpression _expression = m.getExpression();
final XBlockExpression body = ((XBlockExpression) _expression);
XExpression _head_1 = IterableExtensions.<XExpression>head(body.getExpressions());
final AnonymousClass anon = ((AnonymousClass) _head_1);
XtendMember _head_2 = IterableExtensions.<XtendMember>head(anon.getMembers());
final XtendFunction m2 = ((XtendFunction) _head_2);
final JvmTypeReference returnType = m2.getReturnType();
final JvmType t = returnType.getType();
Assert.assertNotNull("notNull", t);
Assert.assertFalse("t.eIsProxy", t.eIsProxy());
this.helper.assertNoErrors(file);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class JvmModelTests method testJvmTypeParameter_05.
@Test
public void testJvmTypeParameter_05() {
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));
Assert.assertNull(member);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class JvmModelTests method testJvmTypeParameter_07.
@Test
public void testJvmTypeParameter_07() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("def <T> String 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.assertEquals(_plus, 1, member.getTypeParameters().size());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class ValueConverterExceptionProducesErrorTest method assertLiteral.
private void assertLiteral(final String expectation, final Resource resource) {
EObject _head = IterableExtensions.<EObject>head(resource.getContents());
final XtendFile file = ((XtendFile) _head);
final XtendTypeDeclaration type = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _head_1 = IterableExtensions.<XtendMember>head(type.getMembers());
final XtendFunction method = ((XtendFunction) _head_1);
XExpression _expression = method.getExpression();
final RichString body = ((RichString) _expression);
XExpression _head_2 = IterableExtensions.<XExpression>head(body.getExpressions());
final RichStringLiteral singleElement = ((RichStringLiteral) _head_2);
Assert.assertEquals(expectation, singleElement.getValue());
}
use of org.eclipse.xtend.core.xtend.XtendTypeDeclaration in project xtext-xtend by eclipse.
the class NamingTest method testNestedTypes.
@Test
public void testNestedTypes() throws Exception {
XtendFile file = file("class Foo { static class Bar { interface Baz {} annotation FooBar {} } }");
XtendTypeDeclaration foo = file.getXtendTypes().get(0);
assertEquals(QualifiedName.create("Foo"), nameProvider.getFullyQualifiedName(foo));
XtendTypeDeclaration bar = (XtendTypeDeclaration) foo.getMembers().get(0);
assertEquals(QualifiedName.create("Foo", "Bar"), nameProvider.getFullyQualifiedName(bar));
XtendTypeDeclaration baz = (XtendTypeDeclaration) bar.getMembers().get(0);
assertEquals(QualifiedName.create("Foo", "Bar", "Baz"), nameProvider.getFullyQualifiedName(baz));
XtendTypeDeclaration fooBar = (XtendTypeDeclaration) bar.getMembers().get(1);
assertEquals(QualifiedName.create("Foo", "Bar", "FooBar"), nameProvider.getFullyQualifiedName(fooBar));
}
Aggregations