|How to visit QueryStatement [message #769619]
||Thu, 22 December 2011 07:16
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!
|Re: How to visit QueryStatement [message #801064 is a reply to message #769619]
||Fri, 17 February 2012 16:47
| Brian Payton
Registered: July 2009
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!
Powered by FUDForum
. Page generated in 0.04319 seconds