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 07:16 Go to next message
Eclipse User
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 16:47 Go to previous message
Brian Payton is currently offline Brian Payton
Messages: 152
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: Tue Jul 29 06:42:32 EDT 2014

Powered by FUDForum. Page generated in 0.01821 seconds