Class GumTreeDiff
java.lang.Object
org.variantsync.diffdetective.variation.diff.construction.GumTreeDiff
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static <L extends Label>
voidaddUnmapped(com.github.gumtreediff.matchers.MappingStore mappings, DiffNode<L> parent, VariationTreeAdapter<L> afterNode) Recursively addsafterNodetoparentreusing 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 aVariationDiffexplicit.improveMatching(DiffNode<L> tree, com.github.gumtreediff.matchers.Matcher matcher) Runmatcheron the matching extracted fromtreeand modifytreein-place to reflect the new matching.private static <L extends Label>
voidMergesafterNodeintobeforeNodesuch thatbeforeNode.isNon() == true.private static <L extends Label>
voidremoveUnmapped(com.github.gumtreediff.matchers.MappingStore mappings, VariationDiffAdapter<L> root) Remove all nodes from theBEFOREprojection which aren't part of a mapping.Removes the implicit matching between theBEFOREandAFTERprojection ofbeforeNode.
-
Constructor Details
-
GumTreeDiff
public GumTreeDiff()
-
-
Method Details
-
diffUsingMatching
public static <L extends Label> VariationDiff<L> diffUsingMatching(VariationTree<L> before, VariationTree<L> after) - See Also:
-
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 aDiffNodeby matching nodes betweenbeforeandafterwithmatcher. The arguments of this function aren't modified (note theoverloadwhich modifiesbeforein-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 aDiffNodeby matching nodes betweenbeforeandafterwithmatcher. The result of this function isbeforewhich is modified in-place. In contrast,afteris kept in tact. Warning: Modifications tobeforeshouldn'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:
-
removeUnmapped
private static <L extends Label> void removeUnmapped(com.github.gumtreediff.matchers.MappingStore mappings, VariationDiffAdapter<L> root) Remove all nodes from theBEFOREprojection which aren't part of a mapping.- Parameters:
mappings- the matching between theBEFOREprojection ofrootsome 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 addsafterNodetoparentreusing matched nodes. The variation diffparentis modified in-place such that itsAFTERprojection contains a child equivalent toafterNodewhich shares matched nodes with theBEFOREprojection ofparent.- Parameters:
mappings- the matching between theBEFOREprojection ofrootand a variation tree containingafterNodeparent- the variation diff whoseAFTERprojection is modifiedafterNode- a desired child ofparent'sAFTERprojection
-
improveMatching
public static <L extends Label> DiffNode<L> improveMatching(DiffNode<L> tree, com.github.gumtreediff.matchers.Matcher matcher) Runmatcheron the matching extracted fromtreeand modifytreein-place to reflect the new matching. This is equivalent todiffUsingMatchingexcept that the existing implicit matching isextractedand used as basis for the new matching. Hence, this method is mostly an optimisation to avoid a copy of theAFTERprojection oftree.- See Also:
-
splitNode
Removes the implicit matching between theBEFOREandAFTERprojection ofbeforeNode. This is achieved by copyingbeforeNodeand reconnecting all necessary edges such that the new node exists only after andbeforeNodeonly exists before the edit. This method doesn't change theBEFOREandAFTERprojection ofbeforeNode.- Parameters:
beforeNode- the node to be split- Returns:
- a copy of
beforeNodeexisting only after the edit.
-
joinNode
MergesafterNodeintobeforeNodesuch thatbeforeNode.isNon() == true. Essentially, an implicit matching is inserted betweenbeforeNodeandafterNode. This method doesn't change theBEFOREandAFTERprojection ofbeforeNode.- Parameters:
beforeNode- the node which is will existBEFOREandAFTERthe 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 aVariationDiffexplicit.- Parameters:
src- the source nodes of the matching, must be of the sameVariationDiffasdst.dst- the destination nodes of the matching, must be of the sameVariationDiffassrcresult- the destination where the matching betweensrcand is added.
-