Java Code Examples for org.eclipse.xtext.resource.IContainer#hasResourceDescription()

The following examples show how to use org.eclipse.xtext.resource.IContainer#hasResourceDescription() . 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: StateBasedContainerManager.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public IContainer getContainer(IResourceDescription desc, IResourceDescriptions resourceDescriptions) {
	if (delegate.shouldUseProjectDescriptionBasedContainers(resourceDescriptions)) {
		return delegate.getContainer(desc, resourceDescriptions);
	}
	String root = internalGetContainerHandle(desc, resourceDescriptions);
	if (root == null) {
		if (log.isDebugEnabled())
			log.debug("Cannot find IContainer for: " + desc.getURI());
		return IContainer.NULL_CONTAINER;
	}
	IContainer result = createContainer(root, resourceDescriptions);
	if (!result.hasResourceDescription(desc.getURI())) {
		// desc has not been saved -> merge containers
		result = new DescriptionAddingContainer(desc, result);
	}
	return result;
}
 
Example 2
Source File: StateBasedContainerManager.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public List<IContainer> getVisibleContainers(IResourceDescription desc, IResourceDescriptions resourceDescriptions) {
	if (delegate.shouldUseProjectDescriptionBasedContainers(resourceDescriptions)) {
		return delegate.getVisibleContainers(desc, resourceDescriptions);
	}
	String root = internalGetContainerHandle(desc, resourceDescriptions);
	if (root == null) {
		if (log.isDebugEnabled())
			log.debug("Cannot find IContainer for: " + desc.getURI());
		return Collections.emptyList();
	}
	List<String> handles = getState(resourceDescriptions).getVisibleContainerHandles(root);
	List<IContainer> result = getVisibleContainers(handles, resourceDescriptions);
	if (!result.isEmpty()) {
		IContainer first = result.get(0);
		if (!first.hasResourceDescription(desc.getURI())) {
			first = new DescriptionAddingContainer(desc, first);
			result.set(0, first);
		}
	}
	return result;
}
 
Example 3
Source File: ExtensionPointAwareScopeProvider.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected IScope createContainerScopeWithContext(final Resource eResource, final IScope parent, final IContainer container, final Predicate<IEObjectDescription> filter, final EClass type, final boolean ignoreCase) {
  IContainer theContainer = container;
  if (eResource != null) {
    URI uriToFilter = eResource.getURI();
    if (container.hasResourceDescription(uriToFilter)) {
      theContainer = new MyFilterUriContainer(uriToFilter, container);
    }
  }
  return createContainerScope(parent, theContainer, filter, type, ignoreCase);
}