Skip to content

Commit c0bf03e

Browse files
committed
single matchers
1 parent 7906a96 commit c0bf03e

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

  • src/main/java/org/variantsync/diffdetective/variation/diff/construction

src/main/java/org/variantsync/diffdetective/variation/diff/construction/GumTreeDiff.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
import com.github.gumtreediff.matchers.Matcher;
55
import com.github.gumtreediff.matchers.Matchers;
66
import com.github.gumtreediff.tree.Tree;
7+
import com.github.gumtreediff.matchers.heuristic.*;
8+
import com.github.gumtreediff.matchers.heuristic.cd.*;
9+
import com.github.gumtreediff.matchers.*;
10+
import com.github.gumtreediff.matchers.optimizations.*;
711

812
import org.variantsync.diffdetective.diff.text.DiffLineNumber;
913
import org.variantsync.diffdetective.gumtree.VariationDiffAdapter;
@@ -18,8 +22,7 @@
1822
import org.variantsync.diffdetective.variation.tree.VariationTree;
1923
import org.variantsync.functjonal.Cast;
2024

21-
import java.util.HashMap;
22-
import java.util.Map;
25+
import java.util.*;
2326

2427
import static org.variantsync.diffdetective.variation.diff.DiffType.ADD;
2528
import static org.variantsync.diffdetective.variation.diff.DiffType.REM;
@@ -86,14 +89,26 @@ public static <A extends VariationNode<A, L>, B extends VariationNode<B, L>, L e
8689
public static <B extends VariationNode<B, L>, L extends Label> DiffNode<L> diffUsingMatching(
8790
DiffNode<L> before,
8891
VariationNode<B, L> after,
89-
Matcher matcher
92+
Matcher matcherOld
9093
) {
9194
var src = new VariationDiffAdapter<L>(before, BEFORE);
9295
var dst = new VariationTreeAdapter<L>(after);
9396

94-
MappingStore matching = matcher.match(src, dst);
95-
for (var mapping : matching) {
96-
System.out.println(mapping.first + " <-> " + mapping.second);
97+
MappingStore matching = new MappingStore(src, dst);
98+
List<Matcher> matchers = List.of(new IdenticalSubtreeMatcherThetaA(), new ChangeDistillerParallelLeavesMatcher(),
99+
new ChangeDistillerBottomUpMatcher(), new LcsOptMatcherThetaB(), new UnmappedLeavesMatcherThetaC(),
100+
new InnerNodesMatcherThetaD(), new LeafMoveMatcherThetaE(), new CrossMoveMatcherThetaF());
101+
for (var matcher : matchers) {
102+
matcher.match(src, dst, matching);
103+
104+
System.out.format("Matching after %s\n", matcher.getClass().getName());
105+
for (var mapping : matching) {
106+
System.out.println(mapping.first + " <-> " + mapping.second);
107+
}
108+
matching.assertConsistency();
109+
System.out.println();
110+
System.out.println();
111+
System.out.println();
97112
}
98113

99114
// We assume that the root nodes are matched.

0 commit comments

Comments
 (0)