java - JavaParser visit method arg parameter clarification -
Can someone give clarification on the use of the second logic of It is very simple. When you call the By the way, you should generally call Not in the other way. visit
arg / Code> As shown in the following code?
I can not find any information on the internet. Public class vacuum throws public key (string [] args) Exception {// file to InputStream = new file inputstream ("test")
.java ") creates an input stream for parsing; CollectionUnit CU; Try {// parse the file cu = JavaParser.parse (in); } Finally {in.close (); } // Enter the new MethodWit () name to travel and print methods. (Travel, walking); } / ** * Implementation of Simple Visitors for Visiting Disclosure Nodes * / Private Static Class Methods Vector VoidVisitorAdapter {@Override Public Zero Travel (MethodDeclaration n, Object arg) {// Here you can use the properties of the method. // This method will be called for all the methods in this method // CompilationUnit, which contains the internal class methods System.out.println (n.getName ()); }}}}
accept method with your visitor, you can provide this additional argument, which will then return to your visitor's
visit methods Will be back on. This is basically a way for visitors to pass certain reference objects that allow visitors to stay themselves stateless. For example, consider a case where you want to collect all the method names viewed while visiting. . You set a
set & lt; String & gt; as an argument and can add method names to that set, I think it is the logic behind this (I personally like the ugly visitors).
cu.accept (new method designer), blank);
Comments
Post a Comment