Skip to content

Commit e688e58

Browse files
committed
Merge branch 'aspect' into splc23-views
2 parents 6968487 + 2c7c377 commit e688e58

14 files changed

Lines changed: 498 additions & 180 deletions

File tree

src/main/java/org/variantsync/diffdetective/experiments/views/Main.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,18 @@
88
import org.variantsync.diffdetective.datasets.Repository;
99
import org.variantsync.diffdetective.variation.diff.filter.DiffTreeFilter;
1010
import org.variantsync.diffdetective.variation.diff.parse.DiffTreeParseOptions;
11-
import org.variantsync.diffdetective.variation.tree.view.query.ArtifactQuery;
11+
import org.variantsync.diffdetective.variation.tree.view.relevance.Search;
1212

1313
import java.io.IOException;
1414
import java.nio.file.Path;
1515
import java.nio.file.Paths;
1616
import java.util.ArrayList;
1717
import java.util.List;
1818

19+
/**
20+
* Main entry point for running the feasibility study (Section 6) of our SPLC'23 paper
21+
* Views on Edits to Variational Software.
22+
*/
1923
public class Main {
2024
/*
2125
* There is a bug in DiffView::naive when ignoreEmptyLines is set to true under
@@ -24,19 +28,25 @@ public class Main {
2428
* commit: 2254b6c09cff8f3a83684fd159289d0e305b0e7d
2529
* patch: "src/alloc.c"
2630
* view_naive
27-
* with the following query.
31+
* with the following relevance.
2832
* What is weird that the parsing only failed when running the analyses but not when extracting the diff to a unit
2933
* test and parsing it there.
3034
* Maybe it has something to do with linebreak or whitespace characters?
3135
*/
32-
private static final ArtifactQuery bugQuery = new ArtifactQuery(" /* Check both of the above conditions, for symbols. */");
36+
private static final Search bugRelevance = new Search(" /* Check both of the above conditions, for symbols. */");
3337
public static DiffTreeParseOptions DIFFTREE_PARSE_OPTIONS =
3438
new DiffTreeParseOptions(
3539
true,
3640
false
3741
);
3842

39-
public static Analysis AnalysisFactory(Repository repo, Path repoOutputDir) {
43+
/**
44+
* Creates the analysis to perform on the given repository to run our feasibility study.
45+
* @param repo The repository to run the feasibility study on.
46+
* @param repoOutputDir The directory to which output should be written.
47+
* @return The analysis to run.
48+
*/
49+
private static Analysis AnalysisFactory(Repository repo, Path repoOutputDir) {
4050
return new Analysis(
4151
"Views Analysis",
4252
new ArrayList<>(List.of(
@@ -51,6 +61,11 @@ public static Analysis AnalysisFactory(Repository repo, Path repoOutputDir) {
5161
);
5262
}
5363

64+
/**
65+
* Main method for running the feasibility study (Section 6).
66+
* @param args see {@link AnalysisRunner.Options#DEFAULT(String[])}
67+
* @throws IOException When an IO operation within the feasibility study fails.
68+
*/
5469
public static void main(String[] args) throws IOException {
5570
final AnalysisRunner.Options defaultOptions = AnalysisRunner.Options.DEFAULT(args);
5671
final AnalysisRunner.Options analysisOptions = new AnalysisRunner.Options(

src/main/java/org/variantsync/diffdetective/experiments/views/ViewAnalysis.java

Lines changed: 159 additions & 47 deletions
Large diffs are not rendered by default.

src/main/java/org/variantsync/diffdetective/experiments/views/result/ViewEvaluation.java

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

33
import org.variantsync.diffdetective.util.CSV;
44
import org.variantsync.diffdetective.variation.diff.DiffTree;
5-
import org.variantsync.diffdetective.variation.tree.view.query.Query;
6-
import org.variantsync.diffdetective.variation.tree.view.query.VariantQuery;
5+
import org.variantsync.diffdetective.variation.diff.view.DiffView;
6+
import org.variantsync.diffdetective.variation.tree.view.relevance.Relevance;
7+
import org.variantsync.diffdetective.variation.tree.view.relevance.Configure;
78

89
import static org.variantsync.functjonal.Functjonal.intercalate;
910

11+
/**
12+
* Single data point in our feasibility study.
13+
* An object of this class corresponds to a row in the CSV files we export.
14+
* This row contains all information for benchmarking a single view generation:
15+
* @param commit The commit on which views were generated.
16+
* @param file The file of the patch that was analysed.
17+
* @param relevance The relevance predicate from which the views were generated.
18+
* @param msNaive Milliseconds it took to generate the view with the {@link DiffView#naive(DiffTree, Relevance) naive algorithm}
19+
* @param msOptimized Milliseconds it took to generate the view with the {@link DiffView#optimized(DiffTree, Relevance) optimized algorithm}
20+
* @param diffStatistics Various statistics on the variation diff of the analysed patch.
21+
* @param viewStatistics The same statistics as for the original variation diff but for the produced view.
22+
*/
1023
public record ViewEvaluation(
1124
// Repository repo,
1225
String commit,
1326
String file,
14-
Query query,
27+
Relevance relevance,
1528
long msNaive,
1629
long msOptimized,
1730
DiffStatistics diffStatistics,
1831
DiffStatistics viewStatistics
1932
) implements CSV {
33+
/**
34+
* Holds various information of a variation diff.
35+
* @param nodeCount The number of nodes contained in the variation diff.
36+
* @param annotationNodeCount The number of annotation nodes in the variation diff.
37+
*/
2038
public record DiffStatistics(int nodeCount, int annotationNodeCount) {
39+
/**
40+
* Gathers statistics of a given variation diff.
41+
* This method is side-effect free and will not alter the given diff.
42+
* @param d A variation diff to extract statistics from.
43+
* @return The extracted statistics.
44+
*/
2145
public static DiffStatistics of(final DiffTree d) {
2246
final int[] nodeCount = {0};
2347
final int[] annotationNodeCount = {0};
@@ -33,6 +57,13 @@ public static DiffStatistics of(final DiffTree d) {
3357
}
3458
}
3559

60+
/**
61+
* Creates the header for a CSV file in which objects of this class
62+
* can be rows.
63+
* @param delimiter The delimiter to use between rows in the CSV file (see {@link CSV#DEFAULT_CSV_DELIMITER}.
64+
* @return A string that should be the first row in a CSV file with objects of this class
65+
* as rows.
66+
*/
3667
public static String makeHeader(String delimiter) {
3768
return intercalate(delimiter,
3869
// "repository",
@@ -55,7 +86,7 @@ public String toCSV(String delimiter) {
5586
// repo.getRepositoryName(),
5687
commit,
5788
file,
58-
query.getFunctionName(),
89+
relevance.getFunctionName(),
5990
// getQueryArguments(),
6091
msNaive,
6192
msOptimized,
@@ -65,11 +96,4 @@ public String toCSV(String delimiter) {
6596
viewStatistics.annotationNodeCount
6697
);
6798
}
68-
69-
private String getQueryArguments() {
70-
if (query instanceof VariantQuery) {
71-
return query.parametersToString();
72-
}
73-
return "";
74-
}
7599
}

src/main/java/org/variantsync/diffdetective/util/fide/FixTrueFalse.java

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

1414
/**
1515
* Class to fix bugs related to {@link True} and {@link False} of FeatureIDE.
16-
* See: https://github.com/FeatureIDE/FeatureIDE/issues/1111
17-
* See: https://github.com/FeatureIDE/FeatureIDE/issues/1333
16+
* See: <a href="https://github.com/FeatureIDE/FeatureIDE/issues/1111">FeatureIDE Issue 1111</a>
17+
* See: <a href="https://github.com/FeatureIDE/FeatureIDE/issues/1333">FeatureIDE Issue 1333</a>
1818
*
1919
* This class contains constants for representing atomic values true and false in formulas
2020
* as well as a conversion method for parsing certain feature names to true and false, respectively.

0 commit comments

Comments
 (0)