{"action":"created","issue":{"url":"https://api.github.com/repos/javaparser/javaparser/issues/1891","repository_url":"https://api.github.com/repos/javaparser/javaparser","labels_url":"https://api.github.com/repos/javaparser/javaparser/issues/1891/labels{/name}","comments_url":"https://api.github.com/repos/javaparser/javaparser/issues/1891/comments","events_url":"https://api.github.com/repos/javaparser/javaparser/issues/1891/events","html_url":"https://github.com/javaparser/javaparser/issues/1891","id":371473649,"node_id":"MDU6SXNzdWUzNzE0NzM2NDk=","number":1891,"title":"VoidVisitorWithDefaults does not visit nodes","user":{"login":"mlg255","id":770553,"node_id":"MDQ6VXNlcjc3MDU1Mw==","avatar_url":"https://avatars3.githubusercontent.com/u/770553?v=4","gravatar_id":"","url":"https://api.github.com/users/mlg255","html_url":"https://github.com/mlg255","followers_url":"https://api.github.com/users/mlg255/followers","following_url":"https://api.github.com/users/mlg255/following{/other_user}","gists_url":"https://api.github.com/users/mlg255/gists{/gist_id}","starred_url":"https://api.github.com/users/mlg255/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mlg255/subscriptions","organizations_url":"https://api.github.com/users/mlg255/orgs","repos_url":"https://api.github.com/users/mlg255/repos","events_url":"https://api.github.com/users/mlg255/events{/privacy}","received_events_url":"https://api.github.com/users/mlg255/received_events","type":"User","site_admin":false},"labels":[{"id":359959666,"node_id":"MDU6TGFiZWwzNTk5NTk2NjY=","url":"https://api.github.com/repos/javaparser/javaparser/labels/Question","name":"Question","color":"006b75","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-18T10:56:04Z","updated_at":"2018-11-09T18:03:10Z","closed_at":"2018-11-09T18:03:10Z","author_association":"NONE","body":"As I understand, only the very root node is visited with a `VoidVisitorWithDefaults`.\r\n\r\nACTUAL The below program outputs:\r\n```\r\nvisited: 3 nodes\r\nvisited: 0 nodes\r\nvisited: 3 nodes\r\n```\r\nEXPECTED: 3 nodes in all cases\r\n\r\nThe below code that demonstrates the problem shows that the `ModifierVisitor` works as expected both before and after using the `VoidVisitorWithDefaults` that does not work:\r\n\r\n```\r\npackage com.yourorganization.maven_sample;\r\n\r\nimport com.github.javaparser.JavaParser;\r\nimport com.github.javaparser.ast.CompilationUnit;\r\nimport com.github.javaparser.ast.expr.BinaryExpr;\r\nimport com.github.javaparser.ast.visitor.ModifierVisitor;\r\nimport com.github.javaparser.ast.visitor.Visitable;\r\nimport com.github.javaparser.ast.visitor.VoidVisitorWithDefaults;\r\n\r\nimport java.io.IOException;\r\n\r\n/**\r\n * Some code that uses JavaParser.\r\n */\r\npublic class StrangeExample {\r\n    public static void main(String[] args) throws IOException {\r\n\r\n        CompilationUnit cu = JavaParser.parse(\"class X { int x() { return 1 + 1.0 - 5; }  static String HW = \\\"hello\\\"+\\\"world\\\"; }\");\r\n\r\n        {\r\n            IntHolder ih1 = new IntHolder();\r\n            cu.accept(new ModifierVisitor<IntHolder>() {\r\n                @Override\r\n                public Visitable visit(BinaryExpr n, IntHolder arg) {\r\n                    arg.x++;\r\n                    return super.visit(n, arg);\r\n                }\r\n            }, ih1);\r\n\r\n            System.out.println(\"visited: \"+ih1.x+\" nodes\");\r\n        }\r\n\r\n\r\n        {\r\n            IntHolder ih2 = new IntHolder();\r\n            cu.accept(new VoidVisitorWithDefaults<IntHolder>() {\r\n                @Override\r\n                public void visit(BinaryExpr n, IntHolder arg) {\r\n                    arg.x++;\r\n                    super.visit(n, arg);\r\n                }\r\n            }, ih2);\r\n\r\n            System.out.println(\"visited: \"+ih2.x+\" nodes\");\r\n        }\r\n\r\n        {\r\n            IntHolder ih3 = new IntHolder();\r\n            cu.accept(new ModifierVisitor<IntHolder>() {\r\n                @Override\r\n                public Visitable visit(BinaryExpr n, IntHolder arg) {\r\n                    arg.x++;\r\n                    return super.visit(n, arg);\r\n                }\r\n            }, ih3);\r\n\r\n            System.out.println(\"visited: \"+ih3.x+\" nodes\");\r\n        }\r\n    }\r\n}\r\n/*\r\nRESULT:\r\n\r\nvisited: 3 nodes\r\nvisited: 0 nodes\r\nvisited: 3 nodes\r\n */\r\n\r\nclass IntHolder {\r\n    public int x;\r\n}\r\n\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/javaparser/javaparser/issues/comments/437443763","html_url":"https://github.com/javaparser/javaparser/issues/1891#issuecomment-437443763","issue_url":"https://api.github.com/repos/javaparser/javaparser/issues/1891","id":437443763,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNzQ0Mzc2Mw==","user":{"login":"matozoid","id":55701,"node_id":"MDQ6VXNlcjU1NzAx","avatar_url":"https://avatars3.githubusercontent.com/u/55701?v=4","gravatar_id":"","url":"https://api.github.com/users/matozoid","html_url":"https://github.com/matozoid","followers_url":"https://api.github.com/users/matozoid/followers","following_url":"https://api.github.com/users/matozoid/following{/other_user}","gists_url":"https://api.github.com/users/matozoid/gists{/gist_id}","starred_url":"https://api.github.com/users/matozoid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matozoid/subscriptions","organizations_url":"https://api.github.com/users/matozoid/orgs","repos_url":"https://api.github.com/users/matozoid/repos","events_url":"https://api.github.com/users/matozoid/events{/privacy}","received_events_url":"https://api.github.com/users/matozoid/received_events","type":"User","site_admin":false},"created_at":"2018-11-09T18:03:10Z","updated_at":"2018-11-09T18:03:10Z","author_association":"MEMBER","body":"No response, I guess this has been answered."}}
{"actor":{"display_login":"matozoid"}}