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

Collapse All | Expand All

(-)search/org/eclipse/jdt/core/search/TypeNameMatch.java (+16 lines)
Lines 30-35 Link Here
30
public abstract class TypeNameMatch {
30
public abstract class TypeNameMatch {
31
31
32
/**
32
/**
33
 * Returns the accessibility of the type name match
34
 *
35
 * @see IAccessRule
36
 *
37
 * @return the accessibility of the type name which may be
38
 * 		{@link IAccessRule#K_ACCESSIBLE}, {@link IAccessRule#K_DISCOURAGED}
39
 * 		or {@link IAccessRule#K_NON_ACCESSIBLE}.
40
 * 		The default returned value is {@link IAccessRule#K_ACCESSIBLE}.
41
 *
42
 * @since 3.6
43
 */
44
public int getAccessibility() {
45
	return IAccessRule.K_ACCESSIBLE;
46
}
47
48
/**
33
 * Returns the matched type's fully qualified name using '.' character
49
 * Returns the matched type's fully qualified name using '.' character
34
 * as separator (e.g. package name + '.' enclosing type names + '.' simple name).
50
 * as separator (e.g. package name + '.' enclosing type names + '.' simple name).
35
 *
51
 *
(-)search/org/eclipse/jdt/internal/core/search/JavaSearchTypeNameMatch.java (-2 / +20 lines)
Lines 20-27 Link Here
20
 */
20
 */
21
public class JavaSearchTypeNameMatch extends TypeNameMatch {
21
public class JavaSearchTypeNameMatch extends TypeNameMatch {
22
22
23
private IType type;
23
	private IType type;
24
private int modifiers = -1; // store modifiers to avoid java model population
24
	private int modifiers = -1; // store modifiers to avoid java model population
25
26
	private int accessibility = IAccessRule.K_ACCESSIBLE;
25
27
26
/**
28
/**
27
 * Creates a new Java Search type name match.
29
 * Creates a new Java Search type name match.
Lines 48-53 Link Here
48
}
50
}
49
51
50
/* (non-Javadoc)
52
/* (non-Javadoc)
53
 * @see org.eclipse.jdt.core.search.TypeNameMatch#getAccessibility()
54
 */
55
public int getAccessibility() {
56
	return this.accessibility;
57
}
58
59
/* (non-Javadoc)
51
 * @see org.eclipse.jdt.core.search.TypeNameMatch#getModifiers()
60
 * @see org.eclipse.jdt.core.search.TypeNameMatch#getModifiers()
52
 */
61
 */
53
public int getModifiers() {
62
public int getModifiers() {
Lines 73-78 Link Here
73
}
82
}
74
83
75
/**
84
/**
85
 * Sets the accessibility of the accepted match.
86
 * 
87
 * @param accessibility the accessibility of the current match
88
 */
89
public void setAccessibility(int accessibility) {
90
	this.accessibility = accessibility;
91
}
92
93
/**
76
 * Set modifiers of the matched type.
94
 * Set modifiers of the matched type.
77
 *
95
 *
78
 * @param modifiers the modifiers of the matched type.
96
 * @param modifiers the modifiers of the matched type.
(-)search/org/eclipse/jdt/internal/core/search/TypeNameMatchRequestorWrapper.java (-1 / +24 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
	// Get type
83
	try {
87
	try {
84
		IType type = null;
88
		IType type = null;
85
		if (this.handleFactory != null) {
89
		if (this.handleFactory != null) {
Lines 108-117 Link Here
108
				? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames)
112
				? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames)
109
				: createTypeFromJar(path, separatorIndex);
113
				: createTypeFromJar(path, separatorIndex);
110
		}
114
		}
115
116
		// Accept match if the type has been found
111
		if (type != null) {
117
		if (type != null) {
112
			// hierarchy scopes require one more check:
118
			// hierarchy scopes require one more check:
113
			if (!(this.scope instanceof HierarchyScope) || ((HierarchyScope)this.scope).enclosesFineGrained(type)) {
119
			if (!(this.scope instanceof HierarchyScope) || ((HierarchyScope)this.scope).enclosesFineGrained(type)) {
114
				this.requestor.acceptTypeNameMatch(new JavaSearchTypeNameMatch(type, modifiers));
120
121
				// Create the match
122
				final JavaSearchTypeNameMatch match = new JavaSearchTypeNameMatch(type, modifiers);
123
124
				// Update match accessibility
125
				if(access != null) {
126
					switch (access.getProblemId()) {
127
						case IProblem.ForbiddenReference:
128
							match.setAccessibility(IAccessRule.K_NON_ACCESSIBLE);
129
							break;
130
						case IProblem.DiscouragedReference:
131
							match.setAccessibility(IAccessRule.K_DISCOURAGED);
132
							break;
133
					}
134
				}
135
136
				// Accept match
137
				this.requestor.acceptTypeNameMatch(match);
115
			}
138
			}
116
		}
139
		}
117
	} catch (JavaModelException e) {
140
	} catch (JavaModelException e) {

Return to bug 296277