Bug 550226 - [content assist] New proposal category may get enabled by default
Summary: [content assist] New proposal category may get enabled by default
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.13   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.15 RC1   Edit
Assignee: Roland Grunberg CLA
QA Contact: Roland Grunberg CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 558434
  Show dependency tree
 
Reported: 2019-08-19 12:55 EDT by Roland Grunberg CLA
Modified: 2020-02-26 13:37 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roland Grunberg CLA 2019-08-19 12:55:35 EDT
In order to contribute a content assist category and have it disabled by default, one needs to add it to PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES (disable it in the default list), and to PreferenceConstants.CODEASSIST_CATEGORY_ORDER with a cycleState > 65535 to ensure it's disabled even for content assist cycling.

However, if a new proposal category is introduced matching the above criteria, and a user has previously made any changes to the default/cycling list, then the proposal category will be enabled by default, because the user's exclusion list (not containing the new proposal category) would override the default one.

This also makes it difficult to contribute new completion categories as it effectively requires that they be near perfect on inclusion due to the highly visible nature of code completion.
Comment 1 Roland Grunberg CLA 2019-08-19 13:01:45 EDT
It's mentioned in https://bugs.eclipse.org/bugs/show_bug.cgi?id=547833#c10 that appending the new proposal category to the user's exclusion list on the first startup of the Eclipse release that introduces it isn't ideal.

The only other way I see of doing this is to explicitly record whether the user has enabled/disabled a proposal category (rather than just disabled). This way if it isn't present, it's a new option and its default should be respected.
Comment 2 Alexander Kurtakov CLA 2019-09-30 10:57:20 EDT
(In reply to Roland Grunberg from comment #1)
> It's mentioned in https://bugs.eclipse.org/bugs/show_bug.cgi?id=547833#c10
> that appending the new proposal category to the user's exclusion list on the
> first startup of the Eclipse release that introduces it isn't ideal.
> 
> The only other way I see of doing this is to explicitly record whether the
> user has enabled/disabled a proposal category (rather than just disabled).
> This way if it isn't present, it's a new option and its default should be
> respected.

^^ This is the sane way of doing it IMHO.
Comment 3 Noopur Gupta CLA 2019-11-05 06:16:13 EST
Roland, can you please check if the strategy used in bug 511443 can be useful here?
Comment 4 Roland Grunberg CLA 2019-11-13 16:28:15 EST
Yes, I believe the logic in Bug 511443 will work, but it will need to be made a bit more generic so that we're not adding too much code every time we have a new code assist to exclude by default :

initializeCodeassistCategoryDisabled(String id) - This would get called somewhere in the bundle's Activator#start(). It checks if the user has their own preferences (that override the default set) AND if the the migration for the code assist has not been run, add the code assist to the user's exclusion list, and set the "content_assist_${id}_migrated" property to true. Each new content assist needing to be disabled will have its own property that persists.

isCodeassistMigrated(String id) - checks the boolean value for "content_assist_${id}_migrated"

setCodeassistFavoriteStaticMembersMigrated(boolean migrated) - sets the value of "content_assist_${id}_migrated"

After introducing these, every new code assist being introduced would only need an additional method call somewhere in the Activator#start() (in addition to the regular additions to PreferenceConstants for content assist)
Comment 5 Noopur Gupta CLA 2019-11-20 04:18:08 EST
Moving to 4.15.
Comment 6 Eclipse Genie CLA 2020-01-24 12:07:07 EST
New Gerrit change created: https://git.eclipse.org/r/156535
Comment 8 Roland Grunberg CLA 2020-02-26 13:37:08 EST
Verified for 4.15 RC1 using I20200226-0600 build