Skip to content

Commit 1d0bc65

Browse files
authored
Merge pull request #52 from TheSoftwareDesignLab/develop
Partial Solution for MO27 compilation errors
2 parents f976ed1 + 7d9c3be commit 1d0bc65

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/uniandes/tsdl/mutapk/operators/gui/android/FindViewByIdReturnsNull.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,16 @@ public boolean performMutation(MutationLocation location, BufferedWriter writer,
2222
ASTMutationLocation mLocation = (ASTMutationLocation) location;
2323
CommonTree parent = (CommonTree) mLocation.getTree().getParent();
2424
CommonTree cast = ASTHelper.getFirstBrotherNamedOfType(smaliParser.I_STATEMENT_FORMAT21c_TYPE, "check-cast", parent);
25-
String varName = cast.getChild(1).toString();
25+
String varName = "";
26+
int position = -1;
27+
if(cast!=null && (cast.getLine()-parent.getLine()<5)) {
28+
varName = cast.getChild(1).toString();
29+
position = cast.getLine();
30+
} else {
31+
CommonTree moveResultObject = ASTHelper.getFirstBrotherNamedOfType(smaliParser.I_STATEMENT_FORMAT11x, "move-result-object", parent);
32+
varName = moveResultObject.getChild(1).toString();
33+
position = moveResultObject.getLine();
34+
}
2635

2736

2837
List<String> newLines = new ArrayList<String>();
@@ -38,13 +47,13 @@ public boolean performMutation(MutationLocation location, BufferedWriter writer,
3847
newLines.add(" const/4 "+varName+", 0x0");
3948
newLines.add("");
4049

41-
for(int i=cast.getLine(); i < lines.size() ; i++){
50+
for(int i=position; i < lines.size() ; i++){
4251
newLines.add(lines.get(i));
4352
}
4453

4554
FileHelper.writeLines(location.getFilePath(), newLines);
4655
Helper.mutationSuccess(mutantIndex);
47-
Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine(), cast.getLine()}, writer);
56+
Helper.writeBasicLogInfo(mutantIndex, location.getFilePath(), location.getType().getName(), new int[] {mLocation.getLine(), position}, writer);
4857
writer.write(" For mutant "+mutantIndex+" the element retrieved at line "+location.getStartLine()+" has been set to null");
4958
writer.newLine();
5059
writer.flush();

test/operators.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
#4 = InvalidKeyIntentPutExtra
66
#17 = InvalidURI
77
#28 = InvalidColor
8-
20 = NullBackEndServiceReturn
8+
#20 = NullBackEndServiceReturn
9+
27 = FindViewByIdReturnsNull

0 commit comments

Comments
 (0)