use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class EObjectLocationTests method testResolveAnonymousClassConstructorCall_3.
@Test
public void testResolveAnonymousClassConstructorCall_3() throws Exception {
String model = "class Foo { val bar = new Bar('') {} } class Bar { new(String x) {} new() {} }";
XtendFile file = file(model);
XtextResource resource = (XtextResource) file.eResource();
EObject constructor = eObjectAtOffsetHelper.resolveCrossReferencedElementAt(resource, model.indexOf("Bar"));
assertTrue(constructor instanceof JvmConstructor);
assertEquals("Bar", ((JvmConstructor) constructor).getDeclaringType().getSimpleName());
assertEquals(1, ((JvmConstructor) constructor).getParameters().size());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testInferredFunctionWithReturnType_02.
@Test
public void testInferredFunctionWithReturnType_02() throws Exception {
XtendFile xtendFile = file("class Foo { def Iterable<String> create result: newArrayList newList() {} }");
JvmGenericType inferredType = getInferredType(xtendFile);
assertTrue(inferredType.getMembers().get(0) instanceof JvmConstructor);
JvmOperation jvmOperation = (JvmOperation) inferredType.getMembers().get(1);
XtendFunction xtendFunction = (XtendFunction) ((XtendClass) xtendFile.getXtendTypes().get(0)).getMembers().get(0);
assertFalse(xtendFunction.getReturnType() == jvmOperation.getReturnType());
assertEquals(xtendFunction.getReturnType().getType(), jvmOperation.getReturnType().getType());
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testInferredJvmConstructor.
@Test
public void testInferredJvmConstructor() throws Exception {
XtendFile xtendFile = file("class Foo { }");
JvmGenericType inferredType = getInferredType(xtendFile);
XtendClass xtendClass = (XtendClass) xtendFile.getXtendTypes().get(0);
assertEquals(1, inferredType.getMembers().size());
JvmMember inferredFirstMember = inferredType.getMembers().get(0);
assertTrue(inferredFirstMember instanceof JvmConstructor);
assertEquals(JvmVisibility.PUBLIC, inferredFirstMember.getVisibility());
assertEquals(associations.getInferredConstructor(xtendClass), inferredFirstMember);
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class FindReferencesTest method testFindReferencesToConstructor.
@Test
public void testFindReferencesToConstructor() throws Exception {
XtendClass classFoo = (XtendClass) testHelper.xtendFile("Foo", "class Foo {}").getXtendTypes().get(0);
XtendClass classBar = (XtendClass) testHelper.xtendFile("Bar", "class Bar { def bar() {new Foo()} }").getXtendTypes().get(0);
waitForBuild();
JvmConstructor inferredConstructor = associations.getInferredConstructor(classFoo);
XtendFunction functionBar = (XtendFunction) classBar.getMembers().get(0);
final MockAcceptor mockAcceptor = new MockAcceptor();
mockAcceptor.expect(((XBlockExpression) functionBar.getExpression()).getExpressions().get(0), inferredConstructor, XCONSTRUCTOR_CALL__CONSTRUCTOR);
findReferencesTester.checkFindReferences(classFoo, "Java References to Foo (/test.project/src/Foo.xtend)", mockAcceptor);
}
use of org.eclipse.xtext.common.types.JvmConstructor in project xtext-xtend by eclipse.
the class FindReferencesTest method testFindReferencesToAnonymousImplicitSuperConstructor.
@Test
public void testFindReferencesToAnonymousImplicitSuperConstructor() throws Exception {
XtendClass classFoo = (XtendClass) testHelper.xtendFile("Foo", "class Foo {}").getXtendTypes().get(0);
XtendClass classBar = (XtendClass) testHelper.xtendFile("Bar", "class Bar { val foo = new Foo{} }").getXtendTypes().get(0);
waitForBuild();
XtendField fieldFoo = (XtendField) classBar.getMembers().get(0);
JvmConstructor inferredConstructor = associations.getInferredConstructor(classFoo);
final MockAcceptor mockAcceptor = new MockAcceptor();
mockAcceptor.expect(((AnonymousClass) fieldFoo.getInitialValue()).getConstructorCall(), inferredConstructor, XCONSTRUCTOR_CALL__CONSTRUCTOR);
findReferencesTester.checkFindReferences(inferredConstructor, "Java References to Foo (/test.project/src/Foo.xtend)", mockAcceptor);
}
Aggregations