Skip to content
Advertisement

Tag: javaparser

ClassOrInterfaceDeclaration.getTokenRange() gets all the tokens for a file even after removing nodes from the class

When I remove “ClassOrInterfaceDeclaration” nodes from a class in CompilationUnit (JavaParser) from a parsed file that contains more than one class, ClassOrInterfaceDeclaration.getTokenRange() gets all the tokens even the removed nodes tokens. For example, the code snippet at positions 1 and 2 will give the same result, although I already removed nodes from ClassOrInterfaceDeclaration n. Does anyone know how to get

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: … the code finds the method calls to “MYMETHOD” correctly, but when I try to replace it with a BlockComment, an exception is thrown: It seems I can only replace an Expression by another Expression (because

Advertisement