Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323561

Summary: No Doxygen template comments for extern "C" void myFunc(int param)
Product: [Tools] CDT Reporter: Axel Mueller <aegges>
Component: cdt-editorAssignee: Anton Leherbauer <aleherb+eclipse>
Status: RESOLVED FIXED QA Contact: Anton Leherbauer <aleherb+eclipse>
Severity: normal    
Priority: P3 CC: malaperle
Version: 7.0   
Target Milestone: 8.0   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Generate documentation for extern function declaration
none
Generate documentation for extern function declaration
none
Generate documentation for extern function declaration
none
Generate documentation for extern function declaration aleherb+eclipse: iplog+

Description Axel Mueller CLA 2010-08-25 02:29:42 EDT
Build Identifier: Helios Build id: 20100618-0524, CDT 7.0.0

No Doxygen template comments for extern "C" void myFunc(int param)

Reproducible: Always

Steps to Reproduce:
1. create a new header that contains:
extern "C" void myFunc(int param);
2. type in /** in the line above and press Enter
Expected output:
/**
 * 
 * @param para
 */

Actual output:
/**
 * 
 */

The doxygen parser does not like the "C" (extern void myFunc(int param) works).
Comment 1 Marc-André Laperle CLA 2010-08-26 01:43:30 EDT
Created attachment 177490 [details]
Generate documentation for extern function declaration

This patch will allow the documentation to be generated above the extern if only one declaration is present in the extern (ICPPASTLinkageSpecification). If more than one declarations are present in the extern, the documentation should be above each declarations anyway.
Comment 2 Anton Leherbauer CLA 2010-08-26 06:10:19 EDT
(In reply to comment #1)
> This patch will allow the documentation to be generated above the extern if
> only one declaration is present in the extern (ICPPASTLinkageSpecification). If
> more than one declarations are present in the extern, the documentation should
> be above each declarations anyway.

In case of 

extern "C" {
void myFunc(int param);
}

I get the doxygen comment also above the extern "C".  It's a minor issue, though, and fixing might not be trivial as the AST does not differentiate between these two variants, AFAIK.
Comment 3 Marc-André Laperle CLA 2010-08-30 13:50:35 EDT
Created attachment 177758 [details]
Generate documentation for extern function declaration

I made a new patch using the raw string and node offsets. I'm not too sure about this solution.
Comment 4 Marc-André Laperle CLA 2010-09-07 12:56:28 EDT
Hi Anton. What to you think of this new patch? Should I try something else?
Comment 5 Anton Leherbauer CLA 2010-09-08 03:10:36 EDT
(In reply to comment #4)
> Hi Anton. What to you think of this new patch? Should I try something else?

You could try using IASTNode.getTrailingSyntax / IASTNode.getLeadingSyntax.  This provides a way to look "between" nodes.
Comment 6 Marc-André Laperle CLA 2010-09-09 13:15:33 EDT
Created attachment 178535 [details]
Generate documentation for extern function declaration

Thanks for the suggestion. This new patch make use of getTrailingSyntax.
Comment 7 Anton Leherbauer CLA 2010-09-15 08:02:25 EDT
(In reply to comment #6)
> Thanks for the suggestion. This new patch make use of getTrailingSyntax.

Looks much better.  Two minor things:
- Don't log the exceptions from getTrailingsyntax()
  I think it would also be safer to just return without trying to change the 
  document in this case.
- Use token.getType() == IToken.tRBRACE
Comment 8 Marc-André Laperle CLA 2010-09-15 12:20:18 EDT
Created attachment 178961 [details]
Generate documentation for extern function declaration

(In reply to comment #7)
> Looks much better.  Two minor things:
> - Don't log the exceptions from getTrailingsyntax()
>   I think it would also be safer to just return without trying to change the 
>   document in this case.
> - Use token.getType() == IToken.tRBRACE

Thanks! Here's the new patch.
Comment 9 Anton Leherbauer CLA 2010-09-16 11:07:11 EDT
Thanks, I committed the patch to HEAD and also added a few JUnit tests.
Comment 10 CDT Genie CLA 2010-09-16 19:23:10 EDT
*** cdt cvs genie on behalf of aleherbau ***
Bug 323561 - No Doxygen template comments for extern &quot;C&quot; void myFunc(int param)
Patch from Marc-Andre Laperle

[*] DoxygenMultilineAutoEditStrategy.java 1.12 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenMultilineAutoEditStrategy.java?root=Tools_Project&r1=1.11&r2=1.12

[*] DoxygenCCommentAutoEditStrategyTest.java 1.7 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/doctools/doxygen/DoxygenCCommentAutoEditStrategyTest.java?root=Tools_Project&r1=1.6&r2=1.7