Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » DTP » How to visit QueryStatement
How to visit QueryStatement [message #769619] Thu, 22 December 2011 12:16 Go to next message
Eclipse UserFriend
hi, DTP professionals:

I use SQLDomainModel to parse a valid SQL statement and it returns a
QueryStatement object. I want to iterate the whole parse tree to look up
constants like 'a string' or 123 or 123.456. But unfortunately I can't
find an universal Visitor Interface to visit QueryStatement.

for example, JDT supplied an AST Visitor (call ASTVisitor) that can
visit AST nodes.

Thanks for your help!

David
Re: How to visit QueryStatement [message #801064 is a reply to message #769619] Fri, 17 February 2012 21:47 Go to previous message
Brian Payton is currently offline Brian PaytonFriend
Messages: 154
Registered: July 2009
Senior Member
Unfortunately there isn't a generic visitor for traversing the Query
model. Query model visitors are typically purpose-written to navigate
the part of the tree they are interested in. There are lots of examples
of that in the "helper" classes, such as the StatementHelper class in
the helper package of the org.eclipse.datatools.modelbase.sql.query plugin.

However you can probably get what you want using a "Post-parse
processor" that you add to the Query parser. The parser can gather
model elements that you are interested in into a list which you can then
iterate. See the PostParseProcessor class in the
org.eclipse.datatools.sqltools.parsers.sql plugin for more information,
and the TableReferenceResolver class in the
org.eclipse.datatools.sqltools.parsers.sql.query plugin for an example.

On 12/22/2011 4:16 AM, David Chan wrote:
> hi, DTP professionals:
>
> I use SQLDomainModel to parse a valid SQL statement and it returns a
> QueryStatement object. I want to iterate the whole parse tree to look up
> constants like 'a string' or 123 or 123.456. But unfortunately I can't
> find an universal Visitor Interface to visit QueryStatement.
>
> for example, JDT supplied an AST Visitor (call ASTVisitor) that can
> visit AST nodes.
>
> Thanks for your help!
>
> David
Previous Topic:Having Problem with creating database
Next Topic:Extending DTP SQL Query builder / statement area
Goto Forum:
  


Current Time: Fri Apr 26 15:42:35 GMT 2024

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

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

Back to the top