Bug 153044 - JarEntryFile does not return fully qualified path
Summary: JarEntryFile does not return fully qualified path
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.3 M6   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 22376
Blocks:
  Show dependency tree
 
Reported: 2006-08-08 04:42 EDT by Benno Baumgartner CLA
Modified: 2010-08-05 13:56 EDT (History)
7 users (show)

See Also:


Attachments
screenshot (54.64 KB, image/png)
2006-08-08 14:26 EDT, Chris Aniszczyk CLA
no flags Details
screenshot (26.16 KB, image/png)
2006-08-09 03:55 EDT, Benno Baumgartner CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Benno Baumgartner CLA 2006-08-08 04:42:03 EDT
3.3.M1 test pass

From some plugin project in the workspace
1. Expand Plug-In Dependencies
2. Expand a project
3. Open its plugin.xml
Is:
  The editor tab hover only shows 'plugin.xml'
Should:
  Indicate to which project the plugin.xml belongs to (Problem occures if you found this plugin.xml through a plugin search)
Comment 1 Benno Baumgartner CLA 2006-08-08 04:51:29 EDT
To reproduce ensure that the selected plugin.xml is not from a project which is in the workspace.
I've opened the plugin.xml with the pde editor.
Comment 2 Chris Aniszczyk CLA 2006-08-08 14:26:04 EDT
Created attachment 47551 [details]
screenshot

I'm a bit confused as I can't reproduce this issue... see screenshot... maybe I don't understand what you're talking about ;)

Screenshots help when talking about problems like this :)
Comment 3 Benno Baumgartner CLA 2006-08-09 03:55:39 EDT
Created attachment 47598 [details]
screenshot

:-) Yes, sorry, this was a 'bit' confusing... It must be a plugin.xml from a project which is not avilable as source in the workspace, see screenshot...

Maybe the hover should state something like 'org.eclipse.u_3.3.0.I.../plugin.xml'
Comment 4 Chris Aniszczyk CLA 2006-08-11 18:20:55 EDT
thoughts on this one Wassim? I'm getting lost in debugging this one.
Comment 5 Chris Aniszczyk CLA 2006-08-22 13:03:58 EDT
So I traced this one to us getting a JDT JarEntryEditorInput versus a PDE JarEntryEditorInput. The JDT implementation has no way to get to the actual zipfile which we need in order to properly display the tooltip.

Thoughts Wassim?

Also, it seems we should just open a text editor, similar to how we do MANIFEST.MF
Comment 6 Wassim Melhem CLA 2006-08-22 13:57:53 EDT
right.  the problem described in comment 0 is due to a limiation in JDT's JarEntryEditorInput.

Chris, you should open a separate bug report against PDE to fix our implementation of the jar input, which occurs when you double-click on a blue icon in the Plug-ins view.
Comment 7 Dani Megert CLA 2006-08-29 09:42:41 EDT
The summary is incorrect: the editor input gets an IStorage from which the JarEntryEditorInput uses getFullPath() for the tool tip text and for its full path. So nothing to blame the JarEntryEditorInput for.

Unfortunately JDT Core's JarEntryFile does not provide the full path.

Adapting summary and moving to JDT Core.
Comment 8 Frederic Fusier CLA 2006-11-21 13:28:54 EST
After discussing about this issue with Dani, we agreed that JDT/Core cannot modify JarFileEntry#getFullPath() as this would have side effects on PackageExplorer while displaying jar file contents
=> move back to JDT/Text
Comment 9 Dani Megert CLA 2006-11-21 13:31:31 EST
Will have to hack the editor input's tool tip.
Comment 10 Dani Megert CLA 2006-11-22 08:15:37 EST
Sorry I have to mark this as WONTFIX because JDT Core decide not to provide the parent of a JarEntryFile as I requested a long time ago, see bug 22376.
Comment 11 Jerome Lanneluc CLA 2007-03-09 06:23:11 EST
Suggest to reopen since bug 22376 is now resolved (dup of bug 148944 which is now fixed)
Comment 12 Markus Keller CLA 2007-03-09 08:57:31 EST
I think we should fix IJarEntryResource.getFullPath(). IStorage.getFullPath() does not specify the exact format of the returned path, so clients already have to handle unexpected results.

The easiest fix would be to change JarEntryResource.getEntryName() to just prepend IPackageFragmentRoot#getPath(). Thus, all clients that just use getFullPath() to render an editor tooltip would be happy (this is the most common scenario).
Comment 13 Dani Megert CLA 2007-03-12 05:51:11 EDT
Agreed. IJarEntryResource.getFullPath() should be cleanly speced and return the full path. Comment 8 is no longer an issue as we now render the folders.
Comment 14 Jerome Lanneluc CLA 2007-03-12 07:12:22 EDT
I agree to spec IJarEntryResource#getFullPath(). However I don't think this should spec that the full path of the IPackageFragmentRoot is prepend. If we did that it would be hard for a client to extract the root relative path of the entry resource.

Consider it as IResource#getFullPath(). It doesn't prepend the workspace path. To get the file system relative path, one should use IResource#getLocation().

Moreover have getFullPath() be a jar relative path corresponds to what a user sees when opening the .jar with a zip viewer (such as WinZip).

So you can either do the prepend in your code, or if you consider it to be important, ask for a getLocation() on IJarEntryResource.
Comment 15 Dani Megert CLA 2007-03-12 07:22:02 EDT
getFullPath() is really not speced anywhere for IStorage and as Markus pointed out the most common/expected result of getFullPath() would be to get full path relative to the workspace root. That's what we normally get when using getFullPath().
Comment 16 Dani Megert CLA 2007-03-12 07:22:40 EDT
BTW: getLocation() would be wrong as we do not want to show the location but rather the path rel. to the workspace root.
Comment 17 Jerome Lanneluc CLA 2007-03-12 07:33:14 EDT
(In reply to comment #15)
> getFullPath() is really not speced anywhere for IStorage 
Agreed, that why I propose to spec it on IJarEntryResource.

(In reply to comment #16)
> BTW: getLocation() would be wrong as we do not want to show the location but
> rather the path rel. to the workspace root.
What about external archives ?
For internal archives, getLocation() might not be a food name. Maybe getWorkspaceRelativePath() would be a better name ?

Comment 18 Dani Megert CLA 2007-03-12 07:40:06 EDT
Instead getFullPath() could be speced as returning the
- workspace root relative path for JARs inside the workspace
- location for external jars
Comment 19 Martin Aeschlimann CLA 2007-03-12 08:01:39 EDT
I also don't like prepending that much, unless we for example use '!' to separate JAR path from the path inside the JAR.
I would suggest to continue with getFullPath to return the path inside the JAR (/plugin.xml) but add new API on IJarEntryResource
  getParentJar() : IPackageFragmentRoot
Comment 20 Dani Megert CLA 2007-03-12 08:03:41 EDT
comment 19 sounds good.
Comment 21 Jerome Lanneluc CLA 2007-03-13 05:33:44 EDT
Added IJarEntryResource#getFullPath() to specify the full path is relative to the jar and added IJarEntryResource#getPackageFragmentRoot() to return the package fragement root the entry belongs too.
Also added regression tests JavaProjectTests#testPackageFragmentNonJavaResources09/11 and testPackageFragmentRootNonJavaResources5/7.
Released for 3.3M6 in HEAD.
Comment 22 Dani Megert CLA 2007-03-13 06:28:21 EDT
Adopted this change in JarEntryEditorInput for I20070313-0800.
Comment 23 Maxime Daniel CLA 2007-03-20 03:42:40 EDT
Verified for 3.3 M6 using build I20070319-1335.

Two remarks:
- I would align getPackageFragmentRoot's doc (talks about files) upon the doc for getFullPath and getParent (talk about resources), except if this is due to a subtlety I did not get;
- I could not make sure from getFullPath's doc whether the returned IPath would start with a leading '/' (as suggested by 'absolute' - and confirmed by tests contents) or not; maybe this is the remark about the result never bearing a trailing '/' that raised doubts in my mind, or the presence of 'absolute' and 'relative to' in a single sentence, or even the comments on this bug; or else maybe the doc would deserve an explicit statement that the returned path starts with '/'.
Comment 24 Jerome Lanneluc CLA 2007-03-20 07:05:44 EDT
Thanks Maxime. Entered bug 178226 to capture these issues.
Comment 25 Adam Taylor CLA 2010-08-05 12:59:02 EDT
I realize this is an old post, but I'm hoping someone can help me anyway.  I need to be able to get the jar file name and path from an IStorageEditorInput (which has type JarEntryEditorInput) as you have discussed below.  However the solution you've come up with requires a dependency on JDT, and I absolutely cannot have a dependency on JDT. 

Is there any possible way to get the path to the jar without the dependency on JDT (as IStorage.getFullPath() just returns the file name within the jar).
Comment 26 Markus Keller CLA 2010-08-05 13:56:59 EDT
(In reply to comment #25)
> Is there any possible way to get the path to the jar without the dependency on
> JDT (as IStorage.getFullPath() just returns the file name within the jar).

There's currently no clean way. IJarEntryResource is only available in JDT Core, so anything you'd do with it depends on JDT.

A way to implement this would be to offer something like
org.eclipse.debug.core.sourcelookup.containers.ZipEntryStorage in org.eclipse.core.resources and then let JDT's IJarEntryResource implementations use that new ZipEntryStorage. This would need new enhancement requests in JDT/Core and Platform/Resources.

Maybe some reflection hacks could also work, but this would still make you depend on JDT (albeit not in your bundle manifest).