We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Taking the following code and input with javaparser 3.24.7, I get the output f().g(), but I would expect the output:
3.24.7
f().g()
f().g() f()
Code:
package parser; import java.lang.System; import com.github.javaparser.JavaParser; import com.github.javaparser.Providers; import com.github.javaparser.Provider; import com.github.javaparser.ParseStart; import com.github.javaparser.ast.body.MethodDeclaration; import com.github.javaparser.ast.expr.MethodCallExpr; import com.github.javaparser.ast.visitor.VoidVisitorAdapter; public class Parser { public static void main(String[] args) { JavaParser parser = new JavaParser(); Provider provider = Providers.provider(System.in, parser.getParserConfiguration().getCharacterEncoding()); ParseStart<MethodDeclaration> start = ParseStart.METHOD_DECLARATION; MethodDeclaration root = parser.parse(start, provider).getResult().get(); ExpressionExtractor expressionExtractor = new ExpressionExtractor(); root.accept(expressionExtractor, null); } static class ExpressionExtractor extends VoidVisitorAdapter<Void> { public void visit(MethodCallExpr node, Void none) { System.out.println(node.toString()); } } }
Input:
void function () { f().g(); }
It seems like the parser just doesn't visit the "inner" call to f(), only its ancestor in the AST.
f()
The text was updated successfully, but these errors were encountered:
Your visitor stops visiting the AST after calling the first MethodCallExpr. You need to modify it like this.
static class ExpressionExtractor extends VoidVisitorAdapter<Void> { public void visit(MethodCallExpr node, Void none) { System.out.println(node.toString()); **super.visit(node, node);** } }
Sorry, something went wrong.
I'm closing this issue because I think I answered the question. If not, you can reopen it.
No branches or pull requests
Taking the following code and input with javaparser
3.24.7
, I get the outputf().g()
, but I would expect the output:Code:
Input:
It seems like the parser just doesn't visit the "inner" call to
f()
, only its ancestor in the AST.The text was updated successfully, but these errors were encountered: