### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: search/org/eclipse/jdt/core/search/TypeNameMatch.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/core/search/TypeNameMatch.java,v retrieving revision 1.13 diff -u -r1.13 TypeNameMatch.java --- search/org/eclipse/jdt/core/search/TypeNameMatch.java 7 Mar 2009 01:08:10 -0000 1.13 +++ search/org/eclipse/jdt/core/search/TypeNameMatch.java 1 Dec 2009 11:31:35 -0000 @@ -30,6 +30,22 @@ public abstract class TypeNameMatch { /** + * Returns the accessibility of the type name match + * + * @see IAccessRule + * + * @return the accessibility of the 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 + */ +public int getAccessibility() { + return IAccessRule.K_ACCESSIBLE; +} + +/** * Returns the matched type's fully qualified name using '.' character * as separator (e.g. package name + '.' enclosing type names + '.' simple name). * Index: search/org/eclipse/jdt/internal/core/search/JavaSearchTypeNameMatch.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/search/org/eclipse/jdt/internal/core/search/JavaSearchTypeNameMatch.java,v retrieving revision 1.4 diff -u -r1.4 JavaSearchTypeNameMatch.java --- search/org/eclipse/jdt/internal/core/search/JavaSearchTypeNameMatch.java 7 Mar 2009 01:08:10 -0000 1.4 +++ search/org/eclipse/jdt/internal/core/search/JavaSearchTypeNameMatch.java 1 Dec 2009 11:31:35 -0000 @@ -20,8 +20,10 @@ */ public class JavaSearchTypeNameMatch extends TypeNameMatch { -private IType type; -private int modifiers = -1; // store modifiers to avoid java model population + private IType type; + private int modifiers = -1; // store modifiers to avoid java model population + + private int accessibility = IAccessRule.K_ACCESSIBLE; /** * Creates a new Java Search type name match. @@ -48,6 +50,13 @@ } /* (non-Javadoc) + * @see org.eclipse.jdt.core.search.TypeNameMatch#getAccessibility() + */ +public int getAccessibility() { + return this.accessibility; +} + +/* (non-Javadoc) * @see org.eclipse.jdt.core.search.TypeNameMatch#getModifiers() */ public int getModifiers() { @@ -73,6 +82,15 @@ } /** + * Sets the accessibility of the accepted match. + * + * @param accessibility the accessibility of the current match + */ +public void setAccessibility(int accessibility) { + this.accessibility = accessibility; +} + +/** * Set modifiers of the matched type. * * @param modifiers the modifiers of the matched type. 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 1 Dec 2009 11:31:35 -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,8 @@ * @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) { + + // Get type try { IType type = null; if (this.handleFactory != null) { @@ -108,10 +112,29 @@ ? 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)) { - this.requestor.acceptTypeNameMatch(new JavaSearchTypeNameMatch(type, modifiers)); + + // Create the match + final JavaSearchTypeNameMatch match = new JavaSearchTypeNameMatch(type, modifiers); + + // Update match accessibility + if(access != null) { + switch (access.getProblemId()) { + case IProblem.ForbiddenReference: + match.setAccessibility(IAccessRule.K_NON_ACCESSIBLE); + break; + case IProblem.DiscouragedReference: + match.setAccessibility(IAccessRule.K_DISCOURAGED); + break; + } + } + + // Accept match + this.requestor.acceptTypeNameMatch(match); } } } catch (JavaModelException e) {