Class GumTreeDiff
java.lang.Object
org.variantsync.diffdetective.variation.diff.construction.GumTreeDiff
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static <L extends Label>
voidaddUnmapped
(com.github.gumtreediff.matchers.MappingStore mappings, DiffNode<L> parent, VariationTreeAdapter<L> afterNode) Recursively addsafterNode
toparent
reusing matched nodes.static <B extends VariationNode<B,
L>, L extends Label>
DiffNode<L>diffUsingMatching
(DiffNode<L> before, VariationNode<B, L> after, com.github.gumtreediff.matchers.Matcher matcher) static <A extends VariationNode<A,
L>, B extends VariationNode<B, L>, L extends Label>
DiffNode<L>diffUsingMatching
(VariationNode<A, L> before, VariationNode<B, L> after, com.github.gumtreediff.matchers.Matcher matcher) static <L extends Label>
VariationDiff<L>diffUsingMatching
(VariationTree<L> before, VariationTree<L> after) private static <L extends Label>
voidextractMatching
(VariationDiffAdapter<L> src, VariationDiffAdapter<L> dst, com.github.gumtreediff.matchers.MappingStore result) Makes the implicit matching of aVariationDiff
explicit.improveMatching
(DiffNode<L> tree, com.github.gumtreediff.matchers.Matcher matcher) Runmatcher
on the matching extracted fromtree
and modifytree
in-place to reflect the new matching.private static <L extends Label>
voidMergesafterNode
intobeforeNode
such thatbeforeNode.isNon() == true
.private static <L extends Label>
voidremoveUnmapped
(com.github.gumtreediff.matchers.MappingStore mappings, VariationDiffAdapter<L> root) Remove all nodes from theBEFORE
projection which aren't part of a mapping.Removes the implicit matching between theBEFORE
andAFTER
projection ofbeforeNode
.
-
Constructor Details
-
GumTreeDiff
public GumTreeDiff()
-
-
Method Details
-
diffUsingMatching
public static <L extends Label> VariationDiff<L> diffUsingMatching(VariationTree<L> before, VariationTree<L> after) -
diffUsingMatching
public static <A extends VariationNode<A,L>, DiffNode<L> diffUsingMatchingB extends VariationNode<B, L>, L extends Label> (VariationNode<A, L> before, VariationNode<B, L> after, com.github.gumtreediff.matchers.Matcher matcher) Create aDiffNode
by matching nodes betweenbefore
andafter
withmatcher
. The arguments of this function aren't modified (note theoverload
which modifiesbefore
in-place.- Parameters:
before
- the variation tree before an editafter
- the variation tree after an edit- See Also:
-
diffUsingMatching
public static <B extends VariationNode<B,L>, DiffNode<L> diffUsingMatchingL extends Label> (DiffNode<L> before, VariationNode<B, L> after, com.github.gumtreediff.matchers.Matcher matcher) Create aDiffNode
by matching nodes betweenbefore
andafter
withmatcher
. The result of this function isbefore
which is modified in-place. In contrast,after
is kept in tact. Warning: Modifications tobefore
shouldn't concurrently modifyafter
. Note: There are currently no guarantees about the line numbers. But it is guaranteed thatDiffNode.getID()
is unique.- Parameters:
before
- the variation tree before an editafter
- the variation tree after an edit- See Also:
-
- "Constructing Variation Diffs Using Tree Diffing Algorithms"
-
removeUnmapped
private static <L extends Label> void removeUnmapped(com.github.gumtreediff.matchers.MappingStore mappings, VariationDiffAdapter<L> root) Remove all nodes from theBEFORE
projection which aren't part of a mapping.- Parameters:
mappings
- the matching between theBEFORE
projection ofroot
some variation treeroot
- the variation diff whose before projection is modified
-
addUnmapped
private static <L extends Label> void addUnmapped(com.github.gumtreediff.matchers.MappingStore mappings, DiffNode<L> parent, VariationTreeAdapter<L> afterNode) Recursively addsafterNode
toparent
reusing matched nodes. The variation diffparent
is modified in-place such that itsAFTER
projection contains a child equivalent toafterNode
which shares matched nodes with theBEFORE
projection ofparent
.- Parameters:
mappings
- the matching between theBEFORE
projection ofroot
and a variation tree containingafterNode
parent
- the variation diff whoseAFTER
projection is modifiedafterNode
- a desired child ofparent
'sAFTER
projection
-
improveMatching
public static <L extends Label> DiffNode<L> improveMatching(DiffNode<L> tree, com.github.gumtreediff.matchers.Matcher matcher) Runmatcher
on the matching extracted fromtree
and modifytree
in-place to reflect the new matching. This is equivalent todiffUsingMatching
except that the existing implicit matching isextracted
and used as basis for the new matching. Hence, this method is mostly an optimisation to avoid a copy of theAFTER
projection oftree
.- See Also:
-
- "Constructing Variation Diffs Using Tree Diffing Algorithms"
-
splitNode
Removes the implicit matching between theBEFORE
andAFTER
projection ofbeforeNode
. This is achieved by copyingbeforeNode
and reconnecting all necessary edges such that the new node exists only after andbeforeNode
only exists before the edit. This method doesn't change theBEFORE
andAFTER
projection ofbeforeNode
.- Parameters:
beforeNode
- the node to be split- Returns:
- a copy of
beforeNode
existing only after the edit.
-
joinNode
MergesafterNode
intobeforeNode
such thatbeforeNode.isNon() == true
. Essentially, an implicit matching is inserted betweenbeforeNode
andafterNode
. This method doesn't change theBEFORE
andAFTER
projection ofbeforeNode
.- Parameters:
beforeNode
- the node which is will existBEFORE
andAFTER
the editafterNode
- the node which is discarded
-
extractMatching
private static <L extends Label> void extractMatching(VariationDiffAdapter<L> src, VariationDiffAdapter<L> dst, com.github.gumtreediff.matchers.MappingStore result) Makes the implicit matching of aVariationDiff
explicit.- Parameters:
src
- the source nodes of the matching, must be of the sameVariationDiff
asdst
.dst
- the destination nodes of the matching, must be of the sameVariationDiff
assrc
result
- the destination where the matching betweensrc
and is added.
-