use of org.eclipse.xtext.util.OnChangeEvictingCache 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.util.OnChangeEvictingCache in project xtext-core by eclipse.
the class KeywordInspectorTest method validateRule.
public void validateRule(AbstractRule rule) {
assertNotNull("rule", rule);
warnings.clear();
KeywordInspector inspector = new KeywordInspector(this, new OnChangeEvictingCache());
Iterator<Keyword> keywords = Iterators.filter(EcoreUtil.getAllContents(rule, true), Keyword.class);
while (keywords.hasNext()) inspector.inspectKeywordHidesTerminalRule(keywords.next());
}
Aggregations