Bug 90612 - Forbidden types must not be available in Code Assist
Summary: Forbidden types must not be available in Code Assist
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: David Audel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 88774
  Show dependency tree
 
Reported: 2005-04-07 10:26 EDT by Wassim Melhem CLA
Modified: 2005-05-12 14:01 EDT (History)
4 users (show)

See Also:


Attachments
patch (14.32 KB, text/plain)
2005-05-02 06:31 EDT, David Audel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wassim Melhem CLA 2005-04-07 10:26:05 EDT
Types that are not accessible and are forbidden on a project's classpath must 
not be available as choices in the code assist popup.
Comment 1 David Audel CLA 2005-04-18 11:17:07 EDT
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 ?
Comment 2 Wassim Melhem CLA 2005-04-18 14:27:10 EDT
'Enabled' would certainly be a better default.
Comment 3 Philipe Mulet CLA 2005-04-18 15:20:39 EDT
Need to think about it.
Comment 4 Wassim Melhem CLA 2005-04-18 15:30:53 EDT
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.
Comment 5 Philipe Mulet CLA 2005-04-18 16:59:59 EDT
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.
Comment 6 David Audel CLA 2005-04-27 10:08:57 EDT
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.
Comment 7 David Audel CLA 2005-04-27 10:18:14 EDT
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
Comment 8 David Audel CLA 2005-04-28 09:19:46 EDT
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"
Comment 9 David Audel CLA 2005-05-02 06:31:54 EDT
Created attachment 20583 [details]
patch
Comment 10 David Audel CLA 2005-05-02 06:42:51 EDT
Need PMC approval
Comment 11 Jim des Rivieres CLA 2005-05-02 08:36:15 EDT
API change approved.
Comment 12 David Audel CLA 2005-05-02 10:36:45 EDT
Fixed.

CompletionTests2 updated.
CompletionTests2#testAccessRestriction13() added.
CompletionTests2#testAccessRestriction14() added.
Comment 13 Wassim Melhem CLA 2005-05-04 19:15:55 EDT
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.
Comment 14 Philipe Mulet CLA 2005-05-05 03:00:06 EDT
This is the intent. I got released recently, so please try with latest build,
and ping David if not working.
Comment 15 David Audel CLA 2005-05-06 04:04:09 EDT
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 ?
Comment 16 Wassim Melhem CLA 2005-05-06 06:37:13 EDT
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.
Comment 17 Olivier Thomann CLA 2005-05-12 14:01:46 EDT
Verified in I20050510-0010 + JDT/Core v_556