use of org.eclipse.xtext.resource.containers.IContainerState in project dsl-devkit by dsldevkit.
the class CachingStateBasedContainerManager method createContainer.
@Override
protected synchronized IContainer createContainer(final String handle, final IResourceDescriptions resourceDescriptions) {
final IResourceDescriptions descriptionsKey = resourceDescriptions instanceof CurrentDescriptions2.ResourceSetAware ? ((CurrentDescriptions2.ResourceSetAware) resourceDescriptions).getDelegate() : resourceDescriptions;
Map<String, WeakReference<IContainer>> containersMap = descriptionsContainersCache.get(descriptionsKey);
if (containersMap == null) {
containersMap = new HashMap<String, WeakReference<IContainer>>();
descriptionsContainersCache.put(descriptionsKey, containersMap);
}
WeakReference<IContainer> containerRef = containersMap.get(handle);
IContainer container = containerRef != null ? containerRef.get() : null;
if (container == null) {
final IContainerState containerState = new ContainerState(handle, getStateProvider().get(descriptionsKey));
container = new StateBasedContainerWithHandle(descriptionsKey, containerState, handle);
new CacheInvalidator(descriptionsKey, handle, containerState);
containerRef = new WeakReference<IContainer>(container);
containersMap.put(handle, containerRef);
}
return container;
}
Aggregations