Community
Participate
Working Groups
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
related bug 12955
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.
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.
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.
Verified.