Skip to content

Commit fa1b84c

Browse files
committed
Merge branch 'merge-thesis_bm' into develop
2 parents dfe439a + 9f567fc commit fa1b84c

131 files changed

Lines changed: 7065 additions & 5162 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.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Project name | Domain | Source code available (**y**es/**n**o)? | Is it a git repository (**y**es/**n**o)? | Repository URL | Clone URL | Estimated number of commits
2+
-------------------|-------------------------|-----------------------------------------|------------------------------------------|--------------------------------------------------------------|----------------------------------------------------|-----------------------------
3+
vim | text editor | y | y | https://github.com/vim/vim | https://github.com/DiffDetective/vim.git | 15,274
4+
busybox | embedded systems | y | y | https://git.busybox.net/busybox | https://github.com/DiffDetective/busybox | 17,447
5+
Marlin | 3d printing | y | y | https://github.com/MarlinFirmware/Marlin | https://github.com/DiffDetective/Marlin.git | 19,258

pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,19 @@
100100
<version>1.0-SNAPSHOT</version>
101101
</dependency>
102102

103+
<dependency>
104+
<groupId>com.github.gumtreediff</groupId>
105+
<artifactId>core</artifactId>
106+
<version>3.0.0</version>
107+
</dependency>
108+
<dependency>
109+
<!-- For Gumtree -->
110+
<groupId>org.atteo.classindex</groupId>
111+
<artifactId>classindex</artifactId>
112+
<version>3.11</version>
113+
<scope>test</scope>
114+
</dependency>
115+
103116
<dependency>
104117
<groupId>net.lingala.zip4j</groupId>
105118
<artifactId>zip4j</artifactId>
@@ -118,6 +131,12 @@
118131
<version>3.12.0</version>
119132
</dependency>
120133

134+
<dependency>
135+
<groupId>commons-io</groupId>
136+
<artifactId>commons-io</artifactId>
137+
<version>2.12.0</version>
138+
</dependency>
139+
121140
<dependency>
122141
<groupId>org.tinylog</groupId>
123142
<artifactId>tinylog-api</artifactId>

deploy_libs.sh renamed to scripts/deploy_libs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
# FeatureIDE
44
mvn deploy:deploy-file -DgroupId=de.ovgu -DartifactId=featureide.lib.fm -Dversion=3.8.1 -Durl=file:./local-maven-repo/ -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile=./lib/de.ovgu.featureide.lib.fm-v3.8.1.jar

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ protected void processCommit() throws Exception {
450450
}
451451

452452
processPatch();
453+
} catch (Throwable t) {
454+
Logger.error("error during {} {}", currentPatch.getFileName(), currentPatch.getCommitHash());
455+
throw t;
453456
} finally {
454457
runReverseHook(patchHook, Hooks::endPatch);
455458
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ public final class MetadataKeys {
3232

3333
public final static String EXPORTED_COMMITS = "exported commits";
3434
public final static String EXPORTED_TREES = "exported trees";
35+
36+
public final static String EDIT_CLASS_MOVEMENT = "edit class movement";
3537
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.variantsync.diffdetective.gumtree;
2+
3+
import org.variantsync.diffdetective.variation.diff.DiffNode;
4+
import org.variantsync.diffdetective.variation.diff.Projection;
5+
import org.variantsync.diffdetective.variation.diff.Time;
6+
import org.variantsync.diffdetective.variation.tree.VariationNode;
7+
8+
/**
9+
* Adapter for running Gumtree's matching algorithms on the projections of variation diffs.
10+
*
11+
* This class is almost identical to {@link VariationTreeAdapter} except that it provides type safe
12+
* access to the projected {@link DiffNode}.
13+
*/
14+
public class DiffTreeAdapter extends VariationTreeAdapter {
15+
public DiffTreeAdapter(DiffNode node, Time time) {
16+
super(node.projection(time));
17+
}
18+
19+
public DiffTreeAdapter(Projection node) {
20+
super(node);
21+
}
22+
23+
protected VariationTreeAdapter newInstance(VariationNode<?> node) {
24+
return new DiffTreeAdapter((Projection)node);
25+
}
26+
27+
public DiffNode getDiffNode() {
28+
return ((Projection)getVariationNode()).getBackingNode();
29+
}
30+
}
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
package org.variantsync.diffdetective.gumtree;
2+
3+
import java.util.ArrayList;
4+
import java.util.Iterator;
5+
import java.util.Map.Entry;
6+
import java.util.stream.Collectors;
7+
8+
import org.variantsync.diffdetective.variation.tree.VariationNode;
9+
10+
import com.github.gumtreediff.tree.AbstractTree;
11+
import com.github.gumtreediff.tree.Tree;
12+
import com.github.gumtreediff.tree.Type;
13+
import com.github.gumtreediff.tree.TypeSet;
14+
15+
/**
16+
* Adapter for running Gumtree's matching algorithms on variation trees.
17+
*
18+
* This class is an <a href="https://en.wikipedia.org/wiki/Adapter_pattern">adapter</a> for a
19+
* snapshot of a variation tree. This means that it doesn't reflect most changes to the underlying
20+
* variation tree. Essentially it creates a copy of the tree structure and the labels of a variation
21+
* tree by stores a reference to the variation node which it adapts.
22+
*/
23+
public class VariationTreeAdapter extends AbstractTree {
24+
private String cachedLabel;
25+
private VariationNode<?> backingNode;
26+
27+
public VariationTreeAdapter(VariationNode<?> node) {
28+
this.backingNode = node;
29+
30+
if (backingNode.isConditionalAnnotation()) {
31+
cachedLabel = backingNode.getFormula().toString();
32+
} else {
33+
cachedLabel = backingNode.getLabelLines().stream().collect(Collectors.joining("\n"));
34+
}
35+
36+
var children = new ArrayList<Tree>(node.getChildren().size());
37+
for (var child : node.getChildren()) {
38+
children.add(newInstance(child));
39+
}
40+
setChildren(children);
41+
}
42+
43+
protected VariationTreeAdapter newInstance(VariationNode<?> node) {
44+
return new VariationTreeAdapter(node);
45+
}
46+
47+
public VariationNode<?> getVariationNode() {
48+
return backingNode;
49+
}
50+
51+
52+
@Override
53+
public String getLabel() {
54+
return cachedLabel;
55+
}
56+
57+
/**
58+
* Uses line numbers instead of byte indexes.
59+
*/
60+
@Override
61+
public int getLength() {
62+
return 1;
63+
}
64+
65+
@Override
66+
public Iterator<Entry<String, Object>> getMetadata() {
67+
throw new UnsupportedOperationException();
68+
}
69+
70+
@Override
71+
public Object getMetadata(String arg0) {
72+
throw new UnsupportedOperationException();
73+
}
74+
75+
/**
76+
* Uses line numbers instead of byte indexes.
77+
*/
78+
@Override
79+
public int getPos() {
80+
return backingNode.getLineRange().fromInclusive();
81+
}
82+
83+
@Override
84+
public Type getType() {
85+
return TypeSet.type(backingNode.getNodeType().toString());
86+
}
87+
88+
@Override
89+
public void setLabel(String label) {
90+
throw new UnsupportedOperationException();
91+
}
92+
93+
@Override
94+
public void setLength(int length) {
95+
throw new UnsupportedOperationException();
96+
}
97+
98+
@Override
99+
public Object setMetadata(String name, Object value) {
100+
throw new UnsupportedOperationException();
101+
}
102+
103+
@Override
104+
public void setPos(int pos) {
105+
throw new UnsupportedOperationException();
106+
}
107+
108+
@Override
109+
public void setType(Type type) {
110+
throw new UnsupportedOperationException();
111+
}
112+
113+
@Override
114+
public Tree deepCopy() {
115+
throw new UnsupportedOperationException();
116+
}
117+
}

src/main/java/org/variantsync/diffdetective/metadata/Metadata.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static <T> T mergeEqual(T a, T b) {
7373
* @param properties The key-value store to print.
7474
* @return A string showing all key-value pairs.
7575
*/
76-
static String show(final Map<String, ?> properties) {
76+
public static String show(final Map<String, ?> properties) {
7777
StringBuilder result = new StringBuilder();
7878
for (final Map.Entry<String, ?> property : properties.entrySet()) {
7979
result.append(show(property.getKey(), property.getValue()));

src/main/java/org/variantsync/diffdetective/preliminary/pattern/semantic/MoveElse.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import java.util.Collection;
88
import java.util.Optional;
9+
import java.util.stream.Stream;
910

1011
import static org.variantsync.diffdetective.variation.diff.Time.AFTER;
1112

@@ -37,13 +38,11 @@ public Optional<PatternMatch<DiffNode>> match(DiffNode annotationNode) {
3738
return Optional.empty();
3839
}
3940

40-
Collection<DiffNode> commonAddElse = annotationNode.getAllChildren();
41-
commonAddElse.retainAll(annotationNode.getParent(AFTER).getAllChildren());
41+
Collection<DiffNode> annotationChildren = annotationNode.getParent(AFTER).getAllChildrenSet();
42+
Stream<DiffNode> commonAddElse = annotationNode.getAllChildrenStream().filter(annotationChildren::contains);
43+
Stream<DiffNode> commonRemElse = removedElse.getAllChildrenStream().filter(annotationChildren::contains);
4244

43-
Collection<DiffNode> commonRemElse = removedElse.getAllChildren();
44-
commonRemElse.retainAll(annotationNode.getParent(AFTER).getAllChildren());
45-
46-
if(commonAddElse.isEmpty() && commonRemElse.isEmpty()){
45+
if(commonAddElse.limit(1).count() == 0 && commonRemElse.limit(1).count() == 0){
4746
return Optional.empty();
4847
}
4948

src/main/java/org/variantsync/diffdetective/util/Assert.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,18 @@ public static void assertTrue(boolean cond, String errorMessage) {
6464
}
6565
}
6666

67+
public static void assertFalse(boolean condition) {
68+
assertTrue(!condition);
69+
}
70+
71+
public static void assertFalse(boolean condition, final Supplier<String> errorMessage) {
72+
assertTrue(!condition, errorMessage);
73+
}
74+
75+
public static void assertFalse(boolean condition, String errorMessage) {
76+
assertTrue(!condition, errorMessage);
77+
}
78+
6779
/** Throws {@link AssertionError} with {@code errorMessage} as error message. */
6880
public static void fail(String errorMessage) {
6981
throw new AssertionError(errorMessage);
@@ -89,7 +101,7 @@ public static <T> void assertEquals(T expected, T actual) {
89101
fail("expected is null but actual is not!");
90102
}
91103
} else {
92-
assertTrue(expected.equals(actual));
104+
assertTrue(expected.equals(actual), expected + " != " + actual);
93105
}
94106
}
95107
}

0 commit comments

Comments
 (0)