Community
Participate
Working Groups
Types that are not accessible and are forbidden on a project's classpath must not be available as choices in the code assist popup.
Currently codeassist propose forbidden reference with a lower relevance. There is an option to not show these proposals but this option is not visible in the preference page (see bug 88774). Default value of this option is 'disabled'. Perhaps 'enabled' would be a better default value for this option ?
'Enabled' would certainly be a better default.
Need to think about it.
Here is the behavior right now: As I type, I see "forbidden" proposals in the code assist. I select one. Right when it gets inserted, I see a red squiggle telling me it's forbidden. Consistency here would be great. ie. not showing the forbidden proposal by default to begin with.
1. the forbidden type is made less relevant, so you wouldn't pick it unless you mean it. 2. forbidden types are only flagged in red if severity is set to ERROR. consistency would need to be relative to chosen severity 3. forbidden type could just mean one need to augment visibility to it, and change the access rules accordingly. Having user not be able to find completion can be quite frustrating (i.e. get out of coding, fix up classpath, and go back to coding). But, we hide completions for non visible matches (configurable) and nobody complains... but we show deprecated code... I am enclined to think that forbidden things should be hidden when severity is an error only.
Need to change code assist options for forbidden and discourared reference. * CODEASSIST / Activate Forbidden Reference Sensitive Completion * When value is "none", completion show forbidden references. * When value is "error", completion doesn't show forbidden references if the compiler problem severity for forbidden references is error. * When value is "warning", completion doesn't show forbidden references if the compiler problem severity for forbidden references is error or warning. * - option id: "org.eclipse.jdt.core.codeComplete.restrictionsCheck" * - possible values: { "none", "error", "warning" } * - default: "error" * * CODEASSIST / Activate Discouraged Reference Sensitive Completion * When value is "none", completion show discouraged references. * When value is "error", completion doesn't show discouraged references if the compiler problem severity for discouraged references is error. * When value is "warning", completion doesn't show discouraged references if the compiler problem severity for discouraged references is error or warning. * - option id: "org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck" * - possible values: { "none", "error", "warning" } * - default: "error" This is an API change.
With options described in comment 6 user will be able to configure code assist: - to show all forbidden references or - to show all forbidden references that do not create compile error or - to not show all forbidden references
Only one option is really necessary to configure code assist. CODEASSIST_DISCOURAGED_REFERENCE_CHECK and CODEASSIST_FORBIDDEN_REFERENCE_CHECK would be replaced by CODEASSIST_HIDE_RESTRICTED_REFERENCES. The behavior of CODEASSIST_HIDE_RESTRICTED_REFERENCES would be: * CODEASSIST / Hide Proposals for Restricted Completions * When value is "never", never hide proposals for restricted completions. * When value is "error", hide proposals for restricted completions if insertion of these completions would create a compile error. * When value is "warning", hide proposals for restricted completions if insertion of these completions would create a compile error or warning. * To configure the severity of restrictions, the "org.eclipse.jdt.core.compiler.problem.forbiddenReference" * option must be used for forbidden reference and the "org.eclipse.jdt.core.compiler.problem.discouragedReference" * option must be used for discouraged reference. * - option id: "org.eclipse.jdt.core.codeComplete.restrictionsCheck" * - possible values: { "never", "error", "warning" } * - default: "error"
Created attachment 20583 [details] patch
Need PMC approval
API change approved.
Fixed. CompletionTests2 updated. CompletionTests2#testAccessRestriction13() added. CompletionTests2#testAccessRestriction14() added.
I have the default of forbidden references set to ERROR and I still see the forbidden types in my code assist. What do I need to do in the UI to filter them out? I was under the impression forbidden types are hidden by default. Discouraged types have lower priority, which is great.
This is the intent. I got released recently, so please try with latest build, and ping David if not working.
I use N20050506-0010 and that's work. With default preferences: -Forbidden types are hidden -Discouraged types are visible with a low relevance If you can see forbidden types with default preferences, could you give me your test case ?
On N-0505, it does work in some cases, but not in others. I will open a separate bug report with my test case if it does not work on 0506.
Verified in I20050510-0010 + JDT/Core v_556