@@ -22,74 +22,29 @@ public boolean performMutation(MutationLocation location, BufferedWriter writer,
2222 ASTMutationLocation mLocation = (ASTMutationLocation ) location ;
2323 CommonTree parent = (CommonTree ) mLocation .getTree ().getParent ();
2424 List <CommonTree > hijos = (List <CommonTree >)parent .getChildren ();
25- int intentInstanceLine = -1 ;
2625 String intentInstanceLineVar = mLocation .getTree ().getChild (1 ).getChild (0 ).toString ();
27- int contextInstanceLine = -1 ;
28- String contextInstanceLineVar = mLocation .getTree ().getChild (1 ).getChild (1 ).toString ();
29- int classComponentLine = -1 ;
30- String classComponentLineVar = mLocation .getTree ().getChild (1 ).getChild (2 ).toString ();
31- int actualChild = mLocation .getTree ().getChildIndex ();
32- while (actualChild >0 && (intentInstanceLine == -1 || contextInstanceLine == -1 || classComponentLine == -1 )) {
33- CommonTree temp = (CommonTree ) hijos .get (actualChild );
34- List <CommonTree > hijoss = (List <CommonTree >) temp .getChildren ();
35- if (temp .getType ()==142
36- && hijoss .get (0 ).getText ().equals ("const-class" )
37- && hijoss .get (1 ).getText ().equals (classComponentLineVar )){
38- classComponentLine = temp .getLine ();
39- } else if (temp .getType ()==142
40- && hijoss .get (0 ).getText ().equals ("new-instance" )
41- && hijoss .get (1 ).getText ().equals (intentInstanceLineVar )){
42- intentInstanceLine = temp .getLine ();
43- } else if (temp .getType ()==148
44- && hijoss .get (0 ).getText ().equals ("iget-object" )
45- && hijoss .get (1 ).getText ().equals (contextInstanceLineVar )) {
46- contextInstanceLine = temp .getLine ();
47- }
48-
49- actualChild --;
50- }
5126
5227 List <String > newLines = new ArrayList <String >();
5328 List <String > lines = FileHelper .readLines (location .getFilePath ());
5429
5530
5631 //Add lines before the MutationLocation
57- for (int i =0 ; i < intentInstanceLine -1 ; i ++){
32+ for (int i =0 ; i < mLocation . getLine () -1 ; i ++){
5833 newLines .add (lines .get (i ));
5934 }
6035
6136
6237 //Apply mutation
6338 newLines .add (" const/4 " +intentInstanceLineVar +", 0x0" );
64- // String linesToConsider = "";
65- // boolean newLineFlag = false;
66- // for(int i = location.getStartLine(); i <= location.getEndLine(); i++){
67- // if(newLineFlag){
68- // linesToConsider += " "+lines.get(i);
69- // } else {
70- // linesToConsider += lines.get(i);
71- // newLineFlag = true;
72- // }
73- // }
74- //
75- // String sub1 = linesToConsider.substring(0, location.getStartColumn());
76- // String sub2 = linesToConsider.substring(location.getEndColumn());
77- //
78- // String mutatedLine = sub1 + "null" + sub2;
79- // newLines.add(mutatedLine);
8039
8140
8241 //Add lines after the MutationLocation
83- for (int i =location .getLine (); i < lines .size () ; i ++){
42+ for (int i =mLocation .getLine (); i < lines .size () ; i ++){
8443 newLines .add (lines .get (i ));
8544 }
8645
87- int [] mutatedlines = new int []{intentInstanceLine , contextInstanceLine , classComponentLine , mLocation .getLine ()};
88- String mutatedLines = "{ " ;
89- for (int i = 0 ; i < mutatedlines .length ; i ++) {
90- mutatedLines += mutatedlines [i ]+", " ;
91- }
92- mutatedLines = mutatedLines .substring (0 ,mutatedLines .length ()-2 )+" }" ;
46+ int [] mutatedlines = new int []{mLocation .getLine ()};
47+ String mutatedLines = "" +mLocation .getLine ();
9348 FileHelper .writeLines (location .getFilePath (), newLines );
9449 Helper .mutationSuccess (mutantIndex );
9550 Helper .writeBasicLogInfo (mutantIndex , location .getFilePath (), location .getType ().getName (), mutatedlines , writer );
0 commit comments