Skip to content

Commit 4025657

Browse files
committed
Use the term 'edit class' instead of 'elementary edit pattern'
1 parent 8aa8ea2 commit 4025657

45 files changed

Lines changed: 383 additions & 384 deletions

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/AnalysisResult.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import org.variantsync.diffdetective.diff.difftree.serialize.DiffTreeSerializeDebugData;
44
import org.variantsync.diffdetective.diff.result.DiffError;
5-
import org.variantsync.diffdetective.metadata.ElementaryPatternCount;
5+
import org.variantsync.diffdetective.metadata.EditClassCount;
66
import org.variantsync.diffdetective.metadata.ExplainedFilterSummary;
77
import org.variantsync.diffdetective.metadata.Metadata;
8-
import org.variantsync.diffdetective.pattern.proposed.ProposedElementaryPatterns;
8+
import org.variantsync.diffdetective.editclass.proposed.ProposedEditClasses;
99
import org.variantsync.functjonal.Functjonal;
1010
import org.variantsync.functjonal.category.InplaceMonoid;
1111
import org.variantsync.functjonal.category.InplaceSemigroup;
@@ -55,7 +55,7 @@ public class AnalysisResult implements Metadata<AnalysisResult> {
5555
a.max.set(CommitProcessTime.max(a.max, b.max));
5656
a.debugData.append(b.debugData);
5757
a.filterHits.append(b.filterHits);
58-
a.elementaryPatternCounts.append(b.elementaryPatternCounts);
58+
a.editClassCounts.append(b.editClassCounts);
5959
MergeMap.putAllValues(a.customInfo, b.customInfo, Semigroup.assertEquals());
6060
a.diffErrors.append(b.diffErrors);
6161
};
@@ -80,7 +80,7 @@ public class AnalysisResult implements Metadata<AnalysisResult> {
8080
public final CommitProcessTime min, max;
8181
public final DiffTreeSerializeDebugData debugData;
8282
public ExplainedFilterSummary filterHits;
83-
public ElementaryPatternCount elementaryPatternCounts;
83+
public EditClassCount editClassCounts;
8484
private final LinkedHashMap<String, String> customInfo = new LinkedHashMap<>();
8585
private final MergeMap<DiffError, Integer> diffErrors = new MergeMap<>(new HashMap<>(), Integer::sum);
8686

@@ -152,7 +152,7 @@ public AnalysisResult(
152152
this.runtimeWithMultithreadingInSeconds = runtimeWithMultithreadingInSeconds;
153153
this.debugData = debugData;
154154
this.filterHits = filterHits;
155-
this.elementaryPatternCounts = new ElementaryPatternCount();
155+
this.editClassCounts = new EditClassCount();
156156
this.min = min;
157157
this.max = max;
158158
}
@@ -189,7 +189,7 @@ public static AnalysisResult importFrom(final Path p, final Map<String, BiConsum
189189
AnalysisResult result = new AnalysisResult();
190190

191191
final List<String> filterHitsLines = new ArrayList<>();
192-
final List<String> elementaryPatternCountsLines = new ArrayList<>();
192+
final List<String> editClassCountsLines = new ArrayList<>();
193193

194194
try (BufferedReader input = Files.newBufferedReader(p)) {
195195
// examine each line of the metadata file separately
@@ -229,13 +229,13 @@ public static AnalysisResult importFrom(final Path p, final Map<String, BiConsum
229229
// temporary fix for renaming from Unchanged to Untouched
230230
final String unchanged = "Unchanged";
231231
if (key.startsWith(unchanged)) {
232-
key = ProposedElementaryPatterns.Untouched.getName();
232+
key = ProposedEditClasses.Untouched.getName();
233233
line = key + line.substring(unchanged.length());
234234
}
235235

236236
final String finalKey = key;
237-
if (ProposedElementaryPatterns.All.stream().anyMatch(pattern -> pattern.getName().equals(finalKey))) {
238-
elementaryPatternCountsLines.add(line);
237+
if (ProposedEditClasses.All.stream().anyMatch(editClass -> editClass.getName().equals(finalKey))) {
238+
editClassCountsLines.add(line);
239239
} else if (key.startsWith(ExplainedFilterSummary.FILTERED_MESSAGE_BEGIN)) {
240240
filterHitsLines.add(line);
241241
} else if (key.startsWith(ERROR_BEGIN)) {
@@ -257,7 +257,7 @@ public static AnalysisResult importFrom(final Path p, final Map<String, BiConsum
257257
}
258258

259259
result.filterHits = ExplainedFilterSummary.parse(filterHitsLines);
260-
result.elementaryPatternCounts = ElementaryPatternCount.parse(elementaryPatternCountsLines, p.toString());
260+
result.editClassCounts = EditClassCount.parse(editClassCountsLines, p.toString());
261261

262262
return result;
263263
}
@@ -289,7 +289,7 @@ public LinkedHashMap<String, Object> snapshot() {
289289
snap.putAll(customInfo);
290290
snap.putAll(debugData.snapshot());
291291
snap.putAll(filterHits.snapshot());
292-
snap.putAll(elementaryPatternCounts.snapshot());
292+
snap.putAll(editClassCounts.snapshot());
293293
snap.putAll(Functjonal.bimap(diffErrors, error -> ERROR_BEGIN + error + ERROR_END, Object::toString));
294294
return snap;
295295
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.variantsync.diffdetective.analysis;
2+
3+
import org.variantsync.diffdetective.editclass.EditClass;
4+
import org.variantsync.diffdetective.editclass.EditClassCatalogue;
5+
import org.variantsync.diffdetective.util.CSV;
6+
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
import java.util.stream.Collectors;
10+
11+
/**
12+
* Gathers statistics about matching edit classes.
13+
* @author Paul Bittner
14+
*/
15+
public class EditClassCount implements CSV {
16+
private final EditClassCatalogue catalogue;
17+
private final Map<EditClass, Integer> editClassCounts;
18+
19+
/**
20+
* Creates a new counter object for the given catalogue of edit classes.
21+
* @param catalogue The catalogue whose edit classes to match and count.
22+
*/
23+
public EditClassCount(final EditClassCatalogue catalogue) {
24+
this.catalogue = catalogue;
25+
this.editClassCounts = new HashMap<>();
26+
catalogue.all().forEach(e -> editClassCounts.put(e, 0));
27+
}
28+
29+
/**
30+
* Increment the count for the given edit class.
31+
* The given edit class is assumed to be part of this counts catalog.
32+
* @see EditClassCount#EditClassCount(EditClassCatalogue)
33+
* @param editClass The edit class whose count to increase by one.
34+
*/
35+
public void increment(final EditClass editClass) {
36+
editClassCounts.computeIfPresent(editClass, (p, i) -> i + 1);
37+
}
38+
39+
@Override
40+
public String toCSV(final String delimiter) {
41+
return catalogue.all().stream()
42+
.map(editClassCounts::get)
43+
.map(Object::toString)
44+
.collect(Collectors.joining(delimiter));
45+
}
46+
}

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

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
package org.variantsync.diffdetective.analysis;
22

33
import org.variantsync.diffdetective.diff.PatchDiff;
4-
import org.variantsync.diffdetective.pattern.ElementaryPatternCatalogue;
4+
import org.variantsync.diffdetective.editclass.EditClassCatalogue;
55
import org.variantsync.diffdetective.util.CSV;
66

77
/**
88
* Statistics for processing a patch in a commit.
99
* @param patchDiff The diff of the processed patch.
10-
* @param elementaryPatternCount Count statistics for the elementary edit patterns matched to the edits in the patch.
10+
* @param editClassCount Count statistics for the edit class matched to the edits in the patch.
1111
* @author Paul Bittner
1212
*/
1313
public record PatchStatistics(
1414
PatchDiff patchDiff,
15-
ElementaryPatternCount elementaryPatternCount) implements CSV {
15+
EditClassCount editClassCount) implements CSV {
1616
/**
17-
* Creates empty patch statistics for the given catalogue of edit patterns.
17+
* Creates empty patch statistics for the given catalogue of edit classes.
1818
* @param patch The patch to gather statistics for.
19-
* @param catalogue A catalogue of elementary edit patterns which should be used for classifying edits.
19+
* @param catalogue A catalogue of edit classes which should be used for classifying edits.
2020
*/
21-
public PatchStatistics(final PatchDiff patch, final ElementaryPatternCatalogue catalogue) {
22-
this(patch, new ElementaryPatternCount(catalogue));
21+
public PatchStatistics(final PatchDiff patch, final EditClassCatalogue catalogue) {
22+
this(patch, new EditClassCount(catalogue));
2323
}
2424

2525
@Override
2626
public String toCSV(final String delimiter) {
27-
return patchDiff.getCommitHash() + delimiter + patchDiff.getFileName() + delimiter + elementaryPatternCount.toCSV(delimiter);
27+
return patchDiff.getCommitHash() + delimiter + patchDiff.getFileName() + delimiter + editClassCount.toCSV(delimiter);
2828
}
2929
}

src/main/java/org/variantsync/diffdetective/diff/difftree/filter/DiffTreeFilter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.variantsync.diffdetective.diff.difftree.DiffNode;
44
import org.variantsync.diffdetective.diff.difftree.DiffTree;
55

6-
import static org.variantsync.diffdetective.pattern.proposed.ProposedElementaryPatterns.*;
6+
import static org.variantsync.diffdetective.editclass.proposed.ProposedEditClasses.*;
77

88
/**
99
* A filter on DiffTrees that is equipped with some metadata T (e.g., for debugging or logging).
@@ -33,7 +33,7 @@ public static TaggedPredicate<String, DiffTree> Any() {
3333
*/
3434
public static TaggedPredicate<String, DiffTree> moreThanOneArtifactNode() {
3535
return new TaggedPredicate<>(
36-
"has more than one elementary pattern",
36+
"has more than one artifact node",
3737
tree -> tree.count(DiffNode::isArtifact) > 1
3838
);
3939
}
@@ -65,10 +65,10 @@ public static TaggedPredicate<String, DiffTree> consistent() {
6565
/**
6666
* Returns a tagged predicate that returns true iff
6767
* the DiffTree has at least one artifact node ({@link DiffNode#isArtifact()})
68-
* that does not match any pattern of
69-
* {@link org.variantsync.diffdetective.pattern.proposed.ProposedElementaryPatterns#AddToPC},
70-
* {@link org.variantsync.diffdetective.pattern.proposed.ProposedElementaryPatterns#RemFromPC},
71-
* {@link org.variantsync.diffdetective.pattern.proposed.ProposedElementaryPatterns#Untouched}.
68+
* that does not match any edit class of
69+
* {@link org.variantsync.diffdetective.editclass.proposed.ProposedEditClasses#AddToPC},
70+
* {@link org.variantsync.diffdetective.editclass.proposed.ProposedEditClasses#RemFromPC},
71+
* {@link org.variantsync.diffdetective.editclass.proposed.ProposedEditClasses#Untouched}.
7272
* The predicate is tagged with a String description of the predicate.
7373
*/
7474
public static TaggedPredicate<String, DiffTree> hasAtLeastOneEditToVariability() {

src/main/java/org/variantsync/diffdetective/diff/difftree/transform/CollapseElementaryPatterns.java renamed to src/main/java/org/variantsync/diffdetective/diff/difftree/transform/CollapseEditClasses.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22

33
import org.variantsync.diffdetective.diff.difftree.DiffNode;
44
import org.variantsync.diffdetective.diff.difftree.DiffTree;
5-
import org.variantsync.diffdetective.pattern.ElementaryPatternCatalogue;
5+
import org.variantsync.diffdetective.editclass.EditClassCatalogue;
66

77
import java.util.List;
88

99
/**
10-
* Collapses elementary patterns in a DiffTree.
10+
* Collapses edit classes in a DiffTree.
1111
* Contrary to its name, this transformation leaves a DiffTree's graph structure unchanged.
1212
* This transformation uses the {@link RelabelNodes} transformer to relabel all nodes.
13-
* All {@link DiffNode#isArtifact() artifact} nodes will be labeled by their respective elementary pattern.
13+
* All {@link DiffNode#isArtifact() artifact} nodes will be labeled by their respective edit class.
1414
* All other nodes will be labeled by the {@link org.variantsync.diffdetective.diff.difftree.NodeType#name name of their node type}.
1515
* @author Paul Bittner
1616
*/
17-
public class CollapseElementaryPatterns implements DiffTreeTransformer {
17+
public class CollapseEditClasses implements DiffTreeTransformer {
1818
private final DiffTreeTransformer relabelNodes;
1919

2020
/**
21-
* Creates a new transformation that will use the given catalog of elementary patterns
21+
* Creates a new transformation that will use the given catalog of edit classes
2222
* to relabel {@link DiffNode#isArtifact() artifact} nodes.
23-
* @param patterns Catalog of patterns to match on artifact nodes.
23+
* @param editClasses Catalog of edit classes to match on artifact nodes.
2424
*/
25-
public CollapseElementaryPatterns(final ElementaryPatternCatalogue patterns) {
25+
public CollapseEditClasses(final EditClassCatalogue editClasses) {
2626
relabelNodes = new RelabelNodes(d -> {
2727
if (d.isArtifact()) {
28-
return patterns.match(d).getName();
28+
return editClasses.match(d).getName();
2929
} else {
3030
return d.nodeType.name;
3131
}

src/main/java/org/variantsync/diffdetective/diff/difftree/transform/CutNonEditedSubtrees.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* A subtree is unedited, if all nodes in it are unchanged and all nodes have the same
1313
* before and after parent.
1414
* Such subtrees just model state but not an edit and thus are removed from the validation
15-
* of our elementary edit patterns in our ESEC/FSE'22 paper.
15+
* of our edit classes in our ESEC/FSE'22 paper.
1616
* @author Paul Bittner
1717
*/
1818
public class CutNonEditedSubtrees implements DiffTreeTransformer, DiffTreeVisitor {

src/main/java/org/variantsync/diffdetective/pattern/ElementaryPattern.java renamed to src/main/java/org/variantsync/diffdetective/editclass/EditClass.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,50 @@
1-
package org.variantsync.diffdetective.pattern;
1+
package org.variantsync.diffdetective.editclass;
22

33
import org.variantsync.diffdetective.diff.difftree.DiffNode;
44
import org.variantsync.diffdetective.diff.difftree.DiffTree;
55
import org.variantsync.diffdetective.diff.difftree.DiffType;
66
import org.variantsync.diffdetective.preliminary.pattern.Pattern;
77

88
/**
9-
* Abstract class for elementary edit pattern according to our ESEC/FSE'22 paper.
9+
* Abstract edit class according to our ESEC/FSE'22 paper.
1010
* @author Paul Bittner, Sören Viegener
1111
*/
12-
public abstract class ElementaryPattern extends Pattern<DiffNode> {
12+
public abstract class EditClass extends Pattern<DiffNode> {
1313
private final DiffType diffType;
1414

1515
/**
16-
* Each elementary pattern handles exactly one DiffType.
16+
* Each edit class handles exactly one DiffType.
1717
* @param name unique identifier (see {@link Pattern}).
18-
* @param diffType This pattern matches only {@link DiffNode}s of the given {@link DiffType}.
18+
* @param diffType This edit class matches only {@link DiffNode}s of the given {@link DiffType}.
1919
*/
20-
public ElementaryPattern(final String name, final DiffType diffType) {
20+
public EditClass(final String name, final DiffType diffType) {
2121
super(name);
2222
this.diffType = diffType;
2323
}
2424

2525
/**
26-
* Returns the diff type nodes must have to be matched to this pattern.
26+
* Returns the diff type nodes matched by this edit class.
2727
*/
2828
public DiffType getDiffType() {
2929
return diffType;
3030
}
3131

3232
/**
33-
* Returns true iff given node matches this pattern.
34-
* @param artifactNode Node which has node type ARTIFACT and whose DiffType is the same as this
35-
* patterns DiffType.
33+
* Returns true iff the given node matches this edit class.
34+
* @param artifactNode Node which has node type ARTIFACT and whose DiffType is the same as {@link getDiffType()}.
3635
*/
3736
protected abstract boolean matchesArtifactNode(DiffNode artifactNode);
3837

3938
/**
40-
* Returns true if this pattern matches the given node and is an artifact.
39+
* Returns true if this edit class matches the given node and is an artifact.
4140
*/
4241
@Override
4342
public final boolean matches(DiffNode node) {
4443
return node.isArtifact() && node.diffType == diffType && matchesArtifactNode(node);
4544
}
4645

4746
/**
48-
* Returns true iff this pattern matches at leat one node on the given tree.
47+
* Returns true iff this edit class matches at leat one node on the given tree.
4948
*/
5049
public boolean anyMatch(final DiffTree t) {
5150
return t.anyMatch(this::matches);

0 commit comments

Comments
 (0)