Lines 37-42
Link Here
|
37 |
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; |
37 |
import org.eclipse.jdt.internal.compiler.lookup.MethodScope; |
38 |
import org.eclipse.jdt.internal.compiler.lookup.Scope; |
38 |
import org.eclipse.jdt.internal.compiler.lookup.Scope; |
39 |
import org.eclipse.jdt.internal.core.*; |
39 |
import org.eclipse.jdt.internal.core.*; |
|
|
40 |
import org.eclipse.jdt.internal.core.search.AbstractJavaSearchScope; |
40 |
import org.eclipse.jdt.internal.core.util.Util; |
41 |
import org.eclipse.jdt.internal.core.util.Util; |
41 |
|
42 |
|
42 |
/** |
43 |
/** |
Lines 82-88
Link Here
|
82 |
|| (rootPathLength = this.lastPkgFragmentRootPath.length()) != resourcePath.length() |
83 |
|| (rootPathLength = this.lastPkgFragmentRootPath.length()) != resourcePath.length() |
83 |
|| !resourcePath.regionMatches(0, this.lastPkgFragmentRootPath, 0, rootPathLength)) { |
84 |
|| !resourcePath.regionMatches(0, this.lastPkgFragmentRootPath, 0, rootPathLength)) { |
84 |
String jarPath= resourcePath.substring(0, separatorIndex); |
85 |
String jarPath= resourcePath.substring(0, separatorIndex); |
85 |
PackageFragmentRoot root= getJarPkgFragmentRoot(jarPath, scope); |
86 |
PackageFragmentRoot root= getJarPkgFragmentRoot(resourcePath, separatorIndex, jarPath, scope); |
86 |
if (root == null) |
87 |
if (root == null) |
87 |
return null; // match is outside classpath |
88 |
return null; // match is outside classpath |
88 |
this.lastPkgFragmentRootPath= jarPath; |
89 |
this.lastPkgFragmentRootPath= jarPath; |
Lines 240-246
Link Here
|
240 |
* See createOpenable(...) for the format of the jar path string. |
241 |
* See createOpenable(...) for the format of the jar path string. |
241 |
* If not null, uses the given scope as a hint for getting Java project handles. |
242 |
* If not null, uses the given scope as a hint for getting Java project handles. |
242 |
*/ |
243 |
*/ |
243 |
private PackageFragmentRoot getJarPkgFragmentRoot(String jarPathString, IJavaSearchScope scope) { |
244 |
private PackageFragmentRoot getJarPkgFragmentRoot(String resourcePathString, int jarSeparatorIndex, String jarPathString, IJavaSearchScope scope) { |
244 |
|
245 |
|
245 |
IPath jarPath= new Path(jarPathString); |
246 |
IPath jarPath= new Path(jarPathString); |
246 |
|
247 |
|
Lines 264-285
Link Here
|
264 |
// walk projects in the scope and find the first one that has the given jar path in its classpath |
265 |
// walk projects in the scope and find the first one that has the given jar path in its classpath |
265 |
IJavaProject[] projects; |
266 |
IJavaProject[] projects; |
266 |
if (scope != null) { |
267 |
if (scope != null) { |
267 |
IPath[] enclosingProjectsAndJars = scope.enclosingProjectsAndJars(); |
268 |
if (scope instanceof AbstractJavaSearchScope) { |
268 |
int length = enclosingProjectsAndJars.length; |
269 |
PackageFragmentRoot root = (PackageFragmentRoot) ((AbstractJavaSearchScope) scope).packageFragmentRoot(resourcePathString, jarSeparatorIndex, jarPathString); |
269 |
projects = new IJavaProject[length]; |
270 |
if (root != null) |
270 |
int index = 0; |
271 |
return root; |
271 |
for (int i = 0; i < length; i++) { |
272 |
} else { |
272 |
IPath path = enclosingProjectsAndJars[i]; |
273 |
IPath[] enclosingProjectsAndJars = scope.enclosingProjectsAndJars(); |
273 |
if (path.segmentCount() == 1) { |
274 |
int length = enclosingProjectsAndJars.length; |
274 |
projects[index++] = this.javaModel.getJavaProject(path.segment(0)); |
275 |
projects = new IJavaProject[length]; |
|
|
276 |
int index = 0; |
277 |
for (int i = 0; i < length; i++) { |
278 |
IPath path = enclosingProjectsAndJars[i]; |
279 |
if (path.segmentCount() == 1) { |
280 |
projects[index++] = this.javaModel.getJavaProject(path.segment(0)); |
281 |
} |
282 |
} |
283 |
if (index < length) { |
284 |
System.arraycopy(projects, 0, projects = new IJavaProject[index], 0, index); |
285 |
} |
286 |
PackageFragmentRoot root = getJarPkgFragmentRoot(jarPath, target, projects); |
287 |
if (root != null) { |
288 |
return root; |
275 |
} |
289 |
} |
276 |
} |
|
|
277 |
if (index < length) { |
278 |
System.arraycopy(projects, 0, projects = new IJavaProject[index], 0, index); |
279 |
} |
280 |
PackageFragmentRoot root = getJarPkgFragmentRoot(jarPath, target, projects); |
281 |
if (root != null) { |
282 |
return root; |
283 |
} |
290 |
} |
284 |
} |
291 |
} |
285 |
|
292 |
|