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

Collapse All | Expand All

(-).settings/.api_filters (+7 lines)
Lines 16-19 Link Here
16
            </message_arguments>
16
            </message_arguments>
17
        </filter>
17
        </filter>
18
    </resource>
18
    </resource>
19
    <resource path="search/org/eclipse/jdt/core/search/TypeNameMatch.java" type="org.eclipse.jdt.core.search.TypeNameMatch">
20
        <filter id="336744520">
21
            <message_arguments>
22
                <message_argument value="org.eclipse.jdt.core.search.TypeNameMatch"/>
23
            </message_arguments>
24
        </filter>
25
    </resource>
19
</component>
26
</component>
(-)search/org/eclipse/jdt/core/search/TypeNameMatch.java (-3 / +16 lines)
Lines 18-26 Link Here
18
 * <p>
18
 * <p>
19
 * The type of this match is available from {@link #getType()}.
19
 * The type of this match is available from {@link #getType()}.
20
 * </p>
20
 * </p>
21
 * <p>
21
 *
22
 * This class is not intended to be overridden by clients.
22
 * @noextend This class is not intended to be subclassed by clients.
23
 * </p>
24
 *
23
 *
25
 * @see TypeNameMatchRequestor
24
 * @see TypeNameMatchRequestor
26
 * @see SearchEngine#searchAllTypeNames(char[], int, char[], int, int, IJavaSearchScope, TypeNameMatchRequestor, int, org.eclipse.core.runtime.IProgressMonitor)
25
 * @see SearchEngine#searchAllTypeNames(char[], int, char[], int, int, IJavaSearchScope, TypeNameMatchRequestor, int, org.eclipse.core.runtime.IProgressMonitor)
Lines 30-35 Link Here
30
public abstract class TypeNameMatch {
29
public abstract class TypeNameMatch {
31
30
32
/**
31
/**
32
 * Returns the accessibility of the type name match
33
 *
34
 * @see IAccessRule
35
 *
36
 * @return the accessibility of the type name which may be
37
 * 		{@link IAccessRule#K_ACCESSIBLE}, {@link IAccessRule#K_DISCOURAGED}
38
 * 		or {@link IAccessRule#K_NON_ACCESSIBLE}.
39
 * 		The default returned value is {@link IAccessRule#K_ACCESSIBLE}.
40
 *
41
 * @since 3.6
42
 */
43
public abstract int getAccessibility();
44
45
/**
33
 * Returns the matched type's fully qualified name using '.' character
46
 * Returns the matched type's fully qualified name using '.' character
34
 * as separator (e.g. package name + '.' enclosing type names + '.' simple name).
47
 * as separator (e.g. package name + '.' enclosing type names + '.' simple name).
35
 *
48
 *
(-)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