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
Tag: javaparser
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
Find if the current statement in an If/Else block is the last statement of the THEN branch
I am using JavaParser to parse through the contents of the following code and identify the sequence of statements: The code I am using to parse the above example: What I would also like to do is to identify if the current statement is an expression statement (i.e., assignment), and if yes, find if it is the last statement contained