Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How to use a ASTVisitor in a correct way?
How to use a ASTVisitor in a correct way? [message #194241] Tue, 25 January 2005 13:54 Go to next message
Eclipse UserFriend
Originally posted by: pimenta.inatel.br

Hi.

I have just created a new class that extends from ASTVisitor. It is
MyASTVisitor.

I have implemented just 2 methods in MyASTVisitor:

public boolean visit(MethodDeclaration node) and
public boolean visit(MethodInvocation node)

The first one just prints "Hellow world" and return true.
And the second just prints"Beautful world" and return false.

--------------------------

The code of my plugin's final user is:


..
..
..
private void createForm(){

form = new Form("Title");
form.append(textItem);


}


Then, at run time, my plugin gets a MethodDeclaration (an AST node
representing such user's method) and run:

MyASTVisitor visitor = new MyASTVisitor()
visitor.visit(myMethodDeclaration); //I suppose the another visit method
will be called automatically.


However, my plugin prints just "Hello world". Why doesn't it print
"Beautiful world" too? If the second method can't run automatically, how
to use a ASTVisitor?

Any hint will be very helpful.

Thanks.

Rodrigo Pimenta Carvalho.
Re: How to use a ASTVisitor in a correct way? [message #194266 is a reply to message #194241] Tue, 25 January 2005 15:31 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: olivier_thomannNOSPAM.ca.ibm.com

Rodrigo Pimenta Carvalho a écrit :
> MyASTVisitor visitor = new MyASTVisitor()
> visitor.visit(myMethodDeclaration); //I suppose the another visit method
> will be called automatically.
I think you should rather write:
myMethodDeclaration.accept(visitor); This will do the traverse of the
tree according to your visitor implementation.
--
Olivier
Re: How to use a ASTVisitor in a correct way? [message #194295 is a reply to message #194266] Wed, 26 January 2005 06:26 Go to previous message
Eclipse UserFriend
Originally posted by: viraj.gs-lab.com

"Olivier Thomann" <olivier_thomannNOSPAM@ca.ibm.com> wrote in message
news:ct6abq$inp$1@www.eclipse.org...
> Rodrigo Pimenta Carvalho a
Previous Topic:ANT script using project and workspace settings
Next Topic:Using the JDT refactoring framework with XMI
Goto Forum:
  


Current Time: Wed May 07 16:20:09 EDT 2025

Powered by FUDForum. Page generated in 0.03227 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top