CDT project view: How to programatically update the directories shown below 'Includes'?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

CDT project view: How to programatically update the directories shown below 'Includes'?

Martin Weber
Hi list,

I wrote an ISettingsProvider that reads a file generated in the build and
feeds the C-include path entries found in the file to the indexer. Works
perfectly.
However, the 'C/C++ projects' view does not show these directories unless I
click Apply in the Project Properties | C/C++ General | Preprocessor Includes
tab.

Is there a way ro update the folder entries programmtically, e.g. by fireing
an even?

Currently the code fires PreferenceConstants.PREF_SHOW_CU_CHILDREN to inform
the indexer; correct me I that`s wrong.

/Martin
 
--
Cd wrttn wtht vwls s mch trsr.


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Doug Schaefer-3
The C/C++ Projects View is unmaintained and should be removed when we do our next major release some time in the future. We have switched to the common Project Explorer.

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Martin Weber
> Sent: Monday, November 20, 2017 3:47 PM
> To: [hidden email]
> Subject: [cdt-dev] CDT project view: How to programatically update the
> directories shown below 'Includes'?
>
> Hi list,
>
> I wrote an ISettingsProvider that reads a file generated in the build and feeds the
> C-include path entries found in the file to the indexer. Works perfectly.
> However, the 'C/C++ projects' view does not show these directories unless I click
> Apply in the Project Properties | C/C++ General | Preprocessor Includes tab.
>
> Is there a way ro update the folder entries programmtically, e.g. by fireing an
> even?
>
> Currently the code fires PreferenceConstants.PREF_SHOW_CU_CHILDREN to
> inform the indexer; correct me I that`s wrong.
>
> /Martin
>
> --
> Cd wrttn wtht vwls s mch trsr.
>
>
> _______________________________________________
> cdt-dev mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Martin Weber
Am Montag, 20. November 2017, 21:11:54 CET schrieb Doug Schaefer:
> The C/C++ Projects View is unmaintained and should be removed when we do our
> next major release some time in the future. We have switched to the common
> Project Explorer.

Will the project explorer then show an include folder? I`am not the only one
who finds it useful.

Martin


--
Cd wrttn wtht vwls s mch trsr.


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Doug Schaefer-3
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Martin Weber
> Sent: Tuesday, November 21, 2017 2:22 PM
> To: CDT General developers list. <[hidden email]>
> Subject: Re: [cdt-dev] CDT project view: How to programatically update the
> directories shown below 'Includes'?
>
> Am Montag, 20. November 2017, 21:11:54 CET schrieb Doug Schaefer:
> > The C/C++ Projects View is unmaintained and should be removed when we
> > do our next major release some time in the future. We have switched to
> > the common Project Explorer.
>
> Will the project explorer then show an include folder? I`am not the only one who
> finds it useful.

What do you find it useful for? Do less knowledgeable users also find it useful?

And besides, it's a lie. Each source file can have its own list of Includes and it changes from build config to build config. So what is it really telling them?

IMHO, the better place to show this is probably in the project properties where it would be more hidden.

Doug.
_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Jonah Graham
In reply to this post by Martin Weber
Hi Martin,

Here is the standard Includes virtual folder in both the (deprecated) C/C++ Projects and Project Explorer view:

Inline images 1 

Is this what you are referring to? Does the Project Explorer update properly for you? Can you share a bit more of your code?

Jonah

~~~
Jonah Graham
Kichwa Coders Ltd.
www.kichwacoders.com

On 21 November 2017 at 19:21, Martin Weber <[hidden email]> wrote:
Am Montag, 20. November 2017, 21:11:54 CET schrieb Doug Schaefer:
> The C/C++ Projects View is unmaintained and should be removed when we do our
> next major release some time in the future. We have switched to the common
> Project Explorer.

Will the project explorer then show an include folder? I`am not the only one
who finds it useful.

Martin


--
Cd wrttn wtht vwls s mch trsr.


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Martin Weber
Am Dienstag, 21. November 2017, 19:35:33 CET schrieb Jonah Graham:
> Hi Martin,
>
> Here is the standard Includes virtual folder in both the (deprecated) C/C++
> Projects and Project Explorer view:
>
> [image: Inline images 1]
>
> Is this what you are referring to? Does the Project Explorer update

Yes, I am referring to that. Glad to see it in the Project Explorer, too!
Do you maintain that code and advise?

> properly for you? Can you share a bit more of your code?

The folder updates only if I open the 'Preprocessor Include Paths...' page in
the project Properties dialog and click 'apply'.
My ILanguageSettingsProvider also implements ICBuildOutputParser to get a
chance to detect settings entries when a user changed one of his
CMakeLists.txt files. It parses a file written and updated by cmake, but no
build logs.

The BuildOutputParser fires a
PropertyChangeEvent(project,PreferenceConstants.PREF_SHOW_CU_CHILDREN, null,
null) event to inform the indexer if it finds include paths or macros. This
seems to trigger re-indexing. (Tell me, If you think that it is of no use).

The code is not hosted on eclipse.org, it`s a plugin I maintain outside of
eclipse on github. Please PM me for details if interested, this is the CDT
mailing list; so no more advertising my plugin here.  

Martin

--
Cd wrttn wtht vwls s mch trsr.


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Jonah Graham
On 21 November 2017 at 20:25, Martin Weber <[hidden email]> wrote:
Am Dienstag, 21. November 2017, 19:35:33 CET schrieb Jonah Graham:
> Hi Martin,
>
> Here is the standard Includes virtual folder in both the (deprecated) C/C++
> Projects and Project Explorer view:
>
> [image: Inline images 1]
>
> Is this what you are referring to? Does the Project Explorer update

Yes, I am referring to that. Glad to see it in the Project Explorer, too!
Do you maintain that code and advise?

I can try to advise, but I don't think anyone actively maintains that code at the moment.
 

> properly for you? Can you share a bit more of your code?

The folder updates only if I open the 'Preprocessor Include Paths...' page in
the project Properties dialog and click 'apply'.
My ILanguageSettingsProvider also implements ICBuildOutputParser to get a
chance to detect settings entries when a user changed one of his
CMakeLists.txt files. It parses a file written and updated by cmake, but no
build logs.

The BuildOutputParser fires a
PropertyChangeEvent(project,PreferenceConstants.PREF_SHOW_CU_CHILDREN, null,
null) event to inform the indexer if it finds include paths or macros. This
seems to trigger re-indexing. (Tell me, If you think that it is of no use).

The code is not hosted on eclipse.org, it`s a plugin I maintain outside of
eclipse on github. Please PM me for details if interested, this is the CDT
mailing list; so no more advertising my plugin here.
It will probably be fastest/most effective for me just to have a look at your code to resolve.
 

Martin

--
Cd wrttn wtht vwls s mch trsr.


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Martin Weber
In reply to this post by Doug Schaefer-3
Am Dienstag, 21. November 2017, 19:32:00 CET schrieb Doug Schaefer:
> > -----Original Message-----
> > From: [hidden email] [mailto:[hidden email]] On
> > Behalf Of Martin Weber
> > Sent: Tuesday, November 21, 2017 2:22 PM
> > To: CDT General developers list. <[hidden email]>
> > Subject: Re: [cdt-dev] CDT project view: How to programatically update the
> > directories shown below 'Includes'?

...
> > Will the project explorer then show an include folder? I`am not the only
> > one who finds it useful.
>
> What do you find it useful for? Do less knowledgeable users also find it
> useful?

I find it useful to easily browse header files of third party libraries (e.g.
/opt/example.org/ccdl/include).
Or cross-compilers that are NOT located below well known dirs like/usr/include
(e.g. /opt/mingw32/include).
Or take a header-only library like boost. On windows, there are no standard
dir location where libraries are installed. A tool like cmake will can find
the library anyway and if its headers are browsable for end-users, that will
be benefit.

>
> And besides, it's a lie. Each source file can have its own list of Includes

Yes, I know it's a lie.
But I see it for just browsing header files: It does not have to reflect each
source file include path. And IMHO, a per-source-file-list of include path is
confusing co-workers.

Martin

--
Cd wrttn wtht vwls s mch trsr.


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Martin Weber
In reply to this post by Jonah Graham
Am Dienstag, 21. November 2017, 20:58:25 CET schrieb Jonah Graham:

> On 21 November 2017 at 20:25, Martin Weber <[hidden email]>
>
> wrote:
> > Am Dienstag, 21. November 2017, 19:35:33 CET schrieb Jonah Graham:
> > > Hi Martin,
> > >
> > > Here is the standard Includes virtual folder in both the (deprecated)
> >
> > C/C++
> >
> > > Projects and Project Explorer view:
> > >
> > > [image: Inline images 1]
> > >
> > > Is this what you are referring to? Does the Project Explorer update
> >
> > Yes, I am referring to that. Glad to see it in the Project Explorer, too!
> > Do you maintain that code and advise?
>
> I can try to advise, but I don't think anyone actively maintains that code
> at the moment.

Please advise.
A simple approach to just call project.getFolder("Includes").refreshLocal()
did not produce any update.

Martin

--
Cd wrttn wtht vwls s mch trsr.


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Jonah Graham
Sorry Martin, I got distracted with something else after not finding the solution quickly. I am not surpised that "project.getFolder("Includes").refreshLocal()" did not work as Includes is not a folder. If you do project.getFolder("Includes").exists() it will return false.

Here is the info I have, hopefully you can figure out the missing piece from there. I didn't manage to verify if this works for your case.

The Content Provider providing Includes to the Common Navigator is: org.eclipse.cdt.internal.ui.navigator.CNavigatorContentProvider (extending the org.eclipse.ui.navigator.navigatorContent extension point). 
IncludeRefContainer provides the view model object for the "Includes" node.
You can refresh the data by calling refresh() on the viewer passing the project as the element to refresh.
The refresh is kicked off by LanguageSettingsProvidersSerializer.notifyLanguageSettingsChangeListeners(ILanguageSettingsChangeEvent) which is kicked off by the below methods.

TL;DR:

You should be able to call this: LanguageSettingsSerializableProvider.serializeLanguageSettingsInBackground(ICConfigurationDescription) or the foreground version serializeLanguageSettings.

HTH



~~~
Jonah Graham
Kichwa Coders Ltd.
www.kichwacoders.com

On 23 November 2017 at 20:41, Martin Weber <[hidden email]> wrote:
Am Dienstag, 21. November 2017, 20:58:25 CET schrieb Jonah Graham:
> On 21 November 2017 at 20:25, Martin Weber <[hidden email]>
>
> wrote:
> > Am Dienstag, 21. November 2017, 19:35:33 CET schrieb Jonah Graham:
> > > Hi Martin,
> > >
> > > Here is the standard Includes virtual folder in both the (deprecated)
> >
> > C/C++
> >
> > > Projects and Project Explorer view:
> > >
> > > [image: Inline images 1]
> > >
> > > Is this what you are referring to? Does the Project Explorer update
> >
> > Yes, I am referring to that. Glad to see it in the Project Explorer, too!
> > Do you maintain that code and advise?
>
> I can try to advise, but I don't think anyone actively maintains that code
> at the moment.

Please advise.
A simple approach to just call project.getFolder("Includes").refreshLocal()
did not produce any update.

Martin

--
Cd wrttn wtht vwls s mch trsr.


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Martin Weber
Am Donnerstag, 23. November 2017, 22:29:57 CET schrieb Jonah Graham:

> Sorry Martin, I got distracted with something else after not finding the

Hi Jonah,
thanks for your thorough investigation.

> The Content Provider providing Includes to the Common Navigator
> is: org.eclipse.cdt.internal.ui.navigator.CNavigatorContentProvider
> (extending the org.eclipse.ui.navigator.navigatorContent extension point).
> IncludeRefContainer provides the view model object for the "Includes" node.
> You can refresh the data by calling refresh() on the viewer passing the
> project as the element to refresh.

Could you explain how to retrieve that viewer? I tried to retrieve it via
PlatformUI.getWorkbench(), but no luck. (I'm not too familiar with JFace, I
admit)

> The refresh is kicked off by
>
LanguageSettingsProvidersSerializer.notifyLanguageSettingsChangeListeners(IL
> anguageSettingsChangeEvent) which is kicked off by the below methods.

This finally ends in a single listener,
org.eclipse.cdt.internal.core.pdom.LanguageSettingsChangeListener and calls
PDOMManager#update(). This seems to trigger re-indexing and updates the
display of open editor views, which is fine.

...
> You should be able to call this:
>
LanguageSettingsSerializableProvider.serializeLanguageSettingsInBackground(I
> CConfigurationDescription) or the foreground version
> serializeLanguageSettings.
Yes, this updates the #if sections in the C-editor views.

Martin

--
E-Mails sollten Text sein, Text und nur Text.
Wenn Gott gewollt hätte, dass E-Mails in HTML geschrieben würden,
endeten Gebete traditionell mit </amen>.
_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Jonah Graham
~~~
Jonah Graham
Kichwa Coders Ltd.
www.kichwacoders.com

On 3 December 2017 at 15:22, Martin Weber <[hidden email]> wrote:

>
> Am Donnerstag, 23. November 2017, 22:29:57 CET schrieb Jonah Graham:
>
> > Sorry Martin, I got distracted with something else after not finding the
>
> Hi Jonah,
> thanks for your thorough investigation.
>
> > The Content Provider providing Includes to the Common Navigator
> > is: org.eclipse.cdt.internal.ui.navigator.CNavigatorContentProvider
> > (extending the org.eclipse.ui.navigator.navigatorContent extension point).
> > IncludeRefContainer provides the view model object for the "Includes" node.
> > You can refresh the data by calling refresh() on the viewer passing the
> > project as the element to refresh.
>
> Could you explain how to retrieve that viewer? I tried to retrieve it via
> PlatformUI.getWorkbench(), but no luck. (I'm not too familiar with JFace, I
> admit)

You shouldn't have to access the viewer directly, unless you still
aren't getting the updates with what you did below. If you put a
breakpoint in IncludeRefContainer, does it get hit when you do
serializeLanguageSettings?

>
> > The refresh is kicked off by
> >
> LanguageSettingsProvidersSerializer.notifyLanguageSettingsChangeListeners(IL
> > anguageSettingsChangeEvent) which is kicked off by the below methods.
>
> This finally ends in a single listener,
> org.eclipse.cdt.internal.core.pdom.LanguageSettingsChangeListener and calls
> PDOMManager#update(). This seems to trigger re-indexing and updates the
> display of open editor views, which is fine.

Good.

> ...
> > You should be able to call this:
> >
> LanguageSettingsSerializableProvider.serializeLanguageSettingsInBackground(I
> > CConfigurationDescription) or the foreground version
> > serializeLanguageSettings.
> Yes, this updates the #if sections in the C-editor views.

And the Includes too?


> Martin
>
> --
> E-Mails sollten Text sein, Text und nur Text.
> Wenn Gott gewollt hätte, dass E-Mails in HTML geschrieben würden,
> endeten Gebete traditionell mit </amen>.
> _______________________________________________
> cdt-dev mailing list
> [hidden email]
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/cdt-dev
_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev
Reply | Threaded
Open this post in threaded view
|

Re: CDT project view: How to programatically update the directories shown below 'Includes'?

Martin Weber
In reply to this post by Jonah Graham
Am Donnerstag, 23. November 2017, 22:29:57 CET schrieb Jonah Graham:

Hi Jonah,
Thanks for your help.

...
> The Content Provider providing Includes to the Common Navigator
> is: org.eclipse.cdt.internal.ui.navigator.CNavigatorContentProvider
> (extending the org.eclipse.ui.navigator.navigatorContent extension point).
> IncludeRefContainer provides the view model object for the "Includes" node.
> You can refresh the data by calling refresh() on the viewer passing the
> project as the element to refresh.

Meanwhile I found out how to refresh the "Includes" node display. But
refreshing it did not provoke any visual effekt.

For the records:

I tracked refresh down to see where the displayed information comes from:
It ends in CModelManager#peekAtInfo(). This method returns information cached
in CModelManager#temporaryCache and CModelManager#cache. Apparently, the
caches only get populated when a project is opened (see
CElement#openWhenClosed()).
So sadly users will have to close and re-open their project to see include
paths detected during the build.

/Martin

--
Cd wrttn wtht vwls s mch trsr.


_______________________________________________
cdt-dev mailing list
[hidden email]
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/cdt-dev