Search in sources :

Example 1 with MockAcceptor

use of org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor 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);
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) MockAcceptor(org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) Test(org.junit.Test)

Example 2 with MockAcceptor

use of org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor in project xtext-xtend by eclipse.

the class FindReferencesTest method testFindReferencesThis.

@Test
public void testFindReferencesThis() throws Exception {
    XtendClass classFoo = (XtendClass) testHelper.xtendFile("Foo", "class Foo { def foo() {this} }").getXtendTypes().get(0);
    waitForBuild();
    JvmGenericType inferredType = associations.getInferredType(classFoo);
    XtendFunction functionFoo = (XtendFunction) classFoo.getMembers().get(0);
    final MockAcceptor mockAcceptor = new MockAcceptor();
    mockAcceptor.expect(((XBlockExpression) functionFoo.getExpression()).getExpressions().get(0), inferredType, XABSTRACT_FEATURE_CALL__FEATURE);
    findReferencesTester.checkFindReferences(inferredType, "Java References to Foo (/test.project/src/Foo.xtend)", mockAcceptor);
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) MockAcceptor(org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 3 with MockAcceptor

use of org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor in project xtext-xtend by eclipse.

the class FindReferencesTest method testFindReferencesToAnonymousSuperType.

@Test
public void testFindReferencesToAnonymousSuperType() 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);
    JvmGenericType inferredTypeFoo = associations.getInferredType(classFoo);
    final MockAcceptor mockAcceptor = new MockAcceptor();
    mockAcceptor.expect(((AnonymousClass) fieldFoo.getInitialValue()).getConstructorCall(), inferredTypeFoo, XCONSTRUCTOR_CALL__CONSTRUCTOR);
    findReferencesTester.checkFindReferences(inferredTypeFoo, "Java References to Foo (/test.project/src/Foo.xtend)", mockAcceptor);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) MockAcceptor(org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) XtendField(org.eclipse.xtend.core.xtend.XtendField) Test(org.junit.Test)

Example 4 with MockAcceptor

use of org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor in project xtext-xtend by eclipse.

the class FindReferencesTest method testFindReferencesTypeLiteral.

@Test
public void testFindReferencesTypeLiteral() throws Exception {
    XtendClass classFoo = (XtendClass) testHelper.xtendFile("Foo", "class Foo { def foo() { Foo } }").getXtendTypes().get(0);
    waitForBuild();
    JvmGenericType inferredType = associations.getInferredType(classFoo);
    XtendFunction functionFoo = (XtendFunction) classFoo.getMembers().get(0);
    final MockAcceptor mockAcceptor = new MockAcceptor();
    mockAcceptor.expect(((XBlockExpression) functionFoo.getExpression()).getExpressions().get(0), inferredType, XABSTRACT_FEATURE_CALL__FEATURE);
    findReferencesTester.checkFindReferences(inferredType, "Java References to Foo (/test.project/src/Foo.xtend)", mockAcceptor);
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) MockAcceptor(org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Example 5 with MockAcceptor

use of org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor in project xtext-xtend by eclipse.

the class FindReferencesTest method testFindReferencesTypeLiteralWithPackageFragment.

@Test
public void testFindReferencesTypeLiteralWithPackageFragment() throws Exception {
    XtendClass classFoo = (XtendClass) testHelper.xtendFile("Foo", "package com.acme class Foo { def foo() { com.acme.Foo } }").getXtendTypes().get(0);
    waitForBuild();
    JvmGenericType inferredType = associations.getInferredType(classFoo);
    XtendFunction functionFoo = (XtendFunction) classFoo.getMembers().get(0);
    final MockAcceptor mockAcceptor = new MockAcceptor();
    mockAcceptor.expect(((XBlockExpression) functionFoo.getExpression()).getExpressions().get(0), inferredType, XABSTRACT_FEATURE_CALL__FEATURE);
    findReferencesTester.checkFindReferences(inferredType, "Java References to com.acme.Foo (/test.project/src/Foo.xtend)", mockAcceptor);
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) MockAcceptor(org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) Test(org.junit.Test)

Aggregations

XtendClass (org.eclipse.xtend.core.xtend.XtendClass)11 MockAcceptor (org.eclipse.xtend.ide.tests.findrefs.FindReferencesTestUtil.MockAcceptor)11 Test (org.junit.Test)11 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)7 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)7 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)5 XtendField (org.eclipse.xtend.core.xtend.XtendField)3 JvmConstructor (org.eclipse.xtext.common.types.JvmConstructor)3 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)1