Bug 24245

Summary: IJavaSearchScope.enclosingProjectsAndJars doc misleading, hard to use
Product: [Eclipse Project] JDT Reporter: Martin Aeschlimann <martinae>
Component: CoreAssignee: Jerome Lanneluc <jerome_lanneluc>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.1 M2   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Martin Aeschlimann CLA 2002-10-01 03:42:26 EDT
20020924
The Javadoc of enclosingProjectsAndJars says:
A project path is the full path to the project. A JAR path is the full OS path 
to the JAR file.

When looking at returned values, this seems to be wrong:
- projects are returned using the workspace path (/MyProject). What does 'full' 
mean in the doc?
- External JAR are returned with the full OS path, internal JAR's however are 
returned with a workspacepath (/MyProject/xy.jar).

A problem of the returned paths is that these paths might not uniquly map to a 
resource:
xy.jar might point
 - to a project names xy.jar
 - to an external jar /xy.jar 
ab/xy.jar
 - to an internal jar xy.jar in project ab
 - to an external jar ab/xy.jar 

Use case for this method is in jdt.ui / TypeInfo
Comment 1 Martin Aeschlimann CLA 2002-10-01 04:02:25 EDT
related bug 12955
Comment 2 Jerome Lanneluc CLA 2002-10-02 07:51:33 EDT
Clarified the spec:
/**
 * Returns the paths to the enclosing projects and JARs for this search scope.
 * <ul>
 * <li> If the path is a project path, this is the full path of the project
 *       (see <code>IResource.getFullPath()</code>).
 *        E.g. /MyProject
 * </li>
 * <li> If the path is a JAR path and this JAR is internal to the workspace,
 *        this is the full path of the JAR file (see <code>IResource.getFullPath
()</code>).
 *        E.g. /MyProject/mylib.jar
 * </li>
 * <li> If the path is a JAR path and this JAR is external to the workspace,
 *        this is the full OS path to the JAR file on the file system.
 *        E.g. d:\libs\mylib.jar
 * </li>
 * </ul>
 * 
 * @return an array of paths to the enclosing projects and JARS.
 */

Otherwise to distinguish an internal jar from an external jar, from a project, 
you can use IContainer.findMember(...). See JavaModel.getTarget(...) for an 
example.
Comment 3 Martin Aeschlimann CLA 2002-10-02 08:39:11 EDT
This does not help with the problem that 
xy.jar might point
 - to a project named xy.jar
 - to an external jar /xy.jar 

Like in the internal/external JAR case: The resolve order must be specified or 
a find method offered.
Comment 4 Jerome Lanneluc CLA 2002-10-02 09:12:55 EDT
The same path cannot correspond to both an external jar and a project. If 
findMember() returns a non-null value, then it is internal to the workspace and 
thus in this case it is a project.
Comment 5 David Audel CLA 2002-10-17 10:26:19 EDT
Verified.