use of org.eclipse.xtext.resource.IContainer in project xtext-core by eclipse.
the class DefaultGlobalScopeProvider method getVisibleContainers.
protected List<IContainer> getVisibleContainers(Resource resource) {
IResourceDescription description = descriptionManager.getResourceDescription(resource);
IResourceDescriptions resourceDescriptions = getResourceDescriptions(resource);
String cacheKey = getCacheKey("VisibleContainers", resource.getResourceSet());
OnChangeEvictingCache.CacheAdapter cache = new OnChangeEvictingCache().getOrCreate(resource);
List<IContainer> result = null;
result = cache.get(cacheKey);
if (result == null) {
result = containerManager.getVisibleContainers(description, resourceDescriptions);
// container manager, but it is not aware of a CacheAdapter
if (resourceDescriptions instanceof IResourceDescription.Event.Source) {
IResourceDescription.Event.Source eventSource = (Source) resourceDescriptions;
DelegatingEventSource delegatingEventSource = new DelegatingEventSource(eventSource);
delegatingEventSource.addListeners(Lists.newArrayList(Iterables.filter(result, IResourceDescription.Event.Listener.class)));
delegatingEventSource.initialize();
cache.addCacheListener(delegatingEventSource);
}
cache.set(cacheKey, result);
}
return result;
}
use of org.eclipse.xtext.resource.IContainer in project xtext-core by eclipse.
the class ProjectDescriptionBasedContainerManager method createContainer.
protected IContainer createContainer(final IResourceDescriptions resourceDescriptions, final ChunkedResourceDescriptions chunkedResourceDescriptions, final String projectName) {
IContainer _xifexpression = null;
if ((resourceDescriptions instanceof LiveShadowedChunkedResourceDescriptions)) {
_xifexpression = new LiveShadowedChunkedContainer(((LiveShadowedChunkedResourceDescriptions) resourceDescriptions), projectName);
} else {
ResourceDescriptionsData _elvis = null;
ResourceDescriptionsData _container = chunkedResourceDescriptions.getContainer(projectName);
if (_container != null) {
_elvis = _container;
} else {
Set<IResourceDescription> _emptySet = CollectionLiterals.<IResourceDescription>emptySet();
ResourceDescriptionsData _resourceDescriptionsData = new ResourceDescriptionsData(_emptySet);
_elvis = _resourceDescriptionsData;
}
_xifexpression = new ResourceDescriptionsBasedContainer(_elvis);
}
return _xifexpression;
}
use of org.eclipse.xtext.resource.IContainer in project xtext-core by eclipse.
the class ProjectDescriptionBasedContainerManager method getContainer.
@Override
public IContainer getContainer(final IResourceDescription desc, final IResourceDescriptions resourceDescriptions) {
final ChunkedResourceDescriptions chunkedResourceDescriptions = this.getChunkedResourceDescriptions(resourceDescriptions);
if ((chunkedResourceDescriptions == null)) {
String _name = ChunkedResourceDescriptions.class.getName();
String _plus = ("expected " + _name);
throw new IllegalArgumentException(_plus);
}
final ResourceSet resourceSet = chunkedResourceDescriptions.getResourceSet();
final ProjectDescription projectDescription = ProjectDescription.findInEmfObject(resourceSet);
final IContainer container = this.createContainer(resourceDescriptions, chunkedResourceDescriptions, projectDescription.getName());
return container;
}
use of org.eclipse.xtext.resource.IContainer in project xtext-core by eclipse.
the class ProjectDescriptionBasedContainerManager method getVisibleContainers.
@Override
public List<IContainer> getVisibleContainers(final IResourceDescription desc, final IResourceDescriptions resourceDescriptions) {
final ChunkedResourceDescriptions chunkedResourceDescriptions = this.getChunkedResourceDescriptions(resourceDescriptions);
if ((chunkedResourceDescriptions == null)) {
String _name = ChunkedResourceDescriptions.class.getName();
String _plus = ("expected " + _name);
throw new IllegalArgumentException(_plus);
}
final ResourceSet resourceSet = chunkedResourceDescriptions.getResourceSet();
final ProjectDescription projectDescription = ProjectDescription.findInEmfObject(resourceSet);
final ArrayList<IContainer> allContainers = CollectionLiterals.<IContainer>newArrayList();
allContainers.add(this.createContainer(resourceDescriptions, chunkedResourceDescriptions, projectDescription.getName()));
List<String> _dependencies = projectDescription.getDependencies();
for (final String name : _dependencies) {
allContainers.add(this.createContainer(resourceDescriptions, chunkedResourceDescriptions, name));
}
return allContainers;
}
use of org.eclipse.xtext.resource.IContainer in project xtext-eclipse by eclipse.
the class StateBasedContainerManagerTest method testGetVisibleContainers_02.
@Test
public void testGetVisibleContainers_02() {
IFile file = getFile(project1, "doesNotExist");
URI uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
IResourceDescription description = new URIBasedTestResourceDescription(uri);
List<IContainer> visibleContainers = containerManager.getVisibleContainers(description, this);
assertEquals(2, visibleContainers.size());
assertEquals(3, Iterables.size(visibleContainers.get(0).getResourceDescriptions()));
assertEquals(1, Iterables.size(visibleContainers.get(1).getResourceDescriptions()));
assertNotNull(visibleContainers.get(0).getResourceDescription(uri));
assertNotNull(visibleContainers.get(0).getResourceDescription(uri1));
assertNotNull(visibleContainers.get(0).getResourceDescription(uri2));
assertNotNull(visibleContainers.get(1).getResourceDescription(uri3));
}
Aggregations