### Eclipse Workspace Patch 1.0
#P org.eclipse.jdt.core
Index: search/org/eclipse/jdt/core/search/TypeNameMatchRequestor.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/TypeNameMatchRequestor.java,v
retrieving revision 1.6
diff -u -r1.6 TypeNameMatchRequestor.java
--- search/org/eclipse/jdt/core/search/TypeNameMatchRequestor.java 7 Mar 2009 01:08:10 -0000 1.6
+++ search/org/eclipse/jdt/core/search/TypeNameMatchRequestor.java 27 Nov 2009 12:18:17 -0000
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.search;
+import org.eclipse.jdt.core.IAccessRule;
+
/**
* A TypeNameMatchRequestor
collects matches from a searchAllTypeNames
* query to a SearchEngine
. Clients must subclass this abstract class and pass an instance to the
@@ -38,11 +40,42 @@
* @since 3.3
*/
public abstract class TypeNameMatchRequestor {
- /**
- * Accepts a type name match ({@link TypeNameMatch}) which contains top-level or a member type
- * information as package name, enclosing types names, simple type name, modifiers, etc.
- *
- * @param match the match which contains all type information
- */
- public abstract void acceptTypeNameMatch(TypeNameMatch match);
+ private int accessibility = IAccessRule.K_ACCESSIBLE;
+
+/**
+ * Accepts a type name match ({@link TypeNameMatch}) which contains top-level or a member type
+ * information as package name, enclosing types names, simple type name, modifiers, etc.
+ *
+ * @param match the match which contains all type information
+ */
+public abstract void acceptTypeNameMatch(TypeNameMatch match);
+
+/**
+ * Returns the accessibility of the accepted match.
+ *
+ * @see IAccessRule
+ *
+ * @return the accessibility of the accepted type name which may be
+ * {@link IAccessRule#K_ACCESSIBLE}, {@link IAccessRule#K_DISCOURAGED}
+ * or {@link IAccessRule#K_NON_ACCESSIBLE}.
+ * The default returned value is {@link IAccessRule#K_ACCESSIBLE}.
+ *
+ * @since 3.6
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+public int getAccessibility() {
+ return this.accessibility;
+}
+
+/**
+ * Sets the accessibility of the accepted match.
+ *
+ * @param accessibility the accessibility of the accepted type name match
+ *
+ * @noreference This method is not intended to be referenced by clients.
+ * @nooverride This method is not intended to be re-implemented or extended by clients.
+ */
+public void setAccessibility(int accessibility) {
+ this.accessibility = accessibility;
+}
}
Index: search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java,v
retrieving revision 1.14
diff -u -r1.14 TypeNameMatchRequestorWrapper.java
--- search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java 22 Oct 2009 12:29:08 -0000 1.14
+++ search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java 27 Nov 2009 12:18:17 -0000
@@ -12,6 +12,7 @@
package org.eclipse.jdt.internal.core.search;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IAccessRule;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
@@ -20,6 +21,7 @@
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
import org.eclipse.jdt.core.search.TypeNameRequestor;
@@ -80,6 +82,20 @@
* @see org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor#acceptType(int, char[], char[], char[][], java.lang.String, org.eclipse.jdt.internal.compiler.env.AccessRestriction)
*/
public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) {
+
+ // Update requestor accessibility
+ if(access != null) {
+ switch (access.getProblemId()) {
+ case IProblem.ForbiddenReference:
+ this.requestor.setAccessibility(IAccessRule.K_NON_ACCESSIBLE);
+ break;
+ case IProblem.DiscouragedReference:
+ this.requestor.setAccessibility(IAccessRule.K_DISCOURAGED);
+ break;
+ }
+ }
+
+ // Get type
try {
IType type = null;
if (this.handleFactory != null) {
@@ -108,6 +124,8 @@
? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames)
: createTypeFromJar(path, separatorIndex);
}
+
+ // Accept match if the type has been found
if (type != null) {
// hierarchy scopes require one more check:
if (!(this.scope instanceof HierarchyScope) || ((HierarchyScope)this.scope).enclosesFineGrained(type)) {