org.eclipse.xtext.resource.IShadowedResourceDescriptions Java Examples

The following examples show how to use org.eclipse.xtext.resource.IShadowedResourceDescriptions. 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: AbstractProjectAwareResourceDescriptionsProvider.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * And if we are in the indexing phase, we don't want to see the local resources.
 */
@Override 
public IResourceDescriptions getResourceDescriptions(ResourceSet resourceSet) {
	IResourceDescriptions result = super.getResourceDescriptions(resourceSet);
	if (compilerPhases.isIndexing(resourceSet)) {
		// during indexing we don't want to see any local files
		String projectName = getProjectName(resourceSet);
		if(projectName != null) {
			final String encodedProjectName = URI.encodeSegment(projectName, true);
			Predicate<URI> predicate = new Predicate<URI>() {
				@Override
				public boolean apply(URI uri) {
					return isProjectLocal(uri, encodedProjectName);
				}

			};
			if (result instanceof IShadowedResourceDescriptions) {
				return new ShadowedFilteringResourceDescriptions(result, predicate);
			} else {
				return new FilteringResourceDescriptions(result, predicate);
			}
		}	
	} 
	return result;
}
 
Example #2
Source File: IndexedJvmTypeAccess.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public EObject getIndexedJvmType(QualifiedName qualifiedName, String fragment, ResourceSet resourceSet, boolean throwShadowedException) throws UnknownNestedTypeException {
	if (resourceSet != null) {
		IResourceDescriptions descriptions = resourceDescriptionsProvider.getResourceDescriptions(resourceSet);
		Iterable<IEObjectDescription> candidates = descriptions.getExportedObjects(TypesPackage.Literals.JVM_TYPE, qualifiedName, false);
		Iterator<IEObjectDescription> iterator = candidates.iterator();
		if (iterator.hasNext()) {
			EObject result = findAccessibleType(fragment, resourceSet, iterator);
			if (result != null) {
				return result;
			}
		}
		if (throwShadowedException && descriptions instanceof IShadowedResourceDescriptions) {
			if (((IShadowedResourceDescriptions) descriptions).isShadowed(TypesPackage.Literals.JVM_TYPE, qualifiedName, false)) {
				throw new ShadowedTypeException("The type '"+qualifiedName+"' is locally shadowed.");
			}
		}
	}
	return null;
}
 
Example #3
Source File: AbstractProjectAwareResourceDescriptionsProvider.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public boolean isShadowed(EClass type, QualifiedName name, boolean ignoreCase) {
	boolean result = ((IShadowedResourceDescriptions) getDelegate()).isShadowed(type, name, ignoreCase);
	return result;
}