Package org.eclipse.emf.compare.merge
Class CachingDiffRelationshipComputer
java.lang.Object
org.eclipse.emf.compare.merge.DiffRelationshipComputer
org.eclipse.emf.compare.merge.CachingDiffRelationshipComputer
- All Implemented Interfaces:
IDiffRelationshipComputer
A computer implementation to cache the relationship of diffs. Note that the "all" relationships are not
cached because they would O(n^2) memory in the general case.
- Since:
- 3.5
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionDirect merge dependencies: left to right.Direct merge dependencies: right to left.Direct resulting merges: left to right.Direct resulting merges: right to left.Direct resulting rejections: left to right.Direct resulting rejections: right to left.Fields inherited from class org.eclipse.emf.compare.merge.DiffRelationshipComputer
criterion, registry
-
Constructor Summary
ConstructorDescriptionCreates a new computer with the given registry.CachingDiffRelationshipComputer
(IMerger.Registry registry, IMergeCriterion criterion) Creates a new computer with the given registry and merge criterion. -
Method Summary
Modifier and TypeMethodDescriptionvoid
computeCache
(Diff diff) Computes the cached relationships for the give diff.computeDirectMergeDependencies
(Diff diff, boolean mergeRightToLeft) Computes direct merge dependencies for the given diff.computeDirectResultingMerges
(Diff diff, boolean mergeRightToLeft) Computes direct resulting merges for the given diff.computeDirectResultingRejections
(Diff diff, boolean mergeRightToLeft) Computes the direct resulting rejections.getCachedDirectMergeDependencies
(Diff diff, boolean mergeRightToLeft) Returns the cached direct merge dependencies.getCachedDirectResultingMerges
(Diff diff, boolean mergeRightToLeft) Returns the cached direct resulting merges.getCachedDirectResultingRejections
(Diff diff, boolean mergeRightToLeft) Returns the cached direct resulting rejections.getDirectMergeDependencies
(Diff diff, boolean mergeRightToLeft) Returns the cached direct merge dependencies, if present.getDirectResultingMerges
(Diff diff, boolean mergeRightToLeft) Returns the cached direct resulting merges, if present.getDirectResultingRejections
(Diff diff, boolean mergeRightToLeft) Returns the set of all differences that need to be rejected ifdiff
is merged in the given direction.void
Invalidates the complete cache, so that relationships will be re-calculated any diff the next time a respective method is called.protected void
setCachedDirectMergeDependencies
(Diff diff, boolean mergeRightToLeft, Set<Diff> directMergeDependencies) Caches the given direct merge dependencies.protected void
setCachedDirectResultingMerges
(Diff diff, boolean mergeRightToLeft, Set<Diff> directResultingMerges) Caches the given direct resulting merges.protected void
setCachedDirectResultingRejections
(Diff diff, boolean mergeRightToLeft, Set<Diff> directResultingRejections) Caches the given direct resulting rejections.void
setMergeCriterion
(IMergeCriterion mergeCriterion) Sets the merge criterion considered for calculating the diff relationships.void
setMergerRegistry
(IMerger.Registry mergerRegistry) Sets the merger registry used for calculating the diff relationships.Methods inherited from class org.eclipse.emf.compare.merge.DiffRelationshipComputer
getAllResultingMerges, getAllResultingMerges, getAllResultingRejections, getAllResultingRejections, getMergeCriterion, getMerger, getMergerRegistry, getMergerRegistry2, hasMerger, internalGetAllResultingMerges
-
Field Details
-
directMergeDependenciesR2L
Direct merge dependencies: right to left. -
directMergeDependenciesL2R
Direct merge dependencies: left to right. -
directResultingMergesR2L
Direct resulting merges: right to left. -
directResultingMergesL2R
Direct resulting merges: left to right. -
directResultingRejectionsR2L
Direct resulting rejections: right to left. -
directResultingRejectionsL2R
Direct resulting rejections: left to right.
-
-
Constructor Details
-
CachingDiffRelationshipComputer
Creates a new computer with the given registry.- Parameters:
registry
- merger registry
-
CachingDiffRelationshipComputer
Creates a new computer with the given registry and merge criterion.- Parameters:
registry
- merger registrycriterion
- merge criterion used to get the merger from the registry, useIMergeCriterion.NONE
if no special criterion should be set.
-
-
Method Details
-
setMergerRegistry
Sets the merger registry used for calculating the diff relationships. WARNING: Setting the merger registry invalidates previously cached results, if another registry was set previously!- Specified by:
setMergerRegistry
in interfaceIDiffRelationshipComputer
- Overrides:
setMergerRegistry
in classDiffRelationshipComputer
- Parameters:
mergerRegistry
- The merger registry.
-
setMergeCriterion
Sets the merge criterion considered for calculating the diff relationships. WARNING: Setting the merge criterion invalidates previously cached results, if another criterion was set previously.- Specified by:
setMergeCriterion
in interfaceIDiffRelationshipComputer
- Overrides:
setMergeCriterion
in classDiffRelationshipComputer
- Parameters:
mergeCriterion
- The merger criterion.
-
setCachedDirectMergeDependencies
protected void setCachedDirectMergeDependencies(Diff diff, boolean mergeRightToLeft, Set<Diff> directMergeDependencies) Caches the given direct merge dependencies.- Parameters:
diff
- diffmergeRightToLeft
- merge directiondirectMergeDependencies
- direct merge dependencies of diff
-
getCachedDirectMergeDependencies
Returns the cached direct merge dependencies.- Parameters:
diff
- diffmergeRightToLeft
- merge direction- Returns:
- cached direct merge dependencies
-
computeDirectMergeDependencies
Computes direct merge dependencies for the given diff.- Parameters:
diff
- diffmergeRightToLeft
- merge direction- Returns:
- a non-null set of direct merge dependencies
-
getDirectMergeDependencies
Returns the cached direct merge dependencies, if present. Otherwise, the direct merge dependencies are retrieved and cached using the given merger.- Specified by:
getDirectMergeDependencies
in interfaceIDiffRelationshipComputer
- Overrides:
getDirectMergeDependencies
in classDiffRelationshipComputer
- Parameters:
diff
- diffmergeRightToLeft
- merge direction- Returns:
- cached direct merge dependencies
- See Also:
-
setCachedDirectResultingMerges
protected void setCachedDirectResultingMerges(Diff diff, boolean mergeRightToLeft, Set<Diff> directResultingMerges) Caches the given direct resulting merges.- Parameters:
diff
- diffmergeRightToLeft
- merge directiondirectResultingMerges
- direct resulting merges
-
getCachedDirectResultingMerges
Returns the cached direct resulting merges.- Parameters:
diff
- diffmergeRightToLeft
- merge direction- Returns:
- cached direct resulting merges
-
computeDirectResultingMerges
Computes direct resulting merges for the given diff.- Parameters:
diff
- diffmergeRightToLeft
- merge direction- Returns:
- a non-null set of all resulting merges
-
getDirectResultingMerges
Returns the cached direct resulting merges, if present. Otherwise, the direct resulting merges are retrieved and cached using the given merger.- Specified by:
getDirectResultingMerges
in interfaceIDiffRelationshipComputer
- Overrides:
getDirectResultingMerges
in classDiffRelationshipComputer
- Parameters:
diff
- diffmergeRightToLeft
- merge direction- Returns:
- cached direct resulting merges
- See Also:
-
setCachedDirectResultingRejections
protected void setCachedDirectResultingRejections(Diff diff, boolean mergeRightToLeft, Set<Diff> directResultingRejections) Caches the given direct resulting rejections.- Parameters:
diff
- diffmergeRightToLeft
- merge directiondirectResultingRejections
- direct resulting rejections
-
getCachedDirectResultingRejections
Returns the cached direct resulting rejections.- Parameters:
diff
- diffmergeRightToLeft
- merge direction- Returns:
- cached direct resulting rejections
-
computeDirectResultingRejections
Computes the direct resulting rejections.- Parameters:
diff
- diffmergeRightToLeft
- merge direction- Returns:
- a non-null set of direct resulting rejections
-
getDirectResultingRejections
Description copied from interface:IDiffRelationshipComputer
Returns the set of all differences that need to be rejected ifdiff
is merged in the given direction.- Specified by:
getDirectResultingRejections
in interfaceIDiffRelationshipComputer
- Overrides:
getDirectResultingRejections
in classDiffRelationshipComputer
- Parameters:
diff
- The difference for which we seek the direct resulting rejections.mergeRightToLeft
- The direction in which we're considering a merge.- Returns:
- A non-null set of direct resulting rejections.
- See Also:
-
computeCache
Computes the cached relationships for the give diff.- Parameters:
diff
- the diff for which to cmpute the cached relationship.
-
invalidate
public void invalidate()Invalidates the complete cache, so that relationships will be re-calculated any diff the next time a respective method is called.
-