Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 351271 - Unused header will be removed from index when saved
Summary: Unused header will be removed from index when saved
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-parser (show other bugs)
Version: 8.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 8.0.1   Edit
Assignee: Sergey Prigogin CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-06 03:28 EDT by Jens Elmenthaler CLA
Modified: 2011-07-21 22:19 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Elmenthaler CLA 2011-07-06 03:28:32 EDT
Build Identifier: 8.0

Since 8.0 there is a new option to automatically index an unused header file when it is opened in an editor. This enables content assist to advertise members that are declared behind the current cursor positions also in header files that are reachable via a source file (see bug 103857).

However, after editing and saving again, the header file is removed from the index, and the feature stops working.

Reproducible: Always

Steps to Reproduce:
1. Create a new header file
2. Define a class with some members
3. Save the file
4. At the top of the class body, define a function and try to access the members via content assist. Nothing is proposed.
Comment 1 Sergey Prigogin CLA 2011-07-06 12:53:17 EDT
(In reply to http://bugs.eclipse.org/bugs/show_bug.cgi?id=103857#c34)
> I can reproduce the behavior. The feature of adding files opened in the editor
> to the index is buggy, when the file is saved it is removed from the index
> again. --> Please create a separate bug for that.

Markus, do you know the mechanism of the removal?
Comment 2 Markus Schorn CLA 2011-07-07 02:23:51 EDT
(In reply to comment #1)
> (In reply to http://bugs.eclipse.org/bugs/show_bug.cgi?id=103857#c34)
> > I can reproduce the behavior. The feature of adding files opened in the editor
> > to the index is buggy, when the file is saved it is removed from the index
> > again. --> Please create a separate bug for that.
> Markus, do you know the mechanism of the removal?

AbstractIndexerTask.extractFiles(...) detects header files that are no longer included by a source file and stores them in a list for later removal.
Comment 3 Sergey Prigogin CLA 2011-07-14 19:06:37 EDT
I've committed a fix to the master branch. Will port it to cdt_8_0 after people have had an opportunity to test the fix.

Jens, could you please try the fix.
Markus, could you please review it at http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=c14dcb907d2fe629b66f069183b141b97a409464.

Thanks.
Comment 4 Jens Elmenthaler CLA 2011-07-15 08:49:46 EDT
(In reply to comment #3)
> I've committed a fix to the master branch. Will port it to cdt_8_0 after people
> have had an opportunity to test the fix.
> Jens, could you please try the fix.
Works now. Thanks.
Comment 5 Sergey Prigogin CLA 2011-07-18 13:01:02 EDT
Fixed in cdt_8_0 > 20110717 and master > 20110714.
Comment 6 Markus Schorn CLA 2011-07-20 07:17:09 EDT
(In reply to comment #3)
The fix looks good to me. 

However, it was not neccessary to add 
   IndexerInputAdapter.isIndexedUnconditionally(Object tu), 
the other method
   IndexerInputAdapter.isIndexedUnconditionally(IIndexFileLocation ifl) 
should do it.
Comment 7 Sergey Prigogin CLA 2011-07-21 21:39:07 EDT
(In reply to comment #6)
> However, it was not neccessary to add 
>    IndexerInputAdapter.isIndexedUnconditionally(Object tu), 
> the other method
>    IndexerInputAdapter.isIndexedUnconditionally(IIndexFileLocation ifl) 
> should do it.

Good point. Simplified the code.
Comment 8 CDT Genie CLA 2011-07-21 22:19:19 EDT
*** cdt git genie on behalf of 351271 ***

    Bug 351271. Code simplification suggested by Markus Schorn.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=b5c36e47a5e4754a5073996f03be31e3bb9e6058
Comment 9 CDT Genie CLA 2011-07-21 22:19:22 EDT
*** cdt git genie on behalf of 351271 ***

    Bug 351271. Code simplification suggested by Markus Schorn.

[*] http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/commit/?id=6d8a98e790f43626bab61125f3228dc96248baa9