Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » AST - How to Parse Comments ?
AST - How to Parse Comments ? [message #171811] Wed, 28 June 2006 14:37 Go to next message
Eclipse UserFriend
Is there a method to access comments in the code?

The only thing I see in org.eclipse.cdt.core.dom.ast.IASTTranslationUnit
is getUnpreprocessedSignature() ..

in JDT there's a getCommentList() method, is there anything like that in
cdt?
Re: AST - How to Parse Comments ? [message #171868 is a reply to message #171811] Fri, 30 June 2006 10:29 Go to previous messageGo to next message
Eclipse UserFriend
Unfortunately the scanner currently ignores comments as whitespace and
does nothing with them. See BaseScanner.skipWhiteSpace().

-Andrew

Sebastian Jagodzinski wrote:
> Is there a method to access comments in the code?
>
> The only thing I see in org.eclipse.cdt.core.dom.ast.IASTTranslationUnit
> is getUnpreprocessedSignature() ..
>
> in JDT there's a getCommentList() method, is there anything like that in
> cdt?
>
>
>
>
>
Re: AST - How to Parse Comments ? [message #211139 is a reply to message #171868] Wed, 05 March 2008 08:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: anand.hatwalne.gmail.com

Is/Are there any crude way(s)/workarounds of achieving this? It appears
the comments are indeed skipped while building AST.. Appreciate any input.

Anand

Andrew Niefer wrote:
> Unfortunately the scanner currently ignores comments as whitespace and
> does nothing with them. See BaseScanner.skipWhiteSpace().
>
> -Andrew
>
> Sebastian Jagodzinski wrote:
>> Is there a method to access comments in the code?
>>
>> The only thing I see in org.eclipse.cdt.core.dom.ast.IASTTranslationUnit
>> is getUnpreprocessedSignature() ..
>>
>> in JDT there's a getCommentList() method, is there anything like that in
>> cdt?
>>
>>
>>
>>
>>
Re: AST - How to Parse Comments ? [message #211172 is a reply to message #171868] Wed, 05 March 2008 23:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dschaefer.rogers.com

Andrew Niefer wrote:
> Unfortunately the scanner currently ignores comments as whitespace and
> does nothing with them. See BaseScanner.skipWhiteSpace().
>
> -Andrew
>
> Sebastian Jagodzinski wrote:
>> Is there a method to access comments in the code?
>>
>> The only thing I see in org.eclipse.cdt.core.dom.ast.IASTTranslationUnit
>> is getUnpreprocessedSignature() ..
>>
>> in JDT there's a getCommentList() method, is there anything like that in
>> cdt?

That is changing with CDT 5.0's refactoring work. I'm not sure of the
details but Markus did some work on this recently.

Doug.
Re: AST - How to Parse Comments ? [message #211195 is a reply to message #211172] Thu, 06 March 2008 04:13 Go to previous messageGo to next message
Eclipse UserFriend
Doug Schaefer wrote:
>
> That is changing with CDT 5.0's refactoring work. I'm not sure of the
> details but Markus did some work on this recently.
>
> Doug.

Since CDT 4.0 the IASTTranslationUnit has a getComments() method. But you
need to configure the parser/scanner to provied comments otherwise the
scanner skips the comments.

Emanuel
Re: AST - How to Parse Comments ? [message #211398 is a reply to message #211195] Sun, 09 March 2008 09:07 Go to previous messageGo to next message
Eclipse UserFriend
Emanuel Graf wrote:
> Doug Schaefer wrote:
>> That is changing with CDT 5.0's refactoring work. I'm not sure of the
>> details but Markus did some work on this recently.
>>
>> Doug.
>
> Since CDT 4.0 the IASTTranslationUnit has a getComments() method. But you
> need to configure the parser/scanner to provied comments otherwise the
> scanner skips the comments.
>
> Emanuel
Yes, remind us how to turn that on, so we can get comments in the AST
Re: AST - How to Parse Comments ? [message #211508 is a reply to message #211398] Mon, 10 March 2008 05:29 Go to previous message
Eclipse UserFriend
Beth Tibbitts wrote:

> Emanuel Graf wrote:
>> Doug Schaefer wrote:
>>> That is changing with CDT 5.0's refactoring work. I'm not sure of the
>>> details but Markus did some work on this recently.
>>>
>>> Doug.
>>
>> Since CDT 4.0 the IASTTranslationUnit has a getComments() method. But you
>> need to configure the parser/scanner to provied comments otherwise the
>> scanner skips the comments.
>>
>> Emanuel
> Yes, remind us how to turn that on, so we can get comments in the AST

You can use the ITranslationUnit.AST_CREATE_COMMENT_NODES flag:

ITranslationUnit tu= ...
tu.getAST(index, ITranslationUnit.AST_CREATE_COMMENT_NODES);

or use one of the CDOM.getTranslationUnit() method with a boolean
parseComments parameter set to true.
Previous Topic:Winter Maintenance Packages broken on Mac OS?
Next Topic:Project isn’t built when makefile changes?
Goto Forum:
  


Current Time: Thu May 08 18:21:38 EDT 2025

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

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

Back to the top