Skip to content

Commit 3537c2f

Browse files
authored
Merge pull request #290 from mrubanov/mastercheckfix
Fix building of Check projects
2 parents 1326770 + e01333e commit 3537c2f

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

com.avaloq.tools.ddk.xtext.builder/src/com/avaloq/tools/ddk/xtext/builder/MonitoredClusteringBuilderState.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ protected IResourceDescription getSavedResourceDescription(final Map<URI, IResou
824824
if (saved == null) {
825825
// TODO DSL-828: this may end up using a lot of memory; we should instead consider creating old copies of the resources in the db
826826
IResourceDescription old = getResourceDescription(uri);
827-
saved = old != null ? new FingerprintResourceDescription(old) : null;
827+
saved = old != null ? createOldStateResourceDescription(old) : null;
828828
} else if (saved == NULL_DESCRIPTION) { // NOPMD
829829
saved = null; // NOPMD
830830
}
@@ -842,11 +842,30 @@ protected Map<URI, IResourceDescription> saveOldDescriptions(final BuildData bui
842842
Map<URI, IResourceDescription> cache = Maps.newHashMapWithExpectedSize(buildData.getToBeUpdated().size());
843843
for (URI uri : Iterables.concat(buildData.getToBeUpdated(), buildData.getToBeDeleted())) {
844844
// Do *not* use descriptionCopier here, we just want the EObjectDescriptions!
845-
cache.computeIfAbsent(uri, u -> Optional.ofNullable(getResourceDescription(u)).<IResourceDescription> map(FingerprintResourceDescription::new).orElse(NULL_DESCRIPTION));
845+
cache.computeIfAbsent(uri, u -> Optional.ofNullable(getResourceDescription(u)).<IResourceDescription> map(this::createOldStateResourceDescription).orElse(NULL_DESCRIPTION));
846846
}
847847
return cache;
848848
}
849849

850+
/**
851+
* Create a resource description's copy that represents the old state of a resource. Will be used to compute invalidations.
852+
* (see 'oldDescriptions' in doUpdate(BuildData, ResourceDescriptionsData, IProgressMonitor))
853+
*
854+
* @param original
855+
* original resource description, must not be {@code null}
856+
* @return a copy, never {@code null}
857+
*/
858+
private IResourceDescription createOldStateResourceDescription(final IResourceDescription original) {
859+
IResourceServiceProvider provider = IResourceServiceProvider.Registry.INSTANCE.getResourceServiceProvider(original.getURI());
860+
if (provider != null && provider.getResourceDescriptionManager() instanceof AbstractCachingResourceDescriptionManager) {
861+
// FingerprintResourceDescription is a lightweight implementation that contains only the information for computation of invalidated resources
862+
// Should be however used only for those DSLs, which use DDK's custom resource descriptions deltas
863+
// This is the case if language's IResourceDescription.Manager implementation subclasses AbstractCachingResourceDescriptionManager
864+
return new FingerprintResourceDescription(original);
865+
}
866+
return new FixedCopiedResourceDescription(original);
867+
}
868+
850869
/**
851870
* Save copies of existing associations for derived objects (which will be cleared in the first build phase as resource descriptions will be overwritten).
852871
*

0 commit comments

Comments
 (0)