org.eclipse.xtext.resource.IResourceServiceProviderExtension Java Examples

The following examples show how to use org.eclipse.xtext.resource.IResourceServiceProviderExtension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ResourceForIEditorInputFactory.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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());
			}
		});
	}
}
 
Example #2
Source File: SourceLevelURICache.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: DefaultResourceUIServiceProvider.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @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;
}
 
Example #4
Source File: XClusteringStorageAwareResourceLoader.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Return true if the given uri must be loaded from source.
 */
protected boolean isSource(URI uri) {
	IResourceServiceProvider provider = context.getResourceServiceProvider(uri);
	return (provider instanceof IResourceServiceProviderExtension
			&& ((IResourceServiceProviderExtension) provider).isSource(uri));
}
 
Example #5
Source File: ClusteringStorageAwareResourceLoader.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Return true if the given uri must be loaded from source.
 */
protected boolean isSource(URI uri) {
	IResourceServiceProvider provider = context.getResourceServiceProvider(uri);
	return provider instanceof IResourceServiceProviderExtension
			&& ((IResourceServiceProviderExtension) provider).isSource(uri);
}