Search in sources :

Example 6 with IAllContainersState

use of org.eclipse.xtext.resource.containers.IAllContainersState in project xtext-eclipse by eclipse.

the class LiveShadowedAllContainerStateTest method formatContainers.

private String formatContainers(ResourceSet rs) {
    IResourceDescriptions resourceDescriptions = resourceDescriptionProvider.getResourceDescriptions(rs);
    IAllContainersState containerState = containerStateProvider.get(resourceDescriptions);
    Set<URI> allURIs = Sets.newHashSet(Iterables.transform(rs.getResources(), Resource::getURI));
    Set<String> allContainers = Sets.newHashSet((Iterables.filter(Iterables.transform(allURIs, it -> containerState.getContainerHandle(it)), Predicates.notNull())));
    for (IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
        allContainers.add(p.getName());
    }
    StringBuilder builder = new StringBuilder();
    for (String container : allContainers) {
        builder.append("container ");
        builder.append(container);
        builder.append(" isEmpty=");
        builder.append(containerState.isEmpty(container));
        builder.append(" {\n");
        for (URI uri : IterableExtensions.sortBy(containerState.getContainedURIs(container), URI::toString)) {
            builder.append("	resourceURI=");
            builder.append(uri);
            builder.append(" exported=[");
            builder.append(Joiner.on(", ").join(Iterables.transform(resourceDescriptions.getResourceDescription(uri).getExportedObjects(), IEObjectDescription::getName)));
            builder.append("]\n");
        }
        builder.append("}\n");
    }
    return builder.toString();
}
Also used : IAllContainersState(org.eclipse.xtext.resource.containers.IAllContainersState) IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) XtextProjectHelper(org.eclipse.xtext.ui.XtextProjectHelper) StringInputStream(org.eclipse.xtext.util.StringInputStream) Iterables(com.google.common.collect.Iterables) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) URI(org.eclipse.emf.common.util.URI) XtextLiveScopeResourceSetProvider(org.eclipse.xtext.ui.resource.XtextLiveScopeResourceSetProvider) Inject(com.google.inject.Inject) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IProject(org.eclipse.core.resources.IProject) IResourcesSetupUtil(org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil) After(org.junit.After) Predicates(com.google.common.base.Predicates) Before(org.junit.Before) FileExtensionProvider(org.eclipse.xtext.resource.FileExtensionProvider) TestsActivator(org.eclipse.xtext.ui.tests.internal.TestsActivator) Set(java.util.Set) IAllContainersState(org.eclipse.xtext.resource.containers.IAllContainersState) Test(org.junit.Test) Sets(com.google.common.collect.Sets) ResourceDescriptionsProvider(org.eclipse.xtext.resource.impl.ResourceDescriptionsProvider) IterableExtensions(org.eclipse.xtext.xbase.lib.IterableExtensions) Resource(org.eclipse.emf.ecore.resource.Resource) Assert(org.junit.Assert) Collections(java.util.Collections) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) Joiner(com.google.common.base.Joiner) IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) URI(org.eclipse.emf.common.util.URI) IProject(org.eclipse.core.resources.IProject) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Aggregations

URI (org.eclipse.emf.common.util.URI)6 IAllContainersState (org.eclipse.xtext.resource.containers.IAllContainersState)6 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)4 Resource (org.eclipse.emf.ecore.resource.Resource)2 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)2 DelegatingIAllContainerAdapter (org.eclipse.xtext.resource.containers.DelegatingIAllContainerAdapter)2 Joiner (com.google.common.base.Joiner)1 Predicates (com.google.common.base.Predicates)1 Iterables (com.google.common.collect.Iterables)1 Sets (com.google.common.collect.Sets)1 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Set (java.util.Set)1 IProject (org.eclipse.core.resources.IProject)1 ResourcesPlugin (org.eclipse.core.resources.ResourcesPlugin)1 Diagnostic (org.eclipse.emf.ecore.resource.Resource.Diagnostic)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 FileExtensionProvider (org.eclipse.xtext.resource.FileExtensionProvider)1 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)1