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

Bug 284669

Summary: "Add Include" adds includes after the last include but not before first usage of the element
Product: [Tools] CDT Reporter: Mathieu Roger <rogma.boami>
Component: cdt-coreAssignee: Sergey Prigogin <eclipse.sprigogin>
Status: RESOLVED FIXED QA Contact: Doug Schaefer <cdtdoug>
Severity: normal    
Priority: P3 CC: eclipse.sprigogin
Version: 6.0Keywords: helpwanted
Target Milestone: 6.0.2   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
Test case to reproduce eclipse.sprigogin: iplog-

Description Mathieu Roger CLA 2009-07-26 05:20:30 EDT
Build ID: 20090619-0625

Steps To Reproduce:
1. use the attached project : the including.h contains a #include placed after the usage of A
2. in including.h, places the caret on inherited class A
3. "Add Include"

Observed result :

the added include is placed after the last include, after the usage of A so it still does not compile.

More information:
The rule should be to place include after the last include preceding the first usage of the element. I we have similar results with several usage of the same "Add Include" target with interlacing #include.

The provided test case is quite stupid but the real life scenario is when the file is a template declaration ending with an include to the template code.
Comment 1 Mathieu Roger CLA 2009-07-26 05:21:13 EDT
Created attachment 142592 [details]
Test case to reproduce
Comment 2 Sergey Prigogin CLA 2009-11-16 01:30:44 EST
The bug is mostly fixed. The include is always inserted before the name on which Add Include was invoked. No checking is done with respect to other instances of the same name.

Fixed in cdt_6_0 and HEAD > 20091115.