View | Details | Raw Unified | Return to bug 296277 | Differences between
and this patch

Collapse All | Expand All

(-)search/org/eclipse/jdt/core/search/TypeNameMatchRequestor.java (-7 / +40 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.search;
11
package org.eclipse.jdt.core.search;
12
12
13
import org.eclipse.jdt.core.IAccessRule;
14
13
/**
15
/**
14
 * A <code>TypeNameMatchRequestor</code> collects matches from a <code>searchAllTypeNames</code>
16
 * A <code>TypeNameMatchRequestor</code> collects matches from a <code>searchAllTypeNames</code>
15
 * query to a <code>SearchEngine</code>. Clients must subclass this abstract class and pass an instance to the
17
 * query to a <code>SearchEngine</code>. Clients must subclass this abstract class and pass an instance to the
Lines 38-48 Link Here
38
 * @since 3.3
40
 * @since 3.3
39
 */
41
 */
40
public abstract class TypeNameMatchRequestor {
42
public abstract class TypeNameMatchRequestor {
41
	/**
43
	private int accessibility = IAccessRule.K_ACCESSIBLE;
42
	 * Accepts a type name match ({@link TypeNameMatch}) which contains top-level or a member type
44
43
	 * information as package name, enclosing types names, simple type name, modifiers, etc.
45
/**
44
	 *
46
 * Accepts a type name match ({@link TypeNameMatch}) which contains top-level or a member type
45
	 * @param match the match which contains all type information
47
 * information as package name, enclosing types names, simple type name, modifiers, etc.
46
	 */
48
 *
47
	public abstract void acceptTypeNameMatch(TypeNameMatch match);
49
 * @param match the match which contains all type information
50
 */
51
public abstract void acceptTypeNameMatch(TypeNameMatch match);
52
53
/**
54
 * Returns the accessibility of the accepted match.
55
 *
56
 * @see IAccessRule
57
 *
58
 * @return the accessibility of the accepted type name which may be
59
 * 		{@link IAccessRule#K_ACCESSIBLE}, {@link IAccessRule#K_DISCOURAGED}
60
 * 		or {@link IAccessRule#K_NON_ACCESSIBLE}.
61
 * 		The default returned value is {@link IAccessRule#K_ACCESSIBLE}.
62
 *
63
 * @since 3.6
64
 * @nooverride This method is not intended to be re-implemented or extended by clients.
65
 */
66
public int getAccessibility() {
67
	return this.accessibility;
68
}
69
70
/**
71
 * Sets the accessibility of the accepted match.
72
 * 
73
 * @param accessibility the accessibility of the accepted type name match
74
 * 
75
 * @noreference This method is not intended to be referenced by clients.
76
 * @nooverride This method is not intended to be re-implemented or extended by clients.
77
 */
78
public void setAccessibility(int accessibility) {
79
	this.accessibility = accessibility;
80
}
48
}
81
}
(-)search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java (+18 lines)
Lines 12-17 Link Here
12
package org.eclipse.jdt.internal.core.search;
12
package org.eclipse.jdt.internal.core.search;
13
13
14
import org.eclipse.core.runtime.Path;
14
import org.eclipse.core.runtime.Path;
15
import org.eclipse.jdt.core.IAccessRule;
15
import org.eclipse.jdt.core.IClassFile;
16
import org.eclipse.jdt.core.IClassFile;
16
import org.eclipse.jdt.core.ICompilationUnit;
17
import org.eclipse.jdt.core.ICompilationUnit;
17
import org.eclipse.jdt.core.IJavaElement;
18
import org.eclipse.jdt.core.IJavaElement;
Lines 20-25 Link Here
20
import org.eclipse.jdt.core.IType;
21
import org.eclipse.jdt.core.IType;
21
import org.eclipse.jdt.core.JavaModelException;
22
import org.eclipse.jdt.core.JavaModelException;
22
import org.eclipse.jdt.core.compiler.CharOperation;
23
import org.eclipse.jdt.core.compiler.CharOperation;
24
import org.eclipse.jdt.core.compiler.IProblem;
23
import org.eclipse.jdt.core.search.IJavaSearchScope;
25
import org.eclipse.jdt.core.search.IJavaSearchScope;
24
import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
26
import org.eclipse.jdt.core.search.TypeNameMatchRequestor;
25
import org.eclipse.jdt.core.search.TypeNameRequestor;
27
import org.eclipse.jdt.core.search.TypeNameRequestor;
Lines 80-85 Link Here
80
 * @see org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor#acceptType(int, char[], char[], char[][], java.lang.String, org.eclipse.jdt.internal.compiler.env.AccessRestriction)
82
 * @see org.eclipse.jdt.internal.core.search.IRestrictedAccessTypeRequestor#acceptType(int, char[], char[], char[][], java.lang.String, org.eclipse.jdt.internal.compiler.env.AccessRestriction)
81
 */
83
 */
82
public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) {
84
public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) {
85
86
	// Update requestor accessibility
87
	if(access != null) {
88
		switch (access.getProblemId()) {
89
			case IProblem.ForbiddenReference:
90
				this.requestor.setAccessibility(IAccessRule.K_NON_ACCESSIBLE);
91
				break;
92
			case IProblem.DiscouragedReference:
93
				this.requestor.setAccessibility(IAccessRule.K_DISCOURAGED);
94
				break;
95
		}
96
	}
97
	
98
	// Get type
83
	try {
99
	try {
84
		IType type = null;
100
		IType type = null;
85
		if (this.handleFactory != null) {
101
		if (this.handleFactory != null) {
Lines 108-113 Link Here
108
				? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames)
124
				? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames)
109
				: createTypeFromJar(path, separatorIndex);
125
				: createTypeFromJar(path, separatorIndex);
110
		}
126
		}
127
		
128
		// Accept match if the type has been found
111
		if (type != null) {
129
		if (type != null) {
112
			// hierarchy scopes require one more check:
130
			// hierarchy scopes require one more check:
113
			if (!(this.scope instanceof HierarchyScope) || ((HierarchyScope)this.scope).enclosesFineGrained(type)) {
131
			if (!(this.scope instanceof HierarchyScope) || ((HierarchyScope)this.scope).enclosesFineGrained(type)) {

Return to bug 296277