Skip to content

Commit ef0a0a3

Browse files
committed
documentation + minor fixes
1 parent adc068f commit ef0a0a3

6 files changed

Lines changed: 17 additions & 16 deletions

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ public static void analyzeAsync(
9090
final InvocationCounter<RevCommit, RevCommit> numberOfTotalCommits = InvocationCounter.justCount();
9191
final Iterator<CommitHistoryAnalysisTask> tasks = new MappedIterator<>(
9292
/// 1.) Retrieve COMMITS_TO_PROCESS_PER_THREAD commits from the differ and cluster them into one list.
93-
new ClusteredIterator<>(differ.yieldRevCommitsAfter(numberOfTotalCommits), commitsToProcessPerThread),
93+
new ClusteredIterator<>(
94+
differ.yieldRevCommitsAfter(numberOfTotalCommits),
95+
commitsToProcessPerThread
96+
),
9497
/// 2.) Create a MiningTask for the list of commits. This task will then be processed by one
9598
/// particular thread.
9699
commitList -> taskFactory.create(

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,7 @@
2929
import org.variantsync.functjonal.iteration.SideEffectIterator;
3030
import org.variantsync.functjonal.iteration.Yield;
3131

32-
import java.io.BufferedReader;
33-
import java.io.ByteArrayOutputStream;
34-
import java.io.IOException;
35-
import java.io.InputStreamReader;
36-
import java.io.LineNumberReader;
37-
import java.io.StringReader;
38-
import java.io.UncheckedIOException;
32+
import java.io.*;
3933
import java.nio.charset.StandardCharsets;
4034
import java.util.ArrayList;
4135
import java.util.Iterator;
@@ -145,6 +139,8 @@ private Yield<RevCommit> yieldAllValidIn(final Iterator<RevCommit> commitsIterat
145139
while (commitsIterator.hasNext()) {
146140
final RevCommit c = commitsIterator.next();
147141
// If this commit is filtered, go to the next one.
142+
// filter returns true if we want to include the commit
143+
// so if we do not want to filter it, we do not want to have it. Thus skip.
148144
if (!diffFilter.filter(c)) {
149145
continue;
150146
}

src/main/java/org/variantsync/diffdetective/diff/difftree/DiffNode.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import org.variantsync.diffdetective.util.fide.FixTrueFalse;
1010

1111
import java.util.*;
12-
import java.util.stream.Collectors;
1312
import java.util.function.Function;
13+
import java.util.stream.Collectors;
1414

1515
import static org.variantsync.diffdetective.util.fide.FormulaUtils.negate;
1616

@@ -528,7 +528,7 @@ private List<Node> getFeatureMappingClauses(Function<DiffNode, DiffNode> parentO
528528
List<Node> and = new ArrayList<>();
529529

530530
if (isElif()) {
531-
and.add(featureMapping);
531+
and.add(getDirectFeatureMapping());
532532
}
533533

534534
// Negate all previous cases
@@ -537,18 +537,19 @@ private List<Node> getFeatureMappingClauses(Function<DiffNode, DiffNode> parentO
537537
if (ancestor.isElif()) {
538538
and.add(negate(ancestor.getDirectFeatureMapping()));
539539
} else {
540-
Assert.assertTrue(ancestor.isCode());
540+
throw new RuntimeException("Expected If or Elif above Else or Elif but got " + ancestor.codeType + " from " + ancestor);
541+
// Assert.assertTrue(ancestor.isCode());
541542
}
542543
ancestor = parentOf.apply(ancestor);
543544
}
544545
and.add(negate(ancestor.getDirectFeatureMapping()));
545546

546547
return and;
547548
} else if (isCode()) {
548-
return List.of(parent.getFeatureMapping(parentOf));
549+
return parent.getFeatureMappingClauses(parentOf);
549550
}
550551

551-
return List.of(featureMapping);
552+
return List.of(getDirectFeatureMapping());
552553
}
553554

554555
private Node getFeatureMapping(Function<DiffNode, DiffNode> parentOf) {

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
@@ -22,7 +22,7 @@ public void visit(final DiffTreeTraversal traversal, final DiffNode subtree) {
2222
/*
2323
* Collapse all children c for which
2424
* 1. all children of c could be collapsed or c never had children
25-
* 2. that was not relocated due to an edit.
25+
* 2. that was not relocated due to an edit (beforeparent and afterparent are the same).
2626
*
2727
* Note: c satisfies 2 => c.isNon() and subtree.isNon()
2828
* We thus only cut subtrees that (a) were not edited themselves and (b) were not relocated.

src/main/java/org/variantsync/diffdetective/load/GitLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public static Git fromRemote(Path localPath, URI remoteURI) {
5656

5757
try {
5858
Logger.info("Cloning {} to {}.", remoteURI, localPath);
59-
return Git.cloneRepository()
59+
return Git
60+
.cloneRepository()
6061
.setURI(remoteURI.toString())
6162
.setDirectory(localPath.toFile())
6263
.setProgressMonitor(new LoggingProgressMonitor())

src/main/java/org/variantsync/diffdetective/validation/Validation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public static void main(String[] args) throws IOException {
9999
final ParseOptions.DiffStoragePolicy diffStoragePolicy = ParseOptions.DiffStoragePolicy.DO_NOT_REMEMBER;
100100

101101
final Path inputDir = Paths.get("..", "DiffDetectiveMining");
102-
final Path outputDir = Paths.get("results", "difftrees");
102+
final Path outputDir = Paths.get("results", "validation", "current");
103103

104104
final List<Repository> repos;
105105
final List<DatasetDescription> datasets = DefaultDatasets.loadDefaultDatasets();

0 commit comments

Comments
 (0)