Skip to content

Commit da62fa0

Browse files
authored
Merge pull request #213 from barbosamaatheus/master
Update regex patterns for code and method change detection
2 parents 004b70d + 57df97b commit da62fa0

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

src/main/services/dataCollectors/modifiedLinesCollector/DiffJParser.groovy

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ class DiffJParser {
1515
private final String REMOVED_FLAG = "d";
1616

1717
private final String FLAGS_REGEX = "(${ADDED_FLAG}|${CHANGED_FLAG}|${REMOVED_FLAG})"
18-
private final Pattern METHOD_CHANGE_HEADER_REGEX = Pattern.compile("^.* code (added|changed|removed) in .*")
18+
private final Pattern STATEMENT_CHANGE_HEADER_REGEX = Pattern.compile("^.* code (added|changed|removed) in .*")
19+
private final Pattern METHOD_DECLARATION_CHANGE_HEADER_REGEX = Pattern.compile("^.* method (added|changed|removed): .*")
1920

2021
public Map<String, int[]> parse (List<String> lines) {
2122
def result = new HashMap<String, int[]>();
@@ -75,16 +76,18 @@ class DiffJParser {
7576
if (iterator.hasNext()) {
7677
iterator.next();
7778
}
78-
}
79+
}
7980

8081
private boolean isMethodChangeLine(String line) {
81-
Matcher matcher = METHOD_CHANGE_HEADER_REGEX.matcher(line);
82+
Matcher codeMatcher = STATEMENT_CHANGE_HEADER_REGEX.matcher(line);
83+
84+
Matcher methodMatcher = METHOD_DECLARATION_CHANGE_HEADER_REGEX.matcher(line);
8285

83-
return matcher.find();
86+
return codeMatcher.find() || methodMatcher.find();
8487
}
8588

8689
private String getMethodName(String headerLine) {
87-
return headerLine.replaceFirst(/^.* code (added|changed|removed) in /, "");
90+
return headerLine.replaceFirst(/^.* code (added|changed|removed) in /, "").replaceFirst(/^.* method (added|changed|removed): /, "");
8891
}
8992

9093
private int[] getModifiedLinesRange(String headerLine) {
@@ -118,4 +121,4 @@ class DiffJParser {
118121
}
119122
}
120123

121-
}
124+
}

src/main/services/outputProcessors/soot/ConflictDetectionAlgorithm.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class ConflictDetectionAlgorithm {
3838
this.depthLimit = depthLimit;
3939
}
4040

41+
String getMode() {
42+
return mode
43+
}
44+
4145
String getName() {
4246
return name
4347
}
@@ -147,4 +151,5 @@ class ConflictDetectionAlgorithm {
147151
}
148152
return result
149153
}
154+
150155
}

src/main/services/outputProcessors/soot/NonCommutativeConflictDetectionAlgorithm.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ class NonCommutativeConflictDetectionAlgorithm extends ConflictDetectionAlgorith
4949
}
5050

5151
private SootConfig buildSootConfig(String filePath, Scenario scenario) {
52-
SootConfig config = new SootConfig(filePath, scenario.getClassPath(), this.mode);
52+
SootConfig config = new SootConfig(filePath, scenario.getClassPath(), super.getMode());
5353
config.addOption("-entrypoints", scenario.getEntrypoints());
5454
config.addOption("-depthLimit", this.getDepthLimit());
5555
return config;
5656
}
5757

5858
@Override
5959
public String toString() {
60-
return "NonCommutativeConflictDetectionAlgorithm{name = ${this.name}}";
60+
return "NonCommutativeConflictDetectionAlgorithm{name = ${super.getName()}}";
6161
}
6262
}

0 commit comments

Comments
 (0)