Search in sources :

Example 1 with IResourceDescriptions

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

the class OpenCallHierarchyHandler method createHierarchyBuilder.

@Override
protected IHierarchyBuilder createHierarchyBuilder(final EObject target) {
    final ArithmeticsCallHierarchyBuilder xtextCallHierarchyBuilder = this._iGlobalServiceProvider.<ArithmeticsCallHierarchyBuilder>findService(target, ArithmeticsCallHierarchyBuilder.class);
    xtextCallHierarchyBuilder.setResourceAccess(this.resourceAccess);
    xtextCallHierarchyBuilder.setIndexData(this._iGlobalServiceProvider.<IResourceDescriptions>findService(target, IResourceDescriptions.class));
    final DeferredHierarchyBuilder deferredHierarchyBuilder = this._iGlobalServiceProvider.<DeferredHierarchyBuilder>findService(target, DeferredHierarchyBuilder.class);
    deferredHierarchyBuilder.setHierarchyBuilder(xtextCallHierarchyBuilder);
    return deferredHierarchyBuilder;
}
Also used : ArithmeticsCallHierarchyBuilder(org.eclipse.xtext.example.arithmetics.ui.editor.hierarchy.ArithmeticsCallHierarchyBuilder) IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) DeferredHierarchyBuilder(org.eclipse.xtext.ui.editor.hierarchy.DeferredHierarchyBuilder)

Example 2 with IResourceDescriptions

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

the class WorkingCopyOwnerProvider method getWorkingCopyOwner.

@Override
public WorkingCopyOwner getWorkingCopyOwner(final IJavaProject javaProject, final ResourceSet resourceSet) {
    return new WorkingCopyOwner() {

        @Override
        public String findSource(String typeName, String packageName) {
            if (packageName.startsWith("java"))
                return super.findSource(typeName, packageName);
            QualifiedName qn = toQualifiedName(packageName, typeName);
            final IResourceDescriptions descriptions = descriptionsProvider.getResourceDescriptions(resourceSet);
            Iterator<IEObjectDescription> exportedObjects = descriptions.getExportedObjects(TypesPackage.Literals.JVM_DECLARED_TYPE, qn, false).iterator();
            while (exportedObjects.hasNext()) {
                IEObjectDescription candidate = exportedObjects.next();
                URI uri = candidate.getEObjectURI();
                if (uri.isPlatformResource() && URI.decode(uri.segment(1)).equals(javaProject.getElementName())) {
                    IResourceDescription resourceDescription = descriptions.getResourceDescription(uri.trimFragment());
                    return getSource(typeName, packageName, candidate, resourceSet, resourceDescription);
                }
            }
            return super.findSource(typeName, packageName);
        }

        /**
         * not implemented because we don't have a proper index for Java package names and the very rare cases in which this would
         * cause trouble are not worth the general degrade in performance.
         */
        @Override
        public boolean isPackage(String[] pkg) {
            return super.isPackage(pkg);
        }
    };
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) WorkingCopyOwner(org.eclipse.jdt.core.WorkingCopyOwner) QualifiedName(org.eclipse.xtext.naming.QualifiedName) IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) URI(org.eclipse.emf.common.util.URI) IEObjectDescription(org.eclipse.xtext.resource.IEObjectDescription)

Example 3 with IResourceDescriptions

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

the class QueryParticipant method createSearchHelper.

protected JavaSearchHelper createSearchHelper(ISearchRequestor requestor) {
    JavaSearchHelper searchHelper = javaSearchHelperProvider.get();
    IResourceDescriptions descriptionsToSearch = resourceDescriptionsProvider.get();
    if (descriptionsToSearch.isEmpty()) {
        waitForBuild();
        descriptionsToSearch = resourceDescriptionsProvider.get();
    }
    searchHelper.init(requestor, descriptionsToSearch);
    return searchHelper;
}
Also used : IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions)

Example 4 with IResourceDescriptions

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

the class AbstractScopeResourceDescriptionsTest method assertExportedObject.

protected void assertExportedObject(Resource resource, String name) {
    IResourceDescriptions resourceDescriptions = resourceDescriptionsProvider.getResourceDescriptions(resource);
    IResourceDescription resourceDescription = resourceDescriptions.getResourceDescription(resource.getURI());
    assertNotNull(resourceDescription);
    QualifiedName qname = QualifiedName.create(name);
    assertFalse(isEmpty(resourceDescription.getExportedObjects(EcorePackage.Literals.EOBJECT, qname, false)));
}
Also used : IResourceDescription(org.eclipse.xtext.resource.IResourceDescription) IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) QualifiedName(org.eclipse.xtext.naming.QualifiedName)

Example 5 with IResourceDescriptions

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

the class OpenCallHierarchyHandler method createHierarchyBuilder.

@Override
protected IHierarchyBuilder createHierarchyBuilder(final EObject target) {
    final XtextCallHierarchyBuilder xtextCallHierarchyBuilder = this._iGlobalServiceProvider.<XtextCallHierarchyBuilder>findService(target, XtextCallHierarchyBuilder.class);
    xtextCallHierarchyBuilder.setResourceAccess(this.resourceAccess);
    xtextCallHierarchyBuilder.setIndexData(this._iGlobalServiceProvider.<IResourceDescriptions>findService(target, IResourceDescriptions.class));
    final DeferredHierarchyBuilder deferredHierarchyBuilder = this._iGlobalServiceProvider.<DeferredHierarchyBuilder>findService(target, DeferredHierarchyBuilder.class);
    deferredHierarchyBuilder.setHierarchyBuilder(xtextCallHierarchyBuilder);
    return deferredHierarchyBuilder;
}
Also used : IResourceDescriptions(org.eclipse.xtext.resource.IResourceDescriptions) XtextCallHierarchyBuilder(org.eclipse.xtext.ui.editor.hierarchy.XtextCallHierarchyBuilder) DeferredHierarchyBuilder(org.eclipse.xtext.ui.editor.hierarchy.DeferredHierarchyBuilder)

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