Skip to content

Instantly share code, notes, and snippets.

@mauricioaniche
Created March 3, 2020 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauricioaniche/b289cd6e3f523d0512251bb2d88c0844 to your computer and use it in GitHub Desktop.
Save mauricioaniche/b289cd6e3f523d0512251bb2d88c0844 to your computer and use it in GitHub Desktop.
public static void main(String[] args) throws FileNotFoundException {
CompilationUnit cu = StaticJavaParser.parse(new FileInputStream("/Users/mauricioaniche/workspace/logremoval/fixture/A.java"));
cu.accept(new ModifierVisitor<Void>() {
@Override
public Visitable visit(final MethodCallExpr n, Void arg) {
boolean isALogClass = n.getScope().isPresent() && (logClasses.stream().anyMatch(x -> n.getScope().get().toString().startsWith(x)));
boolean isALogMethod = logMethods.contains(n.getName().asString());
if(isALogClass && isALogMethod) {
System.out.println("log call!");
n.getScope().get().remove();
}
return super.visit(n, arg);
}
}, null);
System.out.println(cu.toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment