Lines 13-18
Link Here
|
13 |
import org.eclipse.core.runtime.Path; |
13 |
import org.eclipse.core.runtime.Path; |
14 |
import org.eclipse.jdt.core.IClassFile; |
14 |
import org.eclipse.jdt.core.IClassFile; |
15 |
import org.eclipse.jdt.core.ICompilationUnit; |
15 |
import org.eclipse.jdt.core.ICompilationUnit; |
|
|
16 |
import org.eclipse.jdt.core.IJavaElement; |
16 |
import org.eclipse.jdt.core.IPackageFragment; |
17 |
import org.eclipse.jdt.core.IPackageFragment; |
17 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
18 |
import org.eclipse.jdt.core.IPackageFragmentRoot; |
18 |
import org.eclipse.jdt.core.IType; |
19 |
import org.eclipse.jdt.core.IType; |
Lines 22-28
Link Here
|
22 |
import org.eclipse.jdt.core.search.TypeNameMatchRequestor; |
23 |
import org.eclipse.jdt.core.search.TypeNameMatchRequestor; |
23 |
import org.eclipse.jdt.core.search.TypeNameRequestor; |
24 |
import org.eclipse.jdt.core.search.TypeNameRequestor; |
24 |
import org.eclipse.jdt.internal.compiler.env.AccessRestriction; |
25 |
import org.eclipse.jdt.internal.compiler.env.AccessRestriction; |
|
|
26 |
import org.eclipse.jdt.internal.core.Openable; |
25 |
import org.eclipse.jdt.internal.core.PackageFragmentRoot; |
27 |
import org.eclipse.jdt.internal.core.PackageFragmentRoot; |
|
|
28 |
import org.eclipse.jdt.internal.core.util.HandleFactory; |
26 |
import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject; |
29 |
import org.eclipse.jdt.internal.core.util.HashtableOfArrayToObject; |
27 |
|
30 |
|
28 |
/** |
31 |
/** |
Lines 51-56
Link Here
|
51 |
public class TypeNameMatchRequestorWrapper implements IRestrictedAccessTypeRequestor { |
54 |
public class TypeNameMatchRequestorWrapper implements IRestrictedAccessTypeRequestor { |
52 |
TypeNameMatchRequestor requestor; |
55 |
TypeNameMatchRequestor requestor; |
53 |
private IJavaSearchScope scope; // scope is needed to retrieve project path for external resource |
56 |
private IJavaSearchScope scope; // scope is needed to retrieve project path for external resource |
|
|
57 |
private HandleFactory handleFactory; |
54 |
|
58 |
|
55 |
/** |
59 |
/** |
56 |
* Cache package fragment root information to optimize speed performance. |
60 |
* Cache package fragment root information to optimize speed performance. |
Lines 66-71
Link Here
|
66 |
public TypeNameMatchRequestorWrapper(TypeNameMatchRequestor requestor, IJavaSearchScope scope) { |
70 |
public TypeNameMatchRequestorWrapper(TypeNameMatchRequestor requestor, IJavaSearchScope scope) { |
67 |
this.requestor = requestor; |
71 |
this.requestor = requestor; |
68 |
this.scope = scope; |
72 |
this.scope = scope; |
|
|
73 |
this.handleFactory = (scope instanceof JavaSearchScope) ? null : new HandleFactory(); |
69 |
} |
74 |
} |
70 |
|
75 |
|
71 |
/* (non-Javadoc) |
76 |
/* (non-Javadoc) |
Lines 73-82
Link Here
|
73 |
*/ |
78 |
*/ |
74 |
public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { |
79 |
public void acceptType(int modifiers, char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path, AccessRestriction access) { |
75 |
try { |
80 |
try { |
76 |
int separatorIndex= path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR); |
81 |
IType type = null; |
77 |
IType type = separatorIndex == -1 |
82 |
if (this.handleFactory != null) { |
78 |
? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames) |
83 |
Openable openable = this.handleFactory.createOpenable(path, scope); |
79 |
: createTypeFromJar(path, separatorIndex); |
84 |
switch (openable.getElementType()) { |
|
|
85 |
case IJavaElement.COMPILATION_UNIT: |
86 |
type = ((ICompilationUnit)openable).getType(new String(simpleTypeName)); |
87 |
break; |
88 |
case IJavaElement.CLASS_FILE: |
89 |
type = ((IClassFile)openable).getType(); |
90 |
break; |
91 |
} |
92 |
} else { |
93 |
int separatorIndex= path.indexOf(IJavaSearchScope.JAR_FILE_ENTRY_SEPARATOR); |
94 |
type = separatorIndex == -1 |
95 |
? createTypeFromPath(path, new String(simpleTypeName), enclosingTypeNames) |
96 |
: createTypeFromJar(path, separatorIndex); |
97 |
} |
80 |
if (type != null) { |
98 |
if (type != null) { |
81 |
this.requestor.acceptTypeNameMatch(new JavaSearchTypeNameMatch(type, modifiers)); |
99 |
this.requestor.acceptTypeNameMatch(new JavaSearchTypeNameMatch(type, modifiers)); |
82 |
} |
100 |
} |