use of org.eclipse.xtext.resource.containers.IAllContainersState in project xtext-core by eclipse.
the class RuntimeResourceSetInitializer method getInitializedResourceSet.
public ResourceSet getInitializedResourceSet(List<String> pathes, UriFilter filter) {
ResourceSet resourceSet = resourceSetProvider.get();
Multimap<String, URI> pathToUriMap = getPathToUriMap(pathes, filter);
IAllContainersState containersState = factory.getContainersState(pathes, pathToUriMap);
resourceSet.eAdapters().add(new DelegatingIAllContainerAdapter(containersState));
for (URI uri : pathToUriMap.values()) {
resourceSet.createResource(uri);
}
return resourceSet;
}
use of org.eclipse.xtext.resource.containers.IAllContainersState in project n4js by eclipse.
the class XcoreReader method invokeInternal.
@Override
protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) {
ResourceSet resourceSet = getResourceSet();
// due to some Xcore peculiarity we have to access the IAllContainerState here
// to trigger some lazy init logic
IAllContainersState allContainerState = (IAllContainersState) EcoreUtil.getAdapter(resourceSet.eAdapters(), IAllContainersState.class);
allContainerState.isEmpty("");
Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes, new Predicate<URI>() {
@Override
public boolean apply(URI input) {
return input.fileExtension().equals(XCORE_FILE_EXT);
}
});
List<Resource> resources = new ArrayList<>();
for (URI uri : uris.values()) {
LOGGER.info(uri);
try {
resources.add(parse(uri, resourceSet));
} catch (Exception e) {
LOGGER.error("Problem during loading of resource @ " + uri, e);
}
}
installIndex(resourceSet);
for (Resource r : resources) {
EcoreUtil.resolveAll(r);
for (Diagnostic x : r.getErrors()) {
issues.addError(x.getMessage(), x);
}
}
ctx.set(slot, resources);
}
use of org.eclipse.xtext.resource.containers.IAllContainersState in project xtext-core by eclipse.
the class Reader method invokeInternal.
@Override
protected void invokeInternal(WorkflowContext ctx, ProgressMonitor monitor, Issues issues) {
ResourceSet resourceSet = getResourceSet();
Multimap<String, URI> uris = getPathTraverser().resolvePathes(pathes, new Predicate<URI>() {
@Override
public boolean apply(URI input) {
boolean result = true;
if (getUriFilter() != null)
result = getUriFilter().matches(input);
if (result)
result = getRegistry().getResourceServiceProvider(input) != null;
return result;
}
});
IAllContainersState containersState = containersStateFactory.getContainersState(pathes, uris);
installAsAdapter(resourceSet, containersState);
populateResourceSet(resourceSet, uris);
getValidator().validate(resourceSet, getRegistry(), issues);
addModelElementsToContext(ctx, resourceSet);
}
use of org.eclipse.xtext.resource.containers.IAllContainersState in project xtext-eclipse by eclipse.
the class LiveShadowedAllContainerStateTest method formatContainers.
private String formatContainers(final ResourceSet rs) {
String _xblockexpression = null;
{
final IResourceDescriptions resourceDescriptions = this.resourceDescriptionProvider.getResourceDescriptions(rs);
final IAllContainersState containerState = this.containerStateProvider.get(resourceDescriptions);
final Function1<Resource, URI> _function = (Resource it) -> {
return it.getURI();
};
final Set<URI> allURIs = IterableExtensions.<URI>toSet(ListExtensions.<Resource, URI>map(rs.getResources(), _function));
final Function1<URI, String> _function_1 = (URI it) -> {
return containerState.getContainerHandle(it);
};
final Set<String> allContainers = IterableExtensions.<String>toSet(IterableExtensions.<String>filterNull(IterableExtensions.<URI, String>map(allURIs, _function_1)));
final Function1<IProject, String> _function_2 = (IProject it) -> {
return it.getName();
};
List<String> _map = ListExtensions.<IProject, String>map(((List<IProject>) Conversions.doWrapArray(ResourcesPlugin.getWorkspace().getRoot().getProjects())), _function_2);
Iterables.<String>addAll(allContainers, _map);
StringConcatenation _builder = new StringConcatenation();
{
for (final String container : allContainers) {
_builder.append("container ");
_builder.append(container);
_builder.append(" isEmpty=");
boolean _isEmpty = containerState.isEmpty(container);
_builder.append(_isEmpty);
_builder.append(" {");
_builder.newLineIfNotEmpty();
{
final Function1<URI, String> _function_3 = (URI it) -> {
return it.toString();
};
List<URI> _sortBy = IterableExtensions.<URI, String>sortBy(containerState.getContainedURIs(container), _function_3);
for (final URI uri : _sortBy) {
_builder.append("\t");
_builder.append("resourceURI=");
_builder.append(uri, "\t");
_builder.append(" exported=[");
final Function1<IEObjectDescription, QualifiedName> _function_4 = (IEObjectDescription it) -> {
return it.getName();
};
String _join = IterableExtensions.join(IterableExtensions.<IEObjectDescription, QualifiedName>map(resourceDescriptions.getResourceDescription(uri).getExportedObjects(), _function_4), ", ");
_builder.append(_join, "\t");
_builder.append("]");
_builder.newLineIfNotEmpty();
}
}
_builder.append("}");
_builder.newLine();
}
}
_xblockexpression = _builder.toString();
}
return _xblockexpression;
}
use of org.eclipse.xtext.resource.containers.IAllContainersState in project xtext-eclipse by eclipse.
the class PersistableResourceDescriptionsTest method createResourceSet.
public ResourceSet createResourceSet() {
ResourceSetImpl resourceSetImpl = new ResourceSetImpl();
resourceSetImpl.setURIConverter(uriConverter);
resourceSetImpl.eAdapters().add(new DelegatingIAllContainerAdapter(new IAllContainersState() {
@Override
public List<String> getVisibleContainerHandles(String handle) {
return null;
}
@Override
public Collection<URI> getContainedURIs(String containerHandle) {
return null;
}
@Override
public String getContainerHandle(URI uri) {
return null;
}
@Override
public boolean isEmpty(String containerHandle) {
return true;
}
}));
return resourceSetImpl;
}
Aggregations