Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » How to use CDT-Parser to write an extension?
How to use CDT-Parser to write an extension? [message #109893] Thu, 08 July 2004 17:27 Go to next message
Eclipse UserFriend
Originally posted by: schmidt.2002.gmx.de

I would like to implement a little extension to CDT that generates some
code from a class interface. So, my little plugin will ask the CDT
C++ parser for the code description of a given class declaration, and then
do sth with it, for example generate code, print some information etc.

So, how hard is it to get the class information from the parser? I need
sth like an iterator over all contained C++ member functions, and get the
return type and information on all parameters for each C++ member function.

How do I start? Which classes in the CDT API shall I look at? Or are there
even examples/tutorials on how to use the CDT C++ parser?

Thanks!
Andi
Re: How to use CDT-Parser to write an extension? [message #110020 is a reply to message #109893] Fri, 09 July 2004 10:48 Go to previous messageGo to next message
Eclipse UserFriend
The parser uses a callback mechanism to report its results, see
ISourceElementRequestor. Use the ParserFactory to create the scanner and
parser. You probably want STRUCTURAL_PARSE parse mode. The AST api is in
parser/org.eclipse.cdt.core.parser.ast.

Check out CModelBuilder.parse to see how the outline view uses the parser to
build the CModel (whose api starts with
model/org.eclipse.cdt.core.model.ICElement

-Andrew

"Andreas Schmidt" <schmidt.2002@gmx.de> wrote in message
news:opsat8kdg8hj6ai6@news.eclipse.org...
> I would like to implement a little extension to CDT that generates some
> code from a class interface. So, my little plugin will ask the CDT
> C++ parser for the code description of a given class declaration, and then
> do sth with it, for example generate code, print some information etc.
>
> So, how hard is it to get the class information from the parser? I need
> sth like an iterator over all contained C++ member functions, and get the
> return type and information on all parameters for each C++ member
function.
>
> How do I start? Which classes in the CDT API shall I look at? Or are there
> even examples/tutorials on how to use the CDT C++ parser?
>
> Thanks!
> Andi
Re: How to use CDT-Parser to write an extension? [message #110287 is a reply to message #109893] Sun, 11 July 2004 16:29 Go to previous message
Eclipse UserFriend
Do note that the Parser APIs are not documented, or considered frozen.

JC

"Andreas Schmidt" <schmidt.2002@gmx.de> wrote in message
news:opsat8kdg8hj6ai6@news.eclipse.org...
> I would like to implement a little extension to CDT that generates some
> code from a class interface. So, my little plugin will ask the CDT
> C++ parser for the code description of a given class declaration, and then
> do sth with it, for example generate code, print some information etc.
>
> So, how hard is it to get the class information from the parser? I need
> sth like an iterator over all contained C++ member functions, and get the
> return type and information on all parameters for each C++ member
function.
>
> How do I start? Which classes in the CDT API shall I look at? Or are there
> even examples/tutorials on how to use the CDT C++ parser?
>
> Thanks!
> Andi
Previous Topic:Following #includes and #ifdefs
Next Topic:Installation Problem CDT R2.0 and Eclipse 3.0 M9
Goto Forum:
  


Current Time: Tue Jul 22 02:36:01 EDT 2025

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

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

Back to the top