Skip to content

Commit b3f65e5

Browse files
committed
Generalize the label of DiffNode and VariationNode
This will be used to encode variation trees of variation trees.
1 parent 4926934 commit b3f65e5

139 files changed

Lines changed: 1356 additions & 1227 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/org/variantsync/diffdetective/analysis/Analysis.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.variantsync.diffdetective.util.Clock;
2626
import org.variantsync.diffdetective.util.Diagnostics;
2727
import org.variantsync.diffdetective.util.InvocationCounter;
28+
import org.variantsync.diffdetective.variation.DiffLinesLabel;
2829
import org.variantsync.diffdetective.variation.diff.DiffTree;
2930
import org.variantsync.functjonal.iteration.ClusteredIterator;
3031
import org.variantsync.functjonal.iteration.MappedIterator;
@@ -64,7 +65,7 @@ public class Analysis {
6465
protected RevCommit currentCommit;
6566
protected CommitDiff currentCommitDiff;
6667
protected PatchDiff currentPatch;
67-
protected DiffTree currentDiffTree;
68+
protected DiffTree<DiffLinesLabel> currentDiffTree;
6869

6970
protected final Path outputDir;
7071
protected Path outputFile;
@@ -106,7 +107,7 @@ public PatchDiff getCurrentPatch() {
106107
* The currently processed patch.
107108
* Valid only during {@link Hooks#analyzeDiffTree}.
108109
*/
109-
public DiffTree getCurrentDiffTree() {
110+
public DiffTree<DiffLinesLabel> getCurrentDiffTree() {
110111
return currentDiffTree;
111112
}
112113

src/main/java/org/variantsync/diffdetective/analysis/EditClassOccurenceAnalysis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public EditClassOccurenceAnalysis(AnalysisStrategy exportStrategy) {
2727

2828
@Override
2929
public void initializeResults(Analysis analysis) {
30-
analysis.append(EditClassCount.KEY, new EditClassCount());
30+
analysis.append(EditClassCount.KEY, new EditClassCount(ProposedEditClasses.Instance));
3131
}
3232

3333
@Override

src/main/java/org/variantsync/diffdetective/analysis/FilterAnalysis.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
import java.util.Arrays;
44

55
import org.variantsync.diffdetective.metadata.ExplainedFilterSummary;
6+
import org.variantsync.diffdetective.variation.DiffLinesLabel;
67
import org.variantsync.diffdetective.variation.diff.DiffTree;
78
import org.variantsync.diffdetective.variation.diff.filter.ExplainedFilter;
89
import org.variantsync.diffdetective.variation.diff.filter.TaggedPredicate;
910

1011
public class FilterAnalysis implements Analysis.Hooks {
11-
private ExplainedFilter<DiffTree> treeFilter;
12+
private ExplainedFilter<DiffTree<? extends DiffLinesLabel>> treeFilter;
1213

13-
public FilterAnalysis(ExplainedFilter<DiffTree> treeFilter) {
14+
public FilterAnalysis(ExplainedFilter<DiffTree<? extends DiffLinesLabel>> treeFilter) {
1415
this.treeFilter = treeFilter;
1516
}
1617

1718
@SafeVarargs
18-
public FilterAnalysis(TaggedPredicate<String, DiffTree>... treeFilter) {
19-
this.treeFilter = new ExplainedFilter<DiffTree>(Arrays.stream(treeFilter));
19+
public FilterAnalysis(TaggedPredicate<String, DiffTree<? extends DiffLinesLabel>>... treeFilter) {
20+
this.treeFilter = new ExplainedFilter<>(Arrays.stream(treeFilter));
2021
}
2122

2223
@Override

src/main/java/org/variantsync/diffdetective/analysis/LineGraphExportAnalysis.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.variantsync.diffdetective.analysis.AnalysisResult.ResultKey;
88
import org.variantsync.diffdetective.analysis.strategies.AnalysisStrategy;
99
import org.variantsync.diffdetective.metadata.Metadata;
10+
import org.variantsync.diffdetective.variation.DiffLinesLabel;
1011
import org.variantsync.diffdetective.variation.diff.serialize.LineGraphExport;
1112
import org.variantsync.diffdetective.variation.diff.serialize.LineGraphExportOptions;
1213
import org.variantsync.functjonal.category.InplaceSemigroup;
@@ -45,10 +46,10 @@ public void setFromSnapshot(LinkedHashMap<String, String> snap) {
4546
}
4647

4748
private final AnalysisStrategy analysisStrategy;
48-
private final LineGraphExportOptions exportOptions;
49+
private final LineGraphExportOptions<? super DiffLinesLabel> exportOptions;
4950
private OutputStream lineGraphDestination;
5051

51-
public LineGraphExportAnalysis(final AnalysisStrategy analysisStrategy, final LineGraphExportOptions exportOptions) {
52+
public LineGraphExportAnalysis(final AnalysisStrategy analysisStrategy, final LineGraphExportOptions<? super DiffLinesLabel> exportOptions) {
5253
this.analysisStrategy = analysisStrategy;
5354
this.exportOptions = exportOptions;
5455
}

src/main/java/org/variantsync/diffdetective/analysis/PreprocessingAnalysis.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44
import java.util.List;
55

66
import org.variantsync.diffdetective.variation.diff.transform.DiffTreeTransformer;
7+
import org.variantsync.diffdetective.variation.DiffLinesLabel;
78

89
public class PreprocessingAnalysis implements Analysis.Hooks {
9-
private final List<DiffTreeTransformer> preprocessors;
10+
private final List<DiffTreeTransformer<DiffLinesLabel>> preprocessors;
1011

11-
public PreprocessingAnalysis(List<DiffTreeTransformer> preprocessors) {
12+
public PreprocessingAnalysis(List<DiffTreeTransformer<DiffLinesLabel>> preprocessors) {
1213
this.preprocessors = preprocessors;
1314
}
1415

15-
public PreprocessingAnalysis(DiffTreeTransformer... preprocessors) {
16+
@SafeVarargs
17+
public PreprocessingAnalysis(DiffTreeTransformer<DiffLinesLabel>... preprocessors) {
1618
this.preprocessors = Arrays.asList(preprocessors);
1719
}
1820

src/main/java/org/variantsync/diffdetective/diff/git/GitDiffer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.variantsync.diffdetective.preliminary.GitDiff;
2222
import org.variantsync.diffdetective.util.Assert;
2323
import org.variantsync.diffdetective.util.StringUtils;
24+
import org.variantsync.diffdetective.variation.DiffLinesLabel;
2425
import org.variantsync.diffdetective.variation.diff.DiffTree;
2526
import org.variantsync.diffdetective.variation.diff.parse.DiffTreeParser;
2627
import org.variantsync.functjonal.iteration.MappedIterator;
@@ -36,7 +37,6 @@
3637
import java.util.function.Function;
3738
import java.util.regex.Matcher;
3839
import java.util.regex.Pattern;
39-
import java.util.stream.Collectors;
4040

4141
/**
4242
* This class creates a GitDiff-object from a git repository (Git-object).
@@ -375,7 +375,7 @@ private static CommitDiffResult getPatchDiffs(
375375
fullDiff += StringUtils.LINEBREAK;
376376
}
377377

378-
final DiffTree diffTree = DiffTreeParser.createDiffTree(
378+
final DiffTree<DiffLinesLabel> diffTree = DiffTreeParser.createDiffTree(
379379
fullDiff,
380380
parseOptions.diffTreeParseOptions()
381381
);

src/main/java/org/variantsync/diffdetective/diff/git/PatchDiff.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.apache.commons.io.FilenameUtils;
44
import org.eclipse.jgit.diff.DiffEntry;
5+
import org.variantsync.diffdetective.variation.DiffLinesLabel;
56
import org.variantsync.diffdetective.variation.diff.DiffTree;
67

78
/**
@@ -13,7 +14,7 @@
1314
*/
1415
public class PatchDiff implements GitPatch {
1516
private final String fullDiff;
16-
private final DiffTree diffTree;
17+
private final DiffTree<DiffLinesLabel> diffTree;
1718

1819
/**
1920
* The commit the patch belongs to.
@@ -38,7 +39,7 @@ public class PatchDiff implements GitPatch {
3839
* @param diffTree The {@link DiffTree} that describes this patch.
3940
*/
4041
public PatchDiff(CommitDiff commitDiff, DiffEntry diffEntry, String fullDiff,
41-
DiffTree diffTree) {
42+
DiffTree<DiffLinesLabel> diffTree) {
4243
this.commitDiff = commitDiff;
4344
this.changeType = diffEntry.getChangeType();
4445
this.path = diffEntry.getNewPath();
@@ -91,7 +92,7 @@ public String getDiff() {
9192
/**
9293
* Returns the DiffTree for this patch.
9394
*/
94-
public DiffTree getDiffTree() {
95+
public DiffTree<DiffLinesLabel> getDiffTree() {
9596
return diffTree;
9697
}
9798

src/main/java/org/variantsync/diffdetective/editclass/EditClass.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Abstract edit class according to our ESEC/FSE'22 paper.
1010
* @author Paul Bittner, Sören Viegener
1111
*/
12-
public abstract class EditClass extends Pattern<DiffNode> {
12+
public abstract class EditClass extends Pattern<DiffNode<?>> {
1313
private final DiffType diffType;
1414

1515
/**
@@ -33,20 +33,20 @@ public DiffType getDiffType() {
3333
* Returns true iff the given node matches this edit class.
3434
* @param artifactNode Node which has node type ARTIFACT and whose DiffType is the same as {@link getDiffType()}.
3535
*/
36-
protected abstract boolean matchesArtifactNode(DiffNode artifactNode);
36+
protected abstract boolean matchesArtifactNode(DiffNode<?> artifactNode);
3737

3838
/**
3939
* Returns true if this edit class matches the given node and is an artifact.
4040
*/
4141
@Override
42-
public final boolean matches(DiffNode node) {
42+
public final boolean matches(DiffNode<?> node) {
4343
return node.isArtifact() && node.diffType == diffType && matchesArtifactNode(node);
4444
}
4545

4646
/**
4747
* Returns true iff this edit class matches at leat one node on the given tree.
4848
*/
49-
public boolean anyMatch(final DiffTree t) {
49+
public boolean anyMatch(final DiffTree<?> t) {
5050
return t.anyMatch(this::matches);
5151
}
5252
}

src/main/java/org/variantsync/diffdetective/editclass/EditClassCatalogue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public interface EditClassCatalogue {
3232
* @param node The node of which to find its edit class.
3333
* @return Returns the edit class that matches the given node.
3434
*/
35-
default EditClass match(DiffNode node)
35+
default EditClass match(DiffNode<?> node)
3636
{
3737
if (!node.isArtifact()) {
3838
throw new IllegalArgumentException("Expected an artifact node but got " + node.nodeType + "!");

src/main/java/org/variantsync/diffdetective/editclass/proposed/AddToPC.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.variantsync.diffdetective.editclass.proposed;
22

33
import org.variantsync.diffdetective.editclass.EditClass;
4+
import org.variantsync.diffdetective.variation.Label;
45
import org.variantsync.diffdetective.variation.diff.DiffNode;
56
import org.variantsync.diffdetective.variation.diff.DiffType;
67

@@ -16,7 +17,7 @@ final class AddToPC extends EditClass {
1617
}
1718

1819
@Override
19-
protected boolean matchesArtifactNode(DiffNode node) {
20+
protected boolean matchesArtifactNode(DiffNode<?> node) {
2021
return !node.getParent(AFTER).isAdd();
2122
}
2223
}

0 commit comments

Comments
 (0)