Index: codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java,v
retrieving revision 1.228
diff -u -r1.228 CompletionEngine.java
--- codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 28 Apr 2005 14:15:39 -0000 1.228
+++ codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java 2 May 2005 10:30:34 -0000
@@ -26,6 +26,7 @@
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.codeassist.complete.*;
+import org.eclipse.jdt.internal.codeassist.impl.AssistOptions;
import org.eclipse.jdt.internal.codeassist.impl.AssistParser;
import org.eclipse.jdt.internal.codeassist.impl.Engine;
import org.eclipse.jdt.internal.codeassist.impl.Keywords;
@@ -276,11 +277,25 @@
if(accessRestriction != null) {
switch (accessRestriction.getProblemId()) {
case IProblem.ForbiddenReference:
- if(this.options.checkForbiddenReference) return;
+ switch (this.options.restrictedReferenceFilter) {
+ case AssistOptions.FILTER_WARNING:
+ return;
+ case AssistOptions.FILTER_ERROR:
+ if(this.forbiddenReferenceIsError) return;
+ break;
+
+ }
accessibility = IAccessRule.K_NON_ACCESSIBLE;
break;
case IProblem.DiscouragedReference:
- if(this.options.checkDiscouragedReference) return;
+ switch (this.options.restrictedReferenceFilter) {
+ case AssistOptions.FILTER_WARNING:
+ return;
+ case AssistOptions.FILTER_ERROR:
+ if(this.discouragedReferenceIsError) return;
+ break;
+
+ }
accessibility = IAccessRule.K_DISCOURAGED;
break;
}
@@ -3755,11 +3770,25 @@
if(accessRestriction != null) {
switch (accessRestriction.getProblemId()) {
case IProblem.ForbiddenReference:
- if(this.options.checkForbiddenReference) return;
+ switch (this.options.restrictedReferenceFilter) {
+ case AssistOptions.FILTER_WARNING:
+ return;
+ case AssistOptions.FILTER_ERROR:
+ if(this.forbiddenReferenceIsError) return;
+ break;
+
+ }
accessibility = IAccessRule.K_NON_ACCESSIBLE;
break;
case IProblem.DiscouragedReference:
- if(this.options.checkDiscouragedReference) return;
+ switch (this.options.restrictedReferenceFilter) {
+ case AssistOptions.FILTER_WARNING:
+ return;
+ case AssistOptions.FILTER_ERROR:
+ if(this.discouragedReferenceIsError) return;
+ break;
+
+ }
accessibility = IAccessRule.K_DISCOURAGED;
break;
}
@@ -3877,11 +3906,25 @@
if(accessRestriction != null) {
switch (accessRestriction.getProblemId()) {
case IProblem.ForbiddenReference:
- if(this.options.checkForbiddenReference) return;
+ switch (this.options.restrictedReferenceFilter) {
+ case AssistOptions.FILTER_WARNING:
+ return;
+ case AssistOptions.FILTER_ERROR:
+ if(this.forbiddenReferenceIsError) return;
+ break;
+
+ }
accessibility = IAccessRule.K_NON_ACCESSIBLE;
break;
case IProblem.DiscouragedReference:
- if(this.options.checkDiscouragedReference) return;
+ switch (this.options.restrictedReferenceFilter) {
+ case AssistOptions.FILTER_WARNING:
+ return;
+ case AssistOptions.FILTER_ERROR:
+ if(this.discouragedReferenceIsError) return;
+ break;
+
+ }
accessibility = IAccessRule.K_DISCOURAGED;
break;
}
Index: codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistOptions.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistOptions.java,v
retrieving revision 1.17
diff -u -r1.17 AssistOptions.java
--- codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistOptions.java 22 Mar 2005 16:16:21 -0000 1.17
+++ codeassist/org/eclipse/jdt/internal/codeassist/impl/AssistOptions.java 2 May 2005 10:30:34 -0000
@@ -38,17 +38,21 @@
"org.eclipse.jdt.core.codeComplete.localSuffixes"; //$NON-NLS-1$
public static final String OPTION_ArgumentSuffixes =
"org.eclipse.jdt.core.codeComplete.argumentSuffixes"; //$NON-NLS-1$
- public static final String OPTION_PerformForbiddenReferenceCheck =
+ public static final String OPTION_HideRestrictedReferences =
"org.eclipse.jdt.core.codeComplete.restrictionsCheck"; //$NON-NLS-1$
- public static final String OPTION_PerformDiscouragedReferenceCheck =
- "org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck"; //$NON-NLS-1$
public static final String ENABLED = "enabled"; //$NON-NLS-1$
public static final String DISABLED = "disabled"; //$NON-NLS-1$
+ public static final String ERROR = "error"; //$NON-NLS-1$
+ public static final String WARNING = "warning"; //$NON-NLS-1$
+ public static final String NEVER = "never"; //$NON-NLS-1$
+ public static final int FILTER_NEVER = 0;
+ public static final int FILTER_ERROR = 1;
+ public static final int FILTER_WARNING = 2;
+
public boolean checkVisibility = false;
- public boolean checkForbiddenReference = false;
- public boolean checkDiscouragedReference = false;
+ public int restrictedReferenceFilter;
public boolean forceImplicitQualification = false;
public char[][] fieldPrefixes = null;
public char[][] staticFieldPrefixes = null;
@@ -172,18 +176,13 @@
}
}
}
- if ((optionValue = optionsMap.get(OPTION_PerformForbiddenReferenceCheck)) != null) {
- if (ENABLED.equals(optionValue)) {
- this.checkForbiddenReference = true;
- } else if (DISABLED.equals(optionValue)) {
- this.checkForbiddenReference = false;
- }
- }
- if ((optionValue = optionsMap.get(OPTION_PerformDiscouragedReferenceCheck)) != null) {
- if (ENABLED.equals(optionValue)) {
- this.checkDiscouragedReference = true;
- } else if (DISABLED.equals(optionValue)) {
- this.checkDiscouragedReference = false;
+ if ((optionValue = optionsMap.get(OPTION_HideRestrictedReferences)) != null) {
+ if (NEVER.equals(optionValue)) {
+ this.restrictedReferenceFilter = FILTER_NEVER;
+ } else if (ERROR.equals(optionValue)) {
+ this.restrictedReferenceFilter = FILTER_ERROR;
+ } else if (WARNING.equals(optionValue)) {
+ this.restrictedReferenceFilter = FILTER_WARNING;
}
}
}
Index: codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java,v
retrieving revision 1.43
diff -u -r1.43 Engine.java
--- codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java 23 Feb 2005 02:47:58 -0000 1.43
+++ codeassist/org/eclipse/jdt/internal/codeassist/impl/Engine.java 2 May 2005 10:30:34 -0000
@@ -19,6 +19,7 @@
import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.lookup.*;
import org.eclipse.jdt.internal.compiler.parser.*;
+import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
import org.eclipse.jdt.internal.compiler.impl.*;
import org.eclipse.jdt.internal.core.SearchableEnvironment;
@@ -31,10 +32,16 @@
public AssistOptions options;
public CompilerOptions compilerOptions;
+ public boolean forbiddenReferenceIsError;
+ public boolean discouragedReferenceIsError;
public Engine(Map settings){
this.options = new AssistOptions(settings);
this.compilerOptions = new CompilerOptions(settings);
+ this.forbiddenReferenceIsError =
+ this.compilerOptions.getSeverity(CompilerOptions.ForbiddenReference) == ProblemSeverities.Error;
+ this.discouragedReferenceIsError =
+ this.compilerOptions.getSeverity(CompilerOptions.DiscouragedReference) == ProblemSeverities.Error;
}
/**
Index: model/org/eclipse/jdt/core/JavaCore.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/core/JavaCore.java,v
retrieving revision 1.458
diff -u -r1.458 JavaCore.java
--- model/org/eclipse/jdt/core/JavaCore.java 27 Apr 2005 21:06:37 -0000 1.458
+++ model/org/eclipse/jdt/core/JavaCore.java 2 May 2005 10:30:38 -0000
@@ -816,14 +816,7 @@
* @see #getDefaultOptions()
* @since 3.1
*/
- public static final String CODEASSIST_FORBIDDEN_REFERENCE_CHECK = PLUGIN_ID + ".codeComplete.restrictionsCheck"; //$NON-NLS-1$
- /**
- * Possible configurable option ID.
- * @see #getDefaultOptions()
- * @since 3.1
- */
- public static final String CODEASSIST_DISCOURAGED_REFERENCE_CHECK = PLUGIN_ID + ".codeComplete.discouragedReferenceCheck"; //$NON-NLS-1$
-
+ public static final String CODEASSIST_HIDE_RESTRICTED_REFERENCES= PLUGIN_ID + ".codeComplete.restrictionsCheck"; //$NON-NLS-1$
// *************** Possible values for configurable options. ********************
/**
@@ -990,6 +983,12 @@
* @since 3.0
*/
public static final String PRIVATE = "private"; //$NON-NLS-1$
+ /**
+ * Possible configurable option value.
+ * @see #getDefaultOptions()
+ * @since 3.1
+ */
+ public static final String NEVER = "never"; //$NON-NLS-1$
/*
* Cache for options.
@@ -2273,24 +2272,29 @@
* - possible values: { "<suffix>[,<suffix>]*" } where <suffix> is a String without any wild-card
* - default: ""
*
- * CODEASSIST / Activate Forbidden Reference Sensitive Completion
- * When active, completion doesn't show that have forbidden reference.
+ * 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, "org.eclipse.jdt.core.compiler.problem.forbiddenReference"
+ * option must be used for forbidden reference and "org.eclipse.jdt.core.compiler.problem.discouragedReference"
+ * option must be used for discouraged reference.
* - option id: "org.eclipse.jdt.core.codeComplete.restrictionsCheck"
- * - possible values: { "enabled", "disabled" }
- * - default: "disabled"
- *
- * CODEASSIST / Activate Discouraged Reference Sensitive Completion
- * When active, completion doesn't show that have discouraged reference.
- * - option id: "org.eclipse.jdt.core.codeComplete.discouragedReferenceCheck"
- * - possible values: { "enabled", "disabled" }
- * - default: "disabled"
- *
+ * - possible values: { "never", "error", "warning" }
+ * - default: "error"
*
*
* @return a mutable table containing the default settings of all known options
* (key type: String
; value type: String
)
* @see #setOptions(Hashtable)
*/
+
+ /* COMPILER / Reporting Forbidden Reference to Type with Restricted Access
+ * When enabled, the compiler will issue an error or a warning when referring to a type that is non accessible, as defined according
+ * to the access rule specifications.
+ * - option id: "org.eclipse.jdt.core.compiler.problem.forbiddenReference"
+ * - possible values: { "error", "warning", "ignore" }
+ * - default: "warning"*/
public static Hashtable getDefaultOptions(){
Hashtable defaultOptions = new Hashtable(10);
Index: model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java,v
retrieving revision 1.11
diff -u -r1.11 JavaCorePreferenceInitializer.java
--- model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java 7 Apr 2005 21:41:06 -0000 1.11
+++ model/org/eclipse/jdt/internal/core/JavaCorePreferenceInitializer.java 2 May 2005 10:30:38 -0000
@@ -83,9 +83,8 @@
defaultOptionsMap.put(JavaCore.CODEASSIST_STATIC_FIELD_SUFFIXES, ""); //$NON-NLS-1$
defaultOptionsMap.put(JavaCore.CODEASSIST_LOCAL_SUFFIXES, ""); //$NON-NLS-1$
defaultOptionsMap.put(JavaCore.CODEASSIST_ARGUMENT_SUFFIXES, ""); //$NON-NLS-1$
- defaultOptionsMap.put(JavaCore.CODEASSIST_FORBIDDEN_REFERENCE_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
- defaultOptionsMap.put(JavaCore.CODEASSIST_DISCOURAGED_REFERENCE_CHECK, JavaCore.DISABLED); //$NON-NLS-1$
-
+ defaultOptionsMap.put(JavaCore.CODEASSIST_HIDE_RESTRICTED_REFERENCES, JavaCore.ERROR); //$NON-NLS-1$
+
// Store default values to default preferences
IEclipsePreferences defaultPreferences = new DefaultScope().getNode(JavaCore.PLUGIN_ID);
for (Iterator iter = defaultOptionsMap.entrySet().iterator(); iter.hasNext();) {
Index: model/org/eclipse/jdt/internal/core/SearchableEnvironment.java
===================================================================
RCS file: /home/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/SearchableEnvironment.java,v
retrieving revision 1.58
diff -u -r1.58 SearchableEnvironment.java
--- model/org/eclipse/jdt/internal/core/SearchableEnvironment.java 25 Mar 2005 18:39:49 -0000 1.58
+++ model/org/eclipse/jdt/internal/core/SearchableEnvironment.java 2 May 2005 10:30:39 -0000
@@ -271,8 +271,9 @@
public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) {
if (excludePath != null && excludePath.equals(path))
return;
- if (enclosingTypeNames != null && enclosingTypeNames.length > 0)
+ if (enclosingTypeNames != null && enclosingTypeNames.length > 0) {
return; // accept only top level types
+ }
storage.acceptType(packageName, simpleTypeName, modifiers, access);
}
};