Lines 56-62
Link Here
|
56 |
* Cache package fragment root information to optimize speed performance. |
56 |
* Cache package fragment root information to optimize speed performance. |
57 |
*/ |
57 |
*/ |
58 |
private String lastPkgFragmentRootPath; |
58 |
private String lastPkgFragmentRootPath; |
59 |
private IPackageFragmentRoot lastPkgFragmentRoot; |
59 |
private PackageFragmentRoot lastPkgFragmentRoot; |
60 |
|
60 |
|
61 |
/** |
61 |
/** |
62 |
* Cache package handles to optimize memory. |
62 |
* Cache package handles to optimize memory. |
Lines 90-96
Link Here
|
90 |
|| (rootPathLength = this.lastPkgFragmentRootPath.length()) != resourcePath.length() |
90 |
|| (rootPathLength = this.lastPkgFragmentRootPath.length()) != resourcePath.length() |
91 |
|| !resourcePath.regionMatches(0, this.lastPkgFragmentRootPath, 0, rootPathLength)) { |
91 |
|| !resourcePath.regionMatches(0, this.lastPkgFragmentRootPath, 0, rootPathLength)) { |
92 |
String jarPath= resourcePath.substring(0, separatorIndex); |
92 |
String jarPath= resourcePath.substring(0, separatorIndex); |
93 |
IPackageFragmentRoot root= this.getJarPkgFragmentRoot(jarPath, scope); |
93 |
PackageFragmentRoot root= getJarPkgFragmentRoot(jarPath, scope); |
94 |
if (root == null) |
94 |
if (root == null) |
95 |
return null; // match is outside classpath |
95 |
return null; // match is outside classpath |
96 |
this.lastPkgFragmentRootPath= jarPath; |
96 |
this.lastPkgFragmentRootPath= jarPath; |
Lines 110-116
Link Here
|
110 |
} |
110 |
} |
111 |
IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName); |
111 |
IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName); |
112 |
if (pkgFragment == null) { |
112 |
if (pkgFragment == null) { |
113 |
pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName); |
113 |
pkgFragment= this.lastPkgFragmentRoot.getPackageFragment(pkgName); |
114 |
this.packageHandles.put(pkgName, pkgFragment); |
114 |
this.packageHandles.put(pkgName, pkgFragment); |
115 |
} |
115 |
} |
116 |
IClassFile classFile= pkgFragment.getClassFile(simpleNames[length]); |
116 |
IClassFile classFile= pkgFragment.getClassFile(simpleNames[length]); |
Lines 121-129
Link Here
|
121 |
int rootPathLength = -1; |
121 |
int rootPathLength = -1; |
122 |
if (this.lastPkgFragmentRootPath == null |
122 |
if (this.lastPkgFragmentRootPath == null |
123 |
|| !(resourcePath.startsWith(this.lastPkgFragmentRootPath) |
123 |
|| !(resourcePath.startsWith(this.lastPkgFragmentRootPath) |
|
|
124 |
&& !org.eclipse.jdt.internal.compiler.util.Util.isExcluded(resourcePath.toCharArray(), this.lastPkgFragmentRoot.fullInclusionPatternChars(), this.lastPkgFragmentRoot.fullExclusionPatternChars(), false) |
124 |
&& (rootPathLength = this.lastPkgFragmentRootPath.length()) > 0 |
125 |
&& (rootPathLength = this.lastPkgFragmentRootPath.length()) > 0 |
125 |
&& resourcePath.charAt(rootPathLength) == '/')) { |
126 |
&& resourcePath.charAt(rootPathLength) == '/')) { |
126 |
IPackageFragmentRoot root= this.getPkgFragmentRoot(resourcePath); |
127 |
PackageFragmentRoot root= getPkgFragmentRoot(resourcePath); |
127 |
if (root == null) |
128 |
if (root == null) |
128 |
return null; // match is outside classpath |
129 |
return null; // match is outside classpath |
129 |
this.lastPkgFragmentRoot = root; |
130 |
this.lastPkgFragmentRoot = root; |
Lines 143-149
Link Here
|
143 |
} |
144 |
} |
144 |
IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName); |
145 |
IPackageFragment pkgFragment= (IPackageFragment) this.packageHandles.get(pkgName); |
145 |
if (pkgFragment == null) { |
146 |
if (pkgFragment == null) { |
146 |
pkgFragment= ((PackageFragmentRoot) this.lastPkgFragmentRoot).getPackageFragment(pkgName); |
147 |
pkgFragment= this.lastPkgFragmentRoot.getPackageFragment(pkgName); |
147 |
this.packageHandles.put(pkgName, pkgFragment); |
148 |
this.packageHandles.put(pkgName, pkgFragment); |
148 |
} |
149 |
} |
149 |
String simpleName= simpleNames[length]; |
150 |
String simpleName= simpleNames[length]; |
Lines 247-253
Link Here
|
247 |
* See createOpenable(...) for the format of the jar path string. |
248 |
* See createOpenable(...) for the format of the jar path string. |
248 |
* If not null, uses the given scope as a hint for getting Java project handles. |
249 |
* If not null, uses the given scope as a hint for getting Java project handles. |
249 |
*/ |
250 |
*/ |
250 |
private IPackageFragmentRoot getJarPkgFragmentRoot(String jarPathString, IJavaSearchScope scope) { |
251 |
private PackageFragmentRoot getJarPkgFragmentRoot(String jarPathString, IJavaSearchScope scope) { |
251 |
|
252 |
|
252 |
IPath jarPath= new Path(jarPathString); |
253 |
IPath jarPath= new Path(jarPathString); |
253 |
|
254 |
|
Lines 261-267
Link Here
|
261 |
try { |
262 |
try { |
262 |
IClasspathEntry entry = javaProject.getClasspathEntryFor(jarPath); |
263 |
IClasspathEntry entry = javaProject.getClasspathEntryFor(jarPath); |
263 |
if (entry != null) { |
264 |
if (entry != null) { |
264 |
return javaProject.getPackageFragmentRoot(jarFile); |
265 |
return (PackageFragmentRoot) javaProject.getPackageFragmentRoot(jarFile); |
265 |
} |
266 |
} |
266 |
} catch (JavaModelException e) { |
267 |
} catch (JavaModelException e) { |
267 |
// ignore and try to find another project |
268 |
// ignore and try to find another project |
Lines 284-290
Link Here
|
284 |
if (index < length) { |
285 |
if (index < length) { |
285 |
System.arraycopy(projects, 0, projects = new IJavaProject[index], 0, index); |
286 |
System.arraycopy(projects, 0, projects = new IJavaProject[index], 0, index); |
286 |
} |
287 |
} |
287 |
IPackageFragmentRoot root = getJarPkgFragmentRoot(jarPath, target, projects); |
288 |
PackageFragmentRoot root = getJarPkgFragmentRoot(jarPath, target, projects); |
288 |
if (root != null) { |
289 |
if (root != null) { |
289 |
return root; |
290 |
return root; |
290 |
} |
291 |
} |
Lines 300-306
Link Here
|
300 |
return getJarPkgFragmentRoot(jarPath, target, projects); |
301 |
return getJarPkgFragmentRoot(jarPath, target, projects); |
301 |
} |
302 |
} |
302 |
|
303 |
|
303 |
private IPackageFragmentRoot getJarPkgFragmentRoot( |
304 |
private PackageFragmentRoot getJarPkgFragmentRoot( |
304 |
IPath jarPath, |
305 |
IPath jarPath, |
305 |
Object target, |
306 |
Object target, |
306 |
IJavaProject[] projects) { |
307 |
IJavaProject[] projects) { |
Lines 311-324
Link Here
|
311 |
if (classpathEnty != null) { |
312 |
if (classpathEnty != null) { |
312 |
if (target instanceof IFile) { |
313 |
if (target instanceof IFile) { |
313 |
// internal jar |
314 |
// internal jar |
314 |
return javaProject.getPackageFragmentRoot((IFile)target); |
315 |
return (PackageFragmentRoot) javaProject.getPackageFragmentRoot((IFile)target); |
315 |
} else { |
316 |
} else { |
316 |
// external jar |
317 |
// external jar |
317 |
return javaProject.getPackageFragmentRoot0(jarPath); |
318 |
return (PackageFragmentRoot) javaProject.getPackageFragmentRoot0(jarPath); |
318 |
} |
319 |
} |
319 |
} |
320 |
} |
320 |
} catch (JavaModelException e) { |
321 |
} catch (JavaModelException e) { |
321 |
// JavaModelException from getResolvedClasspath - a problem occured while accessing project: nothing we can do, ignore |
322 |
// JavaModelException from getResolvedClasspath - a problem occurred while accessing project: nothing we can do, ignore |
322 |
} |
323 |
} |
323 |
} |
324 |
} |
324 |
return null; |
325 |
return null; |
Lines 327-333
Link Here
|
327 |
/** |
328 |
/** |
328 |
* Returns the package fragment root that contains the given resource path. |
329 |
* Returns the package fragment root that contains the given resource path. |
329 |
*/ |
330 |
*/ |
330 |
private IPackageFragmentRoot getPkgFragmentRoot(String pathString) { |
331 |
private PackageFragmentRoot getPkgFragmentRoot(String pathString) { |
331 |
|
332 |
|
332 |
IPath path= new Path(pathString); |
333 |
IPath path= new Path(pathString); |
333 |
IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects(); |
334 |
IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects(); |