Search in sources :

Example 1 with MockAcceptor

use of org.eclipse.xtext.xbase.ui.testing.FindReferencesTestUtil.MockAcceptor in project xtext-eclipse by eclipse.

the class FindReferencesTest method testFindReferencesTypeLiteralTwice.

@Test
public void testFindReferencesTypeLiteralTwice() throws Exception {
    createFile("find.references.test/src/Test." + fileExtension, "com.acme.OtherwiseUnused != com.acme.OtherwiseUnused");
    waitForBuild();
    XtextResourceSet set = get(XtextResourceSet.class);
    set.setClasspathURIContext(JavaCore.create(project));
    Resource resource = set.getResource(URI.createPlatformResourceURI("find.references.test/src/Test." + fileExtension, true), true);
    // obtain reference to type
    XBinaryOperation expression = (XBinaryOperation) resource.getContents().get(0);
    JvmType lookup = (JvmType) ((XAbstractFeatureCall) expression.getLeftOperand()).getFeature();
    final MockAcceptor mockAcceptor = new MockAcceptor();
    mockAcceptor.expect(expression.getLeftOperand(), lookup, XABSTRACT_FEATURE_CALL__FEATURE);
    mockAcceptor.expect(expression.getRightOperand(), lookup, XABSTRACT_FEATURE_CALL__FEATURE);
    findReferencesTester.checkFindReferences(lookup, "Java References to com.acme.OtherwiseUnused", mockAcceptor);
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) MockAcceptor(org.eclipse.xtext.xbase.ui.testing.FindReferencesTestUtil.MockAcceptor) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) XBinaryOperation(org.eclipse.xtext.xbase.XBinaryOperation) JvmType(org.eclipse.xtext.common.types.JvmType) Test(org.junit.Test)

Example 2 with MockAcceptor

use of org.eclipse.xtext.xbase.ui.testing.FindReferencesTestUtil.MockAcceptor in project xtext-eclipse by eclipse.

the class FindReferencesTest method testFindReferencesTypeLiteral.

@Test
public void testFindReferencesTypeLiteral() throws Exception {
    createFile("find.references.test/src/Test." + fileExtension, "com.acme.OtherwiseUnused::m()");
    waitForBuild();
    XtextResourceSet set = get(XtextResourceSet.class);
    set.setClasspathURIContext(JavaCore.create(project));
    Resource resource = set.getResource(URI.createPlatformResourceURI("find.references.test/src/Test." + fileExtension, true), true);
    // obtain reference to type
    XMemberFeatureCall expression = (XMemberFeatureCall) resource.getContents().get(0);
    JvmType lookup = (JvmType) ((XAbstractFeatureCall) expression.getMemberCallTarget()).getFeature();
    final MockAcceptor mockAcceptor = new MockAcceptor();
    mockAcceptor.expect(expression.getMemberCallTarget(), lookup, XABSTRACT_FEATURE_CALL__FEATURE);
    findReferencesTester.checkFindReferences(lookup, "Java References to com.acme.OtherwiseUnused", mockAcceptor);
}
Also used : XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) MockAcceptor(org.eclipse.xtext.xbase.ui.testing.FindReferencesTestUtil.MockAcceptor) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) JvmType(org.eclipse.xtext.common.types.JvmType) Test(org.junit.Test)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)2 JvmType (org.eclipse.xtext.common.types.JvmType)2 XtextResource (org.eclipse.xtext.resource.XtextResource)2 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)2 MockAcceptor (org.eclipse.xtext.xbase.ui.testing.FindReferencesTestUtil.MockAcceptor)2 Test (org.junit.Test)2 XBinaryOperation (org.eclipse.xtext.xbase.XBinaryOperation)1 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)1