use of com.avaloq.tools.ddk.xtext.resource.AbstractCachingResourceDescriptionManager in project dsl-devkit by dsldevkit.
the class MonitoredClusteringBuilderState method queueAffectedResources.
/**
* {@inheritDoc}
*/
@Override
protected void queueAffectedResources(final Set<URI> allRemainingURIs, final IResourceDescriptions oldState, final CurrentDescriptions newState, final Collection<Delta> changedDeltas, final Collection<Delta> allDeltas, final BuildData buildData, final IProgressMonitor monitor) {
if (allDeltas.isEmpty() || allRemainingURIs.isEmpty()) {
return;
}
ImmutableListMultimap<Manager, URI> candidatesByManager = getUrisByManager(allRemainingURIs);
FindReferenceCachingState cachingIndex = new FindReferenceCachingState((IResourceDescriptions2) newState);
final SubMonitor progressMonitor = SubMonitor.convert(monitor, candidatesByManager.keySet().size());
for (Manager manager : candidatesByManager.keySet()) {
Collection<Delta> deltas = changedDeltas;
if (manager instanceof IResourceDescription.Manager.AllChangeAware) {
deltas = allDeltas;
}
try {
if (manager instanceof AbstractCachingResourceDescriptionManager) {
checkForCancellation(monitor);
AbstractCachingResourceDescriptionManager bulkManager = (AbstractCachingResourceDescriptionManager) manager;
Set<URI> candidates = Sets.newHashSet(candidatesByManager.get(bulkManager));
candidates.retainAll(allRemainingURIs);
Collection<URI> affected = bulkManager.getAffectedResources(deltas, candidates, cachingIndex);
for (URI uri : affected) {
if (allRemainingURIs.remove(uri)) {
buildData.queueURI(uri);
}
}
} else {
for (URI candidateURI : candidatesByManager.get(manager)) {
checkForCancellation(monitor);
if (allRemainingURIs.contains(candidateURI)) {
boolean affected = false;
if (manager instanceof IResourceDescription.Manager.AllChangeAware) {
affected = ((IResourceDescription.Manager.AllChangeAware) manager).isAffectedByAny(deltas, oldState.getResourceDescription(candidateURI), cachingIndex);
} else {
affected = manager.isAffected(deltas, oldState.getResourceDescription(candidateURI), cachingIndex);
}
if (affected) {
allRemainingURIs.remove(candidateURI);
buildData.queueURI(candidateURI);
}
}
}
}
} catch (OperationCanceledException e) {
throw e;
// CHECKSTYLE:CHECK-OFF IllegalCatch - Failing here means the build fails completely
} catch (Throwable t) {
// CHECKSTYLE:CHECK-ON IllegalCatch
// $NON-NLS-1$
LOGGER.warn(manager.getClass().getSimpleName() + " failed to enqueue the affected resources", t);
}
progressMonitor.worked(1);
if (allRemainingURIs.isEmpty()) {
break;
}
}
}
use of com.avaloq.tools.ddk.xtext.resource.AbstractCachingResourceDescriptionManager in project dsl-devkit by dsldevkit.
the class CheckCfgUtil method getAllLanguages.
/**
* Gets the all languages available in the workbench.
*
* @return set of all languages
*/
public Set<String> getAllLanguages() {
Set<String> languages = new HashSet<String>();
for (String extension : Registry.INSTANCE.getExtensionToFactoryMap().keySet()) {
final URI dummyUri = URI.createURI("foo:/foo." + extension);
IResourceServiceProvider resourceServiceProvider = Registry.INSTANCE.getResourceServiceProvider(dummyUri);
// By checking that description manager is AbstractCachingResourceDescriptionManager we exclude technical languages of the framework
if (resourceServiceProvider != null && resourceServiceProvider.getResourceDescriptionManager() instanceof AbstractCachingResourceDescriptionManager) {
try {
IGrammarAccess grammarAccess = resourceServiceProvider.get(IGrammarAccess.class);
if (grammarAccess != null && grammarAccess.getGrammar() != null) {
languages.add(grammarAccess.getGrammar().getName());
}
} catch (ConfigurationException e) {
// Will happen if no binding for IGrammarAccess was present.
}
}
}
return languages;
}
Aggregations