use of org.eclipse.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class JvmModelTests method testAnnotationDefaultAssociatedWithJvmOperation.
@Test
public void testAnnotationDefaultAssociatedWithJvmOperation() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotation Foo {");
_builder.newLine();
_builder.append("\t");
_builder.append("val 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);
final JvmAnnotationValue defaultValue = inferred.getDefaultValue();
Assert.assertSame(inferred, defaultValue.getOperation());
} 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 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.xtext.common.types.JvmOperation in project xtext-xtend by eclipse.
the class JvmModelTests method testAnonymousClass_01.
@Test
public void testAnonymousClass_01() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("def foo() {");
_builder.newLine();
_builder.append("\t");
_builder.append("new Runnable() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("int field");
_builder.newLine();
_builder.append("\t\t");
_builder.append("override run() {}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(this.function(_builder.toString()));
this.typeResolver.resolveTypes(operation.eResource());
Assert.assertEquals(1, operation.getLocalClasses().size());
final JvmGenericType anonymous = IterableExtensions.<JvmGenericType>head(operation.getLocalClasses());
Assert.assertTrue(anonymous.isFinal());
Assert.assertFalse(anonymous.isStatic());
Assert.assertTrue(anonymous.isLocal());
Assert.assertFalse(anonymous.isAnonymous());
Assert.assertEquals(JvmVisibility.DEFAULT, anonymous.getVisibility());
Assert.assertEquals(2, anonymous.getSuperTypes().size());
Assert.assertEquals("java.lang.Runnable", IterableExtensions.<JvmTypeReference>last(anonymous.getSuperTypes()).getQualifiedName());
Assert.assertEquals(3, anonymous.getMembers().size());
final JvmMember constructor = IterableExtensions.<JvmMember>last(anonymous.getMembers());
Assert.assertTrue((constructor instanceof JvmConstructor));
Assert.assertEquals(0, ((JvmConstructor) constructor).getParameters().size());
JvmMember _head = IterableExtensions.<JvmMember>head(anonymous.getMembers());
Assert.assertTrue((_head instanceof JvmField));
final JvmMember overriding = anonymous.getMembers().get(1);
Assert.assertTrue((overriding instanceof JvmOperation));
} 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 testAnonymousClass_03.
@Test
public void testAnonymousClass_03() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("def <T> foo() {");
_builder.newLine();
_builder.append("\t");
_builder.append("new Iterable<T>() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("override iterator() {}");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final JvmOperation operation = this._iXtendJvmAssociations.getDirectlyInferredOperation(this.function(_builder.toString()));
this.typeResolver.resolveTypes(operation.eResource());
Assert.assertEquals(1, operation.getLocalClasses().size());
final JvmGenericType anonymous = IterableExtensions.<JvmGenericType>head(operation.getLocalClasses());
Assert.assertTrue(anonymous.isFinal());
Assert.assertFalse(anonymous.isStatic());
Assert.assertTrue(anonymous.isLocal());
Assert.assertTrue(anonymous.isAnonymous());
Assert.assertEquals(0, anonymous.getTypeParameters().size());
Assert.assertEquals(JvmVisibility.DEFAULT, anonymous.getVisibility());
Assert.assertEquals(2, anonymous.getSuperTypes().size());
Assert.assertEquals("java.lang.Iterable<T>", IterableExtensions.<JvmTypeReference>last(anonymous.getSuperTypes()).getQualifiedName());
Assert.assertEquals(2, anonymous.getMembers().size());
final JvmMember constructor = IterableExtensions.<JvmMember>last(anonymous.getMembers());
Assert.assertTrue((constructor instanceof JvmConstructor));
Assert.assertEquals(0, ((JvmConstructor) constructor).getTypeParameters().size());
final JvmMember overriding = IterableExtensions.<JvmMember>head(anonymous.getMembers());
Assert.assertTrue((overriding instanceof JvmOperation));
} 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 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);
}
}
Aggregations