use of org.eclipse.emf.ecore.resource.URIHandler in project xtext-core by eclipse.
the class ExternalContentSupport method configureConverter.
public void configureConverter(URIConverter converter, IExternalContentProvider contentProvider) {
List<URIHandler> uriHandlers = converter.getURIHandlers();
ListIterator<URIHandler> iter = uriHandlers.listIterator();
while (iter.hasNext()) {
URIHandler transformed = new ExternalContentAwareURIHandler(iter.next(), contentProvider);
iter.set(transformed);
}
}
use of org.eclipse.emf.ecore.resource.URIHandler in project xtext-core by eclipse.
the class AbstractIncrementalBuilderTest method newBuildRequest.
protected BuildRequest newBuildRequest(final Procedure1<? super BuildRequest> init) {
BuildRequest _buildRequest = new BuildRequest();
final Procedure1<BuildRequest> _function = (BuildRequest it) -> {
final ResourceDescriptionsData newIndex = this.indexState.getResourceDescriptions().copy();
it.setBaseDir(this.uri(""));
XtextResourceSet _get = this.resourceSetProvider.get();
final Procedure1<XtextResourceSet> _function_1 = (XtextResourceSet it_1) -> {
it_1.getURIConverter().getURIHandlers().clear();
EList<URIHandler> _uRIHandlers = it_1.getURIConverter().getURIHandlers();
_uRIHandlers.add(this.inMemoryURIHandler);
it_1.setClasspathURIContext(AbstractIncrementalBuilderTest.class.getClassLoader());
ProjectDescription _projectDescription = new ProjectDescription();
final Procedure1<ProjectDescription> _function_2 = (ProjectDescription it_2) -> {
it_2.setName("test-project");
};
final ProjectDescription projectDescription = ObjectExtensions.<ProjectDescription>operator_doubleArrow(_projectDescription, _function_2);
projectDescription.attachToEmfObject(it_1);
Map<String, ResourceDescriptionsData> _emptyMap = CollectionLiterals.<String, ResourceDescriptionsData>emptyMap();
final ChunkedResourceDescriptions index = new ChunkedResourceDescriptions(_emptyMap, it_1);
index.setContainer(projectDescription.getName(), newIndex);
};
XtextResourceSet _doubleArrow = ObjectExtensions.<XtextResourceSet>operator_doubleArrow(_get, _function_1);
it.setResourceSet(_doubleArrow);
it.setDirtyFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
it.setDeletedFiles(Collections.<URI>unmodifiableList(CollectionLiterals.<URI>newArrayList()));
final BuildRequest.IPostValidationCallback _function_2 = (URI uri, Iterable<Issue> issues) -> {
Iterables.<Issue>addAll(this.issues, issues);
return IterableExtensions.isEmpty(issues);
};
it.setAfterValidate(_function_2);
final Procedure1<URI> _function_3 = (URI it_1) -> {
this.deleted.add(it_1);
};
it.setAfterDeleteFile(_function_3);
final Procedure2<URI, URI> _function_4 = (URI source, URI target) -> {
this.generated.put(source, target);
};
it.setAfterGenerateFile(_function_4);
Source2GeneratedMapping _copy = this.indexState.getFileMappings().copy();
IndexState _indexState = new IndexState(newIndex, _copy);
it.setState(_indexState);
};
final BuildRequest result = ObjectExtensions.<BuildRequest>operator_doubleArrow(_buildRequest, _function);
init.apply(result);
return result;
}
use of org.eclipse.emf.ecore.resource.URIHandler 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());
}
Aggregations