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;
}
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());
}
});
}
}
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;
}
Aggregations