Skip to content

Commit a19afcd

Browse files
committed
made old ba analysis deprecated (use respective branch to run it)
1 parent de9059e commit a19afcd

39 files changed

Lines changed: 458 additions & 303 deletions
Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
package pattern;
22

3-
import analysis.data.PatternMatch;
4-
import evaluation.FeatureContext;
5-
6-
import java.util.Optional;
7-
83
public abstract class EditPattern<E> {
94
protected String name;
105

116
public EditPattern(final String name) {
127
this.name = name;
138
}
149

15-
public abstract Optional<PatternMatch<E>> match(E x);
16-
17-
public abstract FeatureContext[] getFeatureContexts(PatternMatch<E> patternMatch);
10+
public abstract boolean matches(E e);
1811

1912
public String getName(){
2013
return this.name;
2114
}
2215

2316
@Override
2417
public String toString() {
25-
return this.name;
18+
return getName();
2619
}
2720
}

src/main/java/pattern/InvalidPatchPattern.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/main/java/pattern/atomic/AtomicPattern.java

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
package pattern.atomic;
22

3-
import analysis.data.PatternMatch;
43
import diff.difftree.DiffNode;
54
import diff.difftree.DiffTree;
65
import diff.difftree.DiffType;
76
import pattern.EditPattern;
87

9-
import java.util.Optional;
10-
118
public abstract class AtomicPattern extends EditPattern<DiffNode> {
129
private final DiffType diffType;
1310

@@ -29,35 +26,14 @@ public DiffType getDiffType() {
2926
*/
3027
protected abstract boolean matchesCodeNode(DiffNode codeNode);
3128

32-
/**
33-
* Creates a PatternMatch object for the given codeNode.
34-
* Assumes {@code matches(codeNode) == true}.
35-
* @param codeNode A node that was matched to this pattern.
36-
* @return A PatternMatch object containing metadata when matching this pattern to the given node.
37-
*/
38-
protected abstract PatternMatch<DiffNode> createMatchOnCodeNode(DiffNode codeNode);
39-
4029
/**
4130
* @return True if this pattern matches the given node and node is code.
4231
*/
32+
@Override
4333
public final boolean matches(DiffNode node) {
4434
return node.isCode() && node.diffType == diffType && matchesCodeNode(node);
4535
}
4636

47-
/**
48-
* Matches this pattern onto the given node.
49-
* @param x The node to match this pattern on.
50-
* @return A {@link PatternMatch<DiffNode>} if the given node matches this pattern (i.e., {@code matches(x) == true}). Empty otherwise.
51-
*/
52-
@Override
53-
public final Optional<PatternMatch<DiffNode>> match(DiffNode x) {
54-
if (matches(x)) {
55-
return Optional.of(createMatchOnCodeNode(x));
56-
}
57-
58-
return Optional.empty();
59-
}
60-
6137
public boolean anyMatch(final DiffTree t) {
6238
return t.anyMatch(this::matches);
6339
}
Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package pattern.atomic.proposed;
22

3-
import analysis.data.PatternMatch;
4-
import diff.Lines;
53
import diff.difftree.DiffNode;
64
import diff.difftree.DiffType;
7-
import evaluation.FeatureContext;
8-
import org.prop4j.Node;
95
import pattern.atomic.AtomicPattern;
106

117
final class AddToPC extends AtomicPattern {
@@ -17,21 +13,4 @@ final class AddToPC extends AtomicPattern {
1713
protected boolean matchesCodeNode(DiffNode node) {
1814
return !node.getAfterParent().isAdd();
1915
}
20-
21-
@Override
22-
public PatternMatch<DiffNode> createMatchOnCodeNode(DiffNode codeNode) {
23-
final Node fm = codeNode.getAfterParent().getAfterFeatureMapping();
24-
final Lines diffLines = codeNode.getLinesInDiff();
25-
26-
return new PatternMatch<>(this,
27-
diffLines.getFromInclusive(), diffLines.getToExclusive(), fm
28-
);
29-
}
30-
31-
@Override
32-
public FeatureContext[] getFeatureContexts(PatternMatch<DiffNode> patternMatch) {
33-
return new FeatureContext[]{
34-
new FeatureContext(patternMatch.getFeatureMappings()[0])
35-
};
36-
}
3716
}
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package pattern.atomic.proposed;
22

3-
import analysis.data.PatternMatch;
4-
import diff.Lines;
53
import diff.difftree.DiffNode;
64
import diff.difftree.DiffType;
7-
import evaluation.FeatureContext;
8-
import org.prop4j.Node;
95
import pattern.atomic.AtomicPattern;
106

117
final class AddWithMapping extends AtomicPattern {
@@ -17,22 +13,4 @@ final class AddWithMapping extends AtomicPattern {
1713
protected boolean matchesCodeNode(DiffNode codeNode) {
1814
return codeNode.getAfterParent().isAdd();
1915
}
20-
21-
@Override
22-
protected PatternMatch<DiffNode> createMatchOnCodeNode(DiffNode codeNode) {
23-
final Node fm = codeNode.getAfterParent().getAfterFeatureMapping();
24-
final Lines diffLines = codeNode.getLinesInDiff();
25-
26-
return new PatternMatch<>(this,
27-
diffLines.getFromInclusive(),
28-
diffLines.getToExclusive(), fm
29-
);
30-
}
31-
32-
@Override
33-
public FeatureContext[] getFeatureContexts(PatternMatch<DiffNode> patternMatch) {
34-
return new FeatureContext[]{
35-
new FeatureContext(patternMatch.getFeatureMappings()[0])
36-
};
37-
}
3816
}
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package pattern.atomic.proposed;
22

33
import analysis.SAT;
4-
import analysis.data.PatternMatch;
5-
import diff.Lines;
64
import diff.difftree.DiffNode;
75
import diff.difftree.DiffType;
8-
import evaluation.FeatureContext;
96
import org.prop4j.Node;
107
import pattern.atomic.AtomicPattern;
118

@@ -20,17 +17,4 @@ protected boolean matchesCodeNode(DiffNode codeNode) {
2017
final Node pca = codeNode.getAfterFeatureMapping();
2118
return SAT.implies(pcb, pca) && !SAT.implies(pca, pcb);
2219
}
23-
24-
@Override
25-
public PatternMatch<DiffNode> createMatchOnCodeNode(DiffNode codeNode) {
26-
final Lines diffLines = codeNode.getLinesInDiff();
27-
return new PatternMatch<>(this,
28-
diffLines.getFromInclusive(), diffLines.getToExclusive()
29-
);
30-
}
31-
32-
@Override
33-
public FeatureContext[] getFeatureContexts(PatternMatch<DiffNode> patternMatch) {
34-
return new FeatureContext[0];
35-
}
3620
}
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package pattern.atomic.proposed;
22

33
import analysis.SAT;
4-
import analysis.data.PatternMatch;
5-
import diff.Lines;
64
import diff.difftree.DiffNode;
75
import diff.difftree.DiffType;
8-
import evaluation.FeatureContext;
96
import org.prop4j.Node;
107
import pattern.atomic.AtomicPattern;
118

@@ -20,17 +17,4 @@ protected boolean matchesCodeNode(DiffNode codeNode) {
2017
final Node pca = codeNode.getAfterFeatureMapping();
2118
return !SAT.implies(pcb, pca) && !SAT.implies(pca, pcb);
2219
}
23-
24-
@Override
25-
public PatternMatch<DiffNode> createMatchOnCodeNode(DiffNode codeNode) {
26-
final Lines diffLines = codeNode.getLinesInDiff();
27-
return new PatternMatch<>(this,
28-
diffLines.getFromInclusive(), diffLines.getToExclusive()
29-
);
30-
}
31-
32-
@Override
33-
public FeatureContext[] getFeatureContexts(PatternMatch<DiffNode> patternMatch) {
34-
return new FeatureContext[0];
35-
}
3620
}
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
package pattern.atomic.proposed;
22

33
import analysis.SAT;
4-
import analysis.data.PatternMatch;
5-
import diff.Lines;
64
import diff.difftree.DiffNode;
75
import diff.difftree.DiffType;
8-
import evaluation.FeatureContext;
96
import org.prop4j.Node;
107
import pattern.atomic.AtomicPattern;
118

@@ -20,17 +17,4 @@ protected boolean matchesCodeNode(DiffNode codeNode) {
2017
final Node pca = codeNode.getAfterFeatureMapping();
2118
return SAT.equivalent(pcb, pca) && !codeNode.beforePathEqualsAfterPath();
2219
}
23-
24-
@Override
25-
public PatternMatch<DiffNode> createMatchOnCodeNode(DiffNode codeNode) {
26-
final Lines diffLines = codeNode.getLinesInDiff();
27-
return new PatternMatch<>(this,
28-
diffLines.getFromInclusive(), diffLines.getToExclusive()
29-
);
30-
}
31-
32-
@Override
33-
public FeatureContext[] getFeatureContexts(PatternMatch<DiffNode> patternMatch) {
34-
return new FeatureContext[0];
35-
}
3620
}
Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package pattern.atomic.proposed;
22

3-
import analysis.data.PatternMatch;
4-
import diff.Lines;
53
import diff.difftree.DiffNode;
64
import diff.difftree.DiffType;
7-
import evaluation.FeatureContext;
8-
import org.prop4j.Node;
95
import pattern.atomic.AtomicPattern;
106

117
final class RemFromPC extends AtomicPattern {
@@ -17,21 +13,4 @@ final class RemFromPC extends AtomicPattern {
1713
protected boolean matchesCodeNode(DiffNode codeNode) {
1814
return !codeNode.getBeforeParent().isRem();
1915
}
20-
21-
@Override
22-
public PatternMatch<DiffNode> createMatchOnCodeNode(DiffNode codeNode) {
23-
final Node fm = codeNode.getBeforeParent().getBeforeFeatureMapping();
24-
final Lines diffLines = codeNode.getLinesInDiff();
25-
26-
return new PatternMatch<>(this,
27-
diffLines.getFromInclusive(), diffLines.getToExclusive(), fm
28-
);
29-
}
30-
31-
@Override
32-
public FeatureContext[] getFeatureContexts(PatternMatch<DiffNode> patternMatch) {
33-
return new FeatureContext[]{
34-
new FeatureContext(patternMatch.getFeatureMappings()[0], true)
35-
};
36-
}
3716
}
Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
package pattern.atomic.proposed;
22

3-
import analysis.data.PatternMatch;
4-
import diff.Lines;
53
import diff.difftree.DiffNode;
64
import diff.difftree.DiffType;
7-
import evaluation.FeatureContext;
8-
import org.prop4j.Node;
95
import pattern.atomic.AtomicPattern;
106

117
final class RemWithMapping extends AtomicPattern {
@@ -17,22 +13,4 @@ final class RemWithMapping extends AtomicPattern {
1713
protected boolean matchesCodeNode(DiffNode codeNode) {
1814
return codeNode.getBeforeParent().isRem();
1915
}
20-
21-
@Override
22-
public PatternMatch<DiffNode> createMatchOnCodeNode(DiffNode codeNode) {
23-
final Node fm = codeNode.getBeforeParent().getBeforeFeatureMapping();
24-
final Lines diffLines = codeNode.getLinesInDiff();
25-
26-
return new PatternMatch<>(this,
27-
diffLines.getFromInclusive(), diffLines.getToExclusive(), fm
28-
);
29-
}
30-
31-
@Override
32-
public FeatureContext[] getFeatureContexts(PatternMatch<DiffNode> patternMatch) {
33-
return new FeatureContext[]{
34-
new FeatureContext(null),
35-
new FeatureContext(patternMatch.getFeatureMappings()[0], true)
36-
};
37-
}
3816
}

0 commit comments

Comments
 (0)