Skip to content
Advertisement

Javaparser comment expression

I’m trying to comment all calls to a custom method inside a java file using Javaparser. My first approach is to use a ModifierVisitor:

JavaScript

… the code finds the method calls to “MYMETHOD” correctly, but when I try to replace it with a BlockComment, an exception is thrown:

JavaScript

It seems I can only replace an Expression by another Expression (because the change is inside an ExpressionStmt).

How could I about it and convert the method call to a comment?

Thank you all

Updated: Finally, I’ve made a hack: changing the name of the method to “//” + method name, so it ends up commented.

Advertisement

Answer

Finally, I’ve made a hack: changing the name of the method to “//” + method name, so it ends up commented.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement