use of org.eclipse.xtext.resource.XtextResourceSet 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);
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class FindReferencesTest method getResourceFor.
@Override
public XtextResource getResourceFor(InputStream stream) {
try {
XtextResourceSet set = get(XtextResourceSet.class);
set.setClasspathURIContext(JavaCore.create(project));
XtextResource result = (XtextResource) set.createResource(URI.createURI("Test." + fileExtension));
result.load(stream, null);
return result;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class NoJRESmokeTester method processFile.
@Override
public void processFile(String data) throws Exception {
XtextResourceSet resourceSet = new XtextResourceSet();
NoOpClassLoader classLoader = new NoOpClassLoader();
resourceSet.setClasspathURIContext(classLoader);
ClasspathTypeProviderFactory factory = new ClasspathTypeProviderFactory(classLoader, typeResourceServices);
factory.createTypeProvider(resourceSet);
EObject parsed = parseHelperNoJRE.parse(data, resourceSet);
EcoreUtil.resolveAll(parsed);
checkNoErrorsInValidator(data, (XtextResource) parsed.eResource());
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class AbstractXbaseContentAssistTest method getResourceSet.
protected final XtextResourceSet getResourceSet() {
XtextResourceSet resourceSet = get(XtextResourceSet.class);
IJvmTypeProvider.Factory typeProviderFactory = new JdtTypeProviderFactory(this);
typeProviderFactory.findOrCreateTypeProvider(resourceSet);
resourceSet.setClasspathURIContext(getJavaProject(resourceSet));
return resourceSet;
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-eclipse by eclipse.
the class GrammarParser method parse.
public Grammar parse(String rules) throws IOException {
ResourceSet resourceSet = new XtextResourceSet();
Resource grammarResource = resourceSet.createResource(URI.createURI("Test.xtext"));
grammarResource.load(new StringInputStream("grammar Test with org.eclipse.xtext.common.Terminals \n" + "generate test \"Test\"\n" + rules), null);
EList<EObject> contents = grammarResource.getContents();
assertEquals(1, contents.size());
EObject root = contents.get(0);
assertTrue(root instanceof Grammar);
return (Grammar) root;
}
Aggregations