Search in sources :

Example 1 with IResourceServiceProviderExtension

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

the class SourceLevelURICache method getOrComputeIsSource.

public boolean getOrComputeIsSource(URI uri, IResourceServiceProvider.Registry resourceServiceProviderRegistry) {
    if (archives.contains(uri)) {
        return false;
    }
    if (sources.contains(uri)) {
        return true;
    }
    IResourceServiceProvider provider = resourceServiceProviderRegistry.getResourceServiceProvider(uri);
    if (provider instanceof IResourceServiceProviderExtension) {
        if (!((IResourceServiceProviderExtension) provider).isSource(uri)) {
            archives.add(uri);
            return false;
        }
    }
    sources.add(uri);
    return true;
}
Also used : IResourceServiceProvider(org.eclipse.xtext.resource.IResourceServiceProvider) IResourceServiceProviderExtension(org.eclipse.xtext.resource.IResourceServiceProviderExtension)

Example 2 with IResourceServiceProviderExtension

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

the class ResourceForIEditorInputFactory method configureResourceSet.

protected void configureResourceSet(ResourceSet resourceSet, URI primaryURI) {
    // TODO: Filter external content - primary resource should not use dirty state
    externalContentSupport.configureResourceSet(resourceSet, externalContentProvider);
    if (!(resourceServiceProvider instanceof IResourceServiceProviderExtension) || ((IResourceServiceProviderExtension) resourceServiceProvider).isSource(primaryURI)) {
        SourceLevelURIsAdapter.setSourceLevelUris(resourceSet, Collections.singleton(primaryURI));
        resourceSet.eAdapters().add(new ResourceStorageProviderAdapter() {

            @Override
            public ResourceStorageLoadable getResourceStorageLoadable(StorageAwareResource resource) {
                if (!dirtyStateManager.hasContent(resource.getURI())) {
                    return null;
                }
                return ((DirtyStateManager) dirtyStateManager).getResourceStorageLoadable(resource.getURI());
            }
        });
    }
}
Also used : ResourceStorageProviderAdapter(org.eclipse.xtext.resource.persistence.ResourceStorageProviderAdapter) ResourceStorageLoadable(org.eclipse.xtext.resource.persistence.ResourceStorageLoadable) StorageAwareResource(org.eclipse.xtext.resource.persistence.StorageAwareResource) IResourceServiceProviderExtension(org.eclipse.xtext.resource.IResourceServiceProviderExtension)

Example 3 with IResourceServiceProviderExtension

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

the class DefaultResourceUIServiceProvider method isSource.

/**
 * @since 2.9
 */
@Override
public boolean isSource(URI uri) {
    if (delegate instanceof IResourceServiceProviderExtension) {
        if (!((IResourceServiceProviderExtension) delegate).isSource(uri))
            return false;
    }
    if (workspace != null) {
        if (uri.isPlatformResource()) {
            String projectName = URI.decode(uri.segment(1));
            IProject project = workspace.getRoot().getProject(projectName);
            return project.isAccessible();
        }
        if (uri.isPlatformPlugin()) {
            return false;
        }
    }
    Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(uri);
    for (Pair<IStorage, IProject> pair : storages) {
        IStorage storage = pair.getFirst();
        if (storage instanceof IFile) {
            return ((IFile) storage).isAccessible();
        } else {
            return false;
        }
    }
    return true;
}
Also used : IFile(org.eclipse.core.resources.IFile) IStorage(org.eclipse.core.resources.IStorage) IResourceServiceProviderExtension(org.eclipse.xtext.resource.IResourceServiceProviderExtension) IProject(org.eclipse.core.resources.IProject) Pair(org.eclipse.xtext.util.Pair)

Aggregations

IResourceServiceProviderExtension (org.eclipse.xtext.resource.IResourceServiceProviderExtension)3 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IStorage (org.eclipse.core.resources.IStorage)1 IResourceServiceProvider (org.eclipse.xtext.resource.IResourceServiceProvider)1 ResourceStorageLoadable (org.eclipse.xtext.resource.persistence.ResourceStorageLoadable)1 ResourceStorageProviderAdapter (org.eclipse.xtext.resource.persistence.ResourceStorageProviderAdapter)1 StorageAwareResource (org.eclipse.xtext.resource.persistence.StorageAwareResource)1 Pair (org.eclipse.xtext.util.Pair)1