Search in sources :

Example 16 with IResourceDescriptions

use of org.eclipse.xtext.resource.IResourceDescriptions in project xtext-core by eclipse.

the class ImportUriGlobalScopeProvider method getScope.

@Override
protected IScope getScope(Resource resource, boolean ignoreCase, EClass type, Predicate<IEObjectDescription> filter) {
    final LinkedHashSet<URI> uniqueImportURIs = getImportedUris(resource);
    IResourceDescriptions descriptions = getResourceDescriptions(resource, uniqueImportURIs);
    List<URI> urisAsList = Lists.newArrayList(uniqueImportURIs);
    Collections.reverse(urisAsList);
    IScope scope = IScope.NULLSCOPE;
    for (URI uri : urisAsList) {
        scope = createLazyResourceScope(scope, uri, descriptions, type, filter, ignoreCase);
    }
    return scope;
}
Also used : IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) IScope(org.eclipse.xtext.scoping.IScope) URI(org.eclipse.emf.common.util.URI)

Example 17 with IResourceDescriptions

use of org.eclipse.xtext.resource.IResourceDescriptions in project xtext-core by eclipse.

the class LiveShadowedChunkedContainerTest method assertGlobalDescriptionsAreUnaffected.

private void assertGlobalDescriptionsAreUnaffected() {
    IResourceDescriptions _globalDescriptions = this.liveShadowedChunkedResourceDescriptions.getGlobalDescriptions();
    final Function1<IEObjectDescription, String> _function = (IEObjectDescription it) -> {
        return it.getQualifiedName().toString();
    };
    Assert.assertEquals("foo", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(((ChunkedResourceDescriptions) _globalDescriptions).getContainer("foo").getExportedObjects(), _function), ","));
    IResourceDescriptions _globalDescriptions_1 = this.liveShadowedChunkedResourceDescriptions.getGlobalDescriptions();
    final Function1<IEObjectDescription, String> _function_1 = (IEObjectDescription it) -> {
        return it.getQualifiedName().toString();
    };
    Assert.assertEquals("bar", IterableExtensions.join(IterableExtensions.<IEObjectDescription, String>map(((ChunkedResourceDescriptions) _globalDescriptions_1).getContainer("bar").getExportedObjects(), _function_1), ","));
}
Also used : IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) LiveShadowedChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.LiveShadowedChunkedResourceDescriptions) ChunkedResourceDescriptions(org.eclipse.xtext.resource.impl.ChunkedResourceDescriptions) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 18 with IResourceDescriptions

use of org.eclipse.xtext.resource.IResourceDescriptions in project xtext-eclipse by eclipse.

the class Bug334456Test method testSameResourceCountForTwoProjects.

@Test
public void testSameResourceCountForTwoProjects() throws Exception {
    IProject fooProject = createPluginProject("foo");
    waitForBuild();
    IResourceDescriptions descriptions = BuilderUtil.getBuilderState();
    int firstSize = Iterables.size(descriptions.getAllResourceDescriptions());
    IProject barProject = createPluginProject("bar");
    waitForBuild();
    descriptions = BuilderUtil.getBuilderState();
    int secondSize = Iterables.size(descriptions.getAllResourceDescriptions());
    assertEquals(firstSize, secondSize);
    barProject.close(null);
    waitForBuild();
    descriptions = BuilderUtil.getBuilderState();
    int thirdSize = Iterables.size(descriptions.getAllResourceDescriptions());
    assertEquals(firstSize, thirdSize);
    fooProject.close(null);
    waitForBuild();
    descriptions = BuilderUtil.getBuilderState();
    int forthSize = Iterables.size(descriptions.getAllResourceDescriptions());
    // no remaining references to archives - fewer entries in index
    assertTrue(firstSize > forthSize);
}
Also used : IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 19 with IResourceDescriptions

use of org.eclipse.xtext.resource.IResourceDescriptions in project xtext-eclipse by eclipse.

the class Bug334456Test method testNoCopiedResourceDescription.

@Test
public void testNoCopiedResourceDescription() throws Exception {
    createPluginProject("foo");
    waitForBuild();
    IResourceDescriptions descriptions = BuilderUtil.getBuilderState();
    assertFalse(Iterables.isEmpty(descriptions.getAllResourceDescriptions()));
    for (IResourceDescription description : descriptions.getAllResourceDescriptions()) {
        if (description instanceof CopiedResourceDescription) {
            fail("Did not expect an instance of copied resource description in builder state");
        }
    }
}
Also used : CopiedResourceDescription(org.eclipse.xtext.builder.clustering.CopiedResourceDescription) IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) Test(org.junit.Test)

Example 20 with IResourceDescriptions

use of org.eclipse.xtext.resource.IResourceDescriptions in project xtext-eclipse by eclipse.

the class BuilderUtil method indexContainsElement.

public static boolean indexContainsElement(final String fileUri, final String eObjectName) {
    IResourceDescriptions descriptions = getBuilderState();
    URI uri = URI.createURI("platform:/resource" + fileUri);
    IResourceDescription description = descriptions.getResourceDescription(uri);
    if (description != null) {
        return description.getExportedObjects(EcorePackage.Literals.EOBJECT, QualifiedName.create(eObjectName), false).iterator().hasNext();
    }
    return false;
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) URI(org.eclipse.emf.common.util.URI)

Aggregations

IResourceDescriptions (org.eclipse.xtext.resource.IResourceDescriptions)46 IResourceDescription (org.eclipse.xtext.resource.IResourceDescription)23 URI (org.eclipse.emf.common.util.URI)18 IEObjectDescription (org.eclipse.xtext.resource.IEObjectDescription)15 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)13 Resource (org.eclipse.emf.ecore.resource.Resource)12 EObject (org.eclipse.emf.ecore.EObject)11 QualifiedName (org.eclipse.xtext.naming.QualifiedName)7 IContainer (org.eclipse.xtext.resource.IContainer)7 List (java.util.List)6 Test (org.junit.Test)6 IN4JSProject (org.eclipse.n4js.projectModel.IN4JSProject)5 IScope (org.eclipse.xtext.scoping.IScope)5 IProject (org.eclipse.core.resources.IProject)4 EClass (org.eclipse.emf.ecore.EClass)4 XtextResource (org.eclipse.xtext.resource.XtextResource)4 IFile (org.eclipse.core.resources.IFile)3 CoreException (org.eclipse.core.runtime.CoreException)3 EPackage (org.eclipse.emf.ecore.EPackage)3 TModule (org.eclipse.n4js.ts.types.TModule)3