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

Bug 247021

Summary: Project Explorer view does not refresh when the user changes the active configuration or source settings
Product: [Tools] CDT Reporter: Alex Freidin <freidin.alex>
Component: cdt-coreAssignee: Andrew Gvozdev <angvoz.dev>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Irit.Belezko, torkildr
Version: 5.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 299857    
Attachments:
Description Flags
CVS patch that fixes the refreshing of the Project Explorer view
none
Updated patch based on CDT_6_0_0 tag
none
Alternative exemplary patch angvoz.dev: iplog+

Description Alex Freidin CLA 2008-09-11 10:35:00 EDT
Created attachment 112311 [details]
CVS patch that fixes the refreshing of the Project Explorer view

Build ID: I20080617-2000

Steps To Reproduce:
1.Create Hello World C project.
2.Select a source file and change its compiler setting.
3.The resource decorator doesn't appear in the Project Explorer until manually refreshing the project. In C/C++ Projects view, it appears immediately.
4.Change active configuration, again the decorator doesn't appear without manual refreshing the project in Project Explorer. In C/C++ Projects view it appears immediately.

Similar, none of the custom decorators is refreshed in Project Explorer view when changing the active configuration, unless it is manually refreshed by the user.

NOTE: When reproducing the problem, keep C/C++ Projects view closed, which is the CDT default anyway.

More information:
Looking at the code, the problem lies in the implementation of AbstractPage.updateViews(..). The Project Explorer view is not getting refreshed, while other views do, e.g. C/C++ Project view.
Attaching a patch that fixes this problem. Please review and apply.

Thanks,
Alex
Comment 1 Alex Freidin CLA 2008-09-11 10:42:11 EDT
I think this removes the need in applying https://bugs.eclipse.org/bugs/show_bug.cgi?id=230202. At least for our case, this is true.
Comment 2 Anton Leherbauer CLA 2008-10-06 03:14:23 EDT
*** Bug 246693 has been marked as a duplicate of this bug. ***
Comment 3 Anton Leherbauer CLA 2008-10-13 10:37:00 EDT
*** Bug 250645 has been marked as a duplicate of this bug. ***
Comment 4 Alex Freidin CLA 2009-08-10 11:32:43 EDT
Created attachment 143920 [details]
Updated patch based on CDT_6_0_0 tag
Comment 5 Andrew Gvozdev CLA 2009-08-11 17:30:47 EDT
When I change some tool settings (add -I directories for example) the decorators get updated. So is there another way which may be more appropriate to notify the other views in general?
Comment 6 Andrew Gvozdev CLA 2009-08-12 06:59:48 EDT
*** Bug 230202 has been marked as a duplicate of this bug. ***
Comment 7 Alex Freidin CLA 2009-08-16 12:06:33 EDT
Interesting that without switching a configuration, for some setting changes (e.g. -I<dir>) the decorators are updated, while for other (e.g. -O<level>) they don't.

The other way to update "C/C++ Projects"/"Project Explorer" views is by their content providers that get called when something changes.
E.g. CoreModel.setProjectDescription->...->CModelManager.firePostChangeDelta()->
...-> CElementContentProvider.processDelta()->...->postRefresh(). 
From the first glance, it seems that the views are not updated if the delta is missing the modified resource. SetCProjectDescriptionOperation.executeOperation() fails to compute the delta for some of the options. This is a more general problem than the original report, but it's definitely worth looking into.
Comment 8 Alex Freidin CLA 2009-08-18 11:14:01 EDT
Created attachment 144835 [details]
Alternative exemplary patch

If we decide that only content providers refresh the view, then appropriate change events should be generated by the model. Today,  CProjectDescriptionManager.generateCElementDeltas() only supports changes of macro, include and libraries settings (refer to ICLanguageSetting/ ICSettingEntry). It should be modified to support deltas for all kinds of resource settings and active configuration change. This is a conceptual change. An exemplary patch that generates the missing deltas is attached.
Comment 9 Andrew Gvozdev CLA 2009-08-26 18:14:25 EDT
(In reply to comment #8)
It sounds for me like the way to go. Is it really a conceptual change? It seems that there was some foresight as the missing kinds are present ICDescriptionDelta. It has not just been implemented in CProjectDescriptionManager.createDelta() yet. I assume you gonna create fully fledged delta your final patch, is it your plan?
Comment 10 Andrew Gvozdev CLA 2010-01-18 00:04:18 EST
It appears that fix for bug 299858 fixes this problem (step 3 from the comment#0). I haven't used your patch directly but the solution is very similar, to trigger an event for resource's CElement. I am sure I used your patch subconsciously so I set IP flag on the attachment. Thanks for the patches.

I think the complain in step 4 is misdirected as Project Explorer uses "Settings configuration" i.e. same configuration which indexer uses. Simple changing of active configuration won't change it. You need to set in project properties->"C/C++ General"->Indexer->"Build configuration for the indexer"->"Use active build configuration". Then it works (maybe with a little delay). What seems to be wrong is that on refresh Project Explorer does display the decorator for active configuration without regard of the properties. I created bug 299895 to follow up with that.
Comment 11 Alex Freidin CLA 2010-01-19 05:30:13 EST
(In reply to comment #10)
> It appears that fix for bug 299858 fixes this problem (step 3 from the
> comment#0). I haven't used your patch directly but the solution is very
> similar, to trigger an event for resource's CElement. I am sure I used your
> patch subconsciously so I set IP flag on the attachment. Thanks for the
> patches.

Thanks for the fix. Unfortunately, I couldn't allocate the time to complete the latest patch.
 
> I think the complain in step 4 is misdirected as Project Explorer uses
> "Settings configuration" i.e. same configuration which indexer uses. Simple
> changing of active configuration won't change it. You need to set in project
> properties->"C/C++ General"->Indexer->"Build configuration for the
> indexer"->"Use active build configuration". Then it works (maybe with a little
> delay). What seems to be wrong is that on refresh Project Explorer does display
> the decorator for active configuration without regard of the properties. I
> created bug 299895 to follow up with that.

I think, we're looking from implementation point of view and not from a user's point of view. It would be extremely difficult to persuade the users that when active configuration changes, the project view does not reflect it. For the "Includes" folder, it barely makes sense. There is no connection from the user's point of view between the indexer settings and the state of the source files displayed in the Project Explorer. The state of the source files should be always updated when anything changes. That's how it works in C/C++ Projects view and hopefully this would be applied to Project Explorer. In that case, the report should be reopened.
Comment 12 Andrew Gvozdev CLA 2010-01-19 09:20:40 EST
(In reply to comment #11)
> > I think the complain in step 4 is misdirected as Project Explorer uses
> > "Settings configuration" i.e. same configuration which indexer uses. Simple
> > changing of active configuration won't change it. You need to set in project
> > properties->"C/C++ General"->Indexer->"Build configuration for the
> > indexer"->"Use active build configuration". Then it works (maybe with a little
> > delay). What seems to be wrong is that on refresh Project Explorer does display
> > the decorator for active configuration without regard of the properties. I
> > created bug 299895 to follow up with that.
> I think, we're looking from implementation point of view and not from a user's
> point of view. It would be extremely difficult to persuade the users that when
> active configuration changes, the project view does not reflect it. For the
> "Includes" folder, it barely makes sense. There is no connection from the user's
> point of view between the indexer settings and the state of the source files
> displayed in the Project Explorer. The state of the source files should be
> always updated when anything changes. That's how it works in C/C++ Projects view
> and hopefully this would be applied to Project Explorer. In that case, the
> report should be reopened.
I agree with you that it is confusing for users and one does expect the view to reflect active configuration. But on the other hand users also want the view to be in sync with the editor where highlighting, navigation etc follow indexer configuration. Ideally it should be the same configuration and the preference should not even be there. When the indexer is able to keep index per configuration and switch at will with no reindexing we will gladly discard it. Until then we have to keep the status quo in consistent way and suffer users' complains.