use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class Bug266082Test method _testRedundantImportLarge.
public void _testRedundantImportLarge() {
XtextResourceSet resourceSet = get(XtextResourceSet.class);
resourceSet.setClasspathURIContext(getClass().getClassLoader());
URI uri = URI.createURI("classpath:/org/eclipse/xtext/linking/04.importuritestlanguage");
Resource res = resourceSet.getResource(uri, true);
assertNotNull("res", res);
EcoreUtil.resolveAll(res);
assertFalse(res.getErrors().toString(), res.getErrors().isEmpty());
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class Bug266082Test method testRedundantImport.
@Test
public void testRedundantImport() {
XtextResourceSet resourceSet = get(XtextResourceSet.class);
resourceSet.setClasspathURIContext(getClass().getClassLoader());
URI uri = URI.createURI("classpath:/org/eclipse/xtext/linking/03.importuritestlanguage");
Resource res = resourceSet.getResource(uri, true);
assertNotNull("res", res);
EcoreUtil.resolveAll(res);
assertFalse(res.getErrors().toString(), res.getErrors().isEmpty());
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class Bug266082Test method testManyResolvedImports.
@Test
public void testManyResolvedImports() throws Exception {
StringBuilder model = new StringBuilder(2000);
int max = 100;
for (int i = 1; i <= max; i++) {
model.append("import '" + i + ".importuritestlanguage'\n");
}
model.append("type Foo extends Bar");
final String modelAsString = model.toString();
model = null;
XtextResourceSet resourceSet = get(XtextResourceSet.class);
resourceSet.setClasspathURIContext(getClass().getClassLoader());
final URIConverter converter = resourceSet.getURIConverter();
resourceSet.setURIConverter(new URIConverter() {
@Override
public Map<String, ?> contentDescription(URI uri, Map<?, ?> options) throws IOException {
return converter.contentDescription(uri, options);
}
@Override
public InputStream createInputStream(URI uri) throws IOException {
return new StringInputStream(modelAsString);
}
@Override
public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
return new StringInputStream(modelAsString);
}
@Override
public OutputStream createOutputStream(URI uri) throws IOException {
return converter.createOutputStream(uri);
}
@Override
public OutputStream createOutputStream(URI uri, Map<?, ?> options) throws IOException {
return converter.createOutputStream(uri, options);
}
@Override
public void delete(URI uri, Map<?, ?> options) throws IOException {
converter.delete(uri, options);
}
@Override
public boolean exists(URI uri, Map<?, ?> options) {
return true;
}
@Override
public Map<String, ?> getAttributes(URI uri, Map<?, ?> options) {
return converter.getAttributes(uri, options);
}
@Override
public EList<ContentHandler> getContentHandlers() {
return converter.getContentHandlers();
}
@Override
public URIHandler getURIHandler(URI uri) {
return converter.getURIHandler(uri);
}
@Override
public EList<URIHandler> getURIHandlers() {
return converter.getURIHandlers();
}
@Override
public Map<URI, URI> getURIMap() {
return converter.getURIMap();
}
@Override
public URI normalize(URI uri) {
return converter.normalize(uri);
}
@Override
public void setAttributes(URI uri, Map<String, ?> attributes, Map<?, ?> options) throws IOException {
converter.setAttributes(uri, attributes, options);
}
});
Resource res = resourceSet.getResource(URI.createURI("file:/1.importuritestlanguage"), true);
EcoreUtil.resolveAll(res);
assertEquals(res.getErrors().toString(), 1, res.getErrors().size());
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class Bug287988WithEagerLinkingTest method doGetResource.
@Override
protected XtextResource doGetResource(InputStream in, URI uri) throws Exception {
XtextResourceSet rs = get(XtextResourceSet.class);
rs.setClasspathURIContext(getClass());
XtextResource resource = (XtextResource) factory.createResource(uri);
rs.getResources().add(resource);
resource.load(in, null);
EcoreUtil.resolveAll(resource);
return resource;
}
use of org.eclipse.xtext.resource.XtextResourceSet in project xtext-core by eclipse.
the class IgnoreCaseLinkingWithURIImportsTest method testWithImports.
@Override
@Test
public void testWithImports() throws Exception {
SyntheticModelAwareURIConverter uriConverter = new SyntheticModelAwareURIConverter();
XtextResourceSet resourceSet = get(XtextResourceSet.class);
resourceSet.setURIConverter(uriConverter);
uriConverter.addModel("a.ignorecaseimportstestlanguage", "a A {}");
XtextResource resource = (XtextResource) getResourceFactory().createResource(URI.createURI("b.ignorecaseimportstestlanguage"));
resourceSet.getResources().add(resource);
resource.load(new StringInputStream("'a.ignorecaseimportstestlanguage' b A {}"), null);
EcoreUtil.resolveAll(resource);
assertTrue(resource.getErrors().toString(), resource.getErrors().isEmpty());
}
Aggregations