Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » In an AST Visitor, how can I know which node's property I am visiting?(Is it possible to differentiate?)
In an AST Visitor, how can I know which node's property I am visiting? [message #644465] Sat, 11 December 2010 13:01 Go to next message
Eclipse UserFriend
Hi, I'm programming an AST Visitor.

An EnumDeclaration node contains the following structural properties:

JAVADOC, MODIFIERS, NAME, SUPER_INTERFACE_TYPES, ENUM_CONSTANTS and BODY_DECLARATIONS.

When I visit a child node of EnumDeclaration (a SimpleName node, for instance), is it possible to know which of the lists of nodes I'm visiting? Is it possible to differentiate?

I'd like to process a node differently, depending on whether I found it in ENUM_CONSTANTS or BODY_DECLARATIONS.

Thanks for the help.

[Updated on: Sun, 12 December 2010 05:36] by Moderator

Re: In an AST Visitor, how can I know which node's property I am visiting? [message #644498 is a reply to message #644465] Sun, 12 December 2010 05:35 Go to previous messageGo to next message
Eclipse UserFriend
Using the accept method it is possible to do this.

List<Node> as = node.<getPropertyX>();
for( Node a: as)
    a.accept( this);
Re: In an AST Visitor, how can I know which node's property I am visiting? [message #644568 is a reply to message #644465] Mon, 13 December 2010 05:10 Go to previous messageGo to next message
Eclipse UserFriend
On 2010-12-11 19:01, Joan Robert wrote:
> When I visit a child node of EnumDeclaration (a SimpleName node, for
> instance), is it possible to know which of the lists of nodes I'm
> visiting? Is it possible to differenciate?

Use "node.getLocationInParent() == EnumDeclaration.NAME_PROPERTY" or
other *_PROPERTY constants.

Markus
Re: In an AST Visitor, how can I know which node's property I am visiting? [message #644571 is a reply to message #644568] Mon, 13 December 2010 05:25 Go to previous message
Eclipse UserFriend
That's a good alternative way, Markus.

[Updated on: Wed, 15 December 2010 10:56] by Moderator

Previous Topic:Java extension and java.g file grammar
Next Topic:My "Import existing project" disappeared
Goto Forum:
  


Current Time: Wed Jul 02 03:06:18 EDT 2025

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

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

Back to the top