blob: 3e052ded73413094292a26c9fbf2349e46b257ad (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package oml.ast.transformers;
import com.strobel.decompiler.languages.java.ast.AstNode;
import com.strobel.decompiler.languages.java.ast.DepthFirstAstVisitor;
import com.strobel.decompiler.languages.java.ast.Identifier;
import com.strobel.decompiler.languages.java.ast.transforms.IAstTransform;
/**
* Created by Thiakil on 13/07/2018.
*/
public class InvalidIdentifierFix implements IAstTransform {
@Override
public void run(AstNode compilationUnit) {
compilationUnit.acceptVisitor(new Visitor(), null);
}
class Visitor extends DepthFirstAstVisitor<Void,Void>{
@Override
public Void visitIdentifier(Identifier node, Void data) {
super.visitIdentifier(node, data);
if (node.getName().equals("do") || node.getName().equals("if")){
Identifier newIdentifier = Identifier.create(node.getName() + "_", node.getStartLocation());
newIdentifier.copyUserDataFrom(node);
node.replaceWith(newIdentifier);
}
return null;
}
}
}
|