Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion STATUS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The `proofs` Haskell project provides an extended formal specification of our th
The library is accompanied by a small demo application that shows an example test case for our proof for completeness, by creating a variation tree diff from two variation trees and re-projecting them.

## Claims
We claim the _Artifacts Available_ badge as we made our artefacts publicly available on [Github][ddgithub] and [Zenodo][ddzenodo].
We claim the _Artifacts Available_ badge as we made our artifacts publicly available on [Github][ddgithub] and [Zenodo][ddzenodo].

We claim the _Artifacts Evaluated Reusable_ badge as we implemented DiffDetective as a reusable library (see above).
Furthermore, both DiffDetective and our Haskell formalization serve as reference implementations if researchers or practitioners want to reimplement our theory in other programming languages.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import org.variantsync.diffdetective.diff.difftree.serialize.DiffTreeSerializeDebugData;
import org.variantsync.diffdetective.diff.result.DiffError;
import org.variantsync.diffdetective.metadata.ElementaryPatternCount;
import org.variantsync.diffdetective.metadata.EditClassCount;
import org.variantsync.diffdetective.metadata.ExplainedFilterSummary;
import org.variantsync.diffdetective.metadata.Metadata;
import org.variantsync.diffdetective.pattern.elementary.proposed.ProposedElementaryPatterns;
import org.variantsync.diffdetective.editclass.proposed.ProposedEditClasses;
import org.variantsync.functjonal.Functjonal;
import org.variantsync.functjonal.category.InplaceMonoid;
import org.variantsync.functjonal.category.InplaceSemigroup;
Expand Down Expand Up @@ -55,7 +55,7 @@ public class AnalysisResult implements Metadata<AnalysisResult> {
a.max.set(CommitProcessTime.max(a.max, b.max));
a.debugData.append(b.debugData);
a.filterHits.append(b.filterHits);
a.elementaryPatternCounts.append(b.elementaryPatternCounts);
a.editClassCounts.append(b.editClassCounts);
MergeMap.putAllValues(a.customInfo, b.customInfo, Semigroup.assertEquals());
a.diffErrors.append(b.diffErrors);
};
Expand All @@ -80,7 +80,7 @@ public class AnalysisResult implements Metadata<AnalysisResult> {
public final CommitProcessTime min, max;
public final DiffTreeSerializeDebugData debugData;
public ExplainedFilterSummary filterHits;
public ElementaryPatternCount elementaryPatternCounts;
public EditClassCount editClassCounts;
private final LinkedHashMap<String, String> customInfo = new LinkedHashMap<>();
private final MergeMap<DiffError, Integer> diffErrors = new MergeMap<>(new HashMap<>(), Integer::sum);

Expand Down Expand Up @@ -152,7 +152,7 @@ public AnalysisResult(
this.runtimeWithMultithreadingInSeconds = runtimeWithMultithreadingInSeconds;
this.debugData = debugData;
this.filterHits = filterHits;
this.elementaryPatternCounts = new ElementaryPatternCount();
this.editClassCounts = new EditClassCount();
this.min = min;
this.max = max;
}
Expand Down Expand Up @@ -189,7 +189,7 @@ public static AnalysisResult importFrom(final Path p, final Map<String, BiConsum
AnalysisResult result = new AnalysisResult();

final List<String> filterHitsLines = new ArrayList<>();
final List<String> elementaryPatternCountsLines = new ArrayList<>();
final List<String> editClassCountsLines = new ArrayList<>();

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

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

result.filterHits = ExplainedFilterSummary.parse(filterHitsLines);
result.elementaryPatternCounts = ElementaryPatternCount.parse(elementaryPatternCountsLines, p.toString());
result.editClassCounts = EditClassCount.parse(editClassCountsLines, p.toString());

return result;
}
Expand Down Expand Up @@ -289,7 +289,7 @@ public LinkedHashMap<String, Object> snapshot() {
snap.putAll(customInfo);
snap.putAll(debugData.snapshot());
snap.putAll(filterHits.snapshot());
snap.putAll(elementaryPatternCounts.snapshot());
snap.putAll(editClassCounts.snapshot());
snap.putAll(Functjonal.bimap(diffErrors, error -> ERROR_BEGIN + error + ERROR_END, Object::toString));
return snap;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package org.variantsync.diffdetective.analysis;

import org.variantsync.diffdetective.editclass.EditClass;
import org.variantsync.diffdetective.editclass.EditClassCatalogue;
import org.variantsync.diffdetective.util.CSV;

import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

/**
* Gathers statistics about matching edit classes.
* @author Paul Bittner
*/
public class EditClassCount implements CSV {
private final EditClassCatalogue catalogue;
private final Map<EditClass, Integer> editClassCounts;

/**
* Creates a new counter object for the given catalogue of edit classes.
* @param catalogue The catalogue whose edit classes to match and count.
*/
public EditClassCount(final EditClassCatalogue catalogue) {
this.catalogue = catalogue;
this.editClassCounts = new HashMap<>();
catalogue.all().forEach(e -> editClassCounts.put(e, 0));
}

/**
* Increment the count for the given edit class.
* The given edit class is assumed to be part of this counts catalog.
* @see EditClassCount#EditClassCount(EditClassCatalogue)
* @param editClass The edit class whose count to increase by one.
*/
public void increment(final EditClass editClass) {
editClassCounts.computeIfPresent(editClass, (p, i) -> i + 1);
}

@Override
public String toCSV(final String delimiter) {
return catalogue.all().stream()
.map(editClassCounts::get)
.map(Object::toString)
.collect(Collectors.joining(delimiter));
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.function.Consumer;

/**
* An analyses that is performed for the entire commit histories of each given git repositoy.
* An analyses that is performed for the entire commit histories of each given git repository.
* @param repositoriesToAnalyze The repositories whose commit history should be analyzed.
* @param outputDir The directory to which any produced results should be written.
* @param commitsToProcessPerThread Number of commits that should be processed by each single thread if multithreading is used.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
package org.variantsync.diffdetective.analysis;

import org.variantsync.diffdetective.diff.PatchDiff;
import org.variantsync.diffdetective.pattern.elementary.ElementaryPatternCatalogue;
import org.variantsync.diffdetective.editclass.EditClassCatalogue;
import org.variantsync.diffdetective.util.CSV;

/**
* Statistics for processing a patch in a commit.
* @param patchDiff The diff of the processed patch.
* @param elementaryPatternCount Count statistics for the elementary edit patterns matched to the edits in the patch.
* @param editClassCount Count statistics for the edit class matched to the edits in the patch.
* @author Paul Bittner
*/
public record PatchStatistics(
PatchDiff patchDiff,
ElementaryPatternCount elementaryPatternCount) implements CSV {
EditClassCount editClassCount) implements CSV {
/**
* Creates empty patch statistics for the given catalogue of edit patterns.
* Creates empty patch statistics for the given catalogue of edit classes.
* @param patch The patch to gather statistics for.
* @param catalogue A catalogue of elementary edit patterns which should be used for classifying edits.
* @param catalogue A catalogue of edit classes which should be used for classifying edits.
*/
public PatchStatistics(final PatchDiff patch, final ElementaryPatternCatalogue catalogue) {
this(patch, new ElementaryPatternCount(catalogue));
public PatchStatistics(final PatchDiff patch, final EditClassCatalogue catalogue) {
this(patch, new EditClassCount(catalogue));
}

@Override
public String toCSV(final String delimiter) {
return patchDiff.getCommitHash() + delimiter + patchDiff.getFileName() + delimiter + elementaryPatternCount.toCSV(delimiter);
return patchDiff.getCommitHash() + delimiter + patchDiff.getFileName() + delimiter + editClassCount.toCSV(delimiter);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ public final class DiffGraph {

private DiffGraph() {}

/**
* Returns true iff the given node has no parents (i.e., is a root candidate).
*/
public static boolean hasNoParents(final DiffNode node) {
return node.getBeforeParent() == null && node.getAfterParent() == null;
}

/**
* Invokes {@link DiffGraph#fromNodes(Collection, DiffTreeSource)} )} with an unknown DiffTreeSource.
*/
Expand All @@ -37,7 +30,7 @@ public static DiffTree fromNodes(final Collection<DiffNode> nodes, final DiffTre
final DiffNode newRoot = DiffNode.createRoot();
newRoot.setLabel(DIFFGRAPH_LABEL);
nodes.stream()
.filter(DiffGraph::hasNoParents)
.filter(DiffNode::isRoot)
.forEach(n ->
n.diffType.matchBeforeAfter(
() -> newRoot.addBeforeChild(n),
Expand Down
Loading