Community
Participate
Working Groups
Hi, I am writing a plugin that allows the user to select a certain java element (IType, IClassFile, ICompilationUnit) and and invoke an action to create a patchfile for the selected element. The patchfile should be written to the (or one of the) source folder of the project "the selected element comes from". To find out this project I need to call IJavaElement.getJavaProject(). When this java element comes from an external archive AND the same archive is used in more than one open project in the workspace IJavaElement. getJavaProject() can return the wrong project - depending on the order these projects were opened. I believe this behaviour may be "by design", to optimize the underlying java model to hold the contents of the archive only once. But there should be a way to safely determine, from which project the selected java element exactly came from.
Your assumption is the right one. This is a performance issue. The user selection should tell you the proper project context.
Given an IStructuredSelection in my action object, how does this selection reveal me the proper project context? The only thing in this selection object is the selected element itself... Regards, Lars
Moving to JDT/UI, they probably know the answer.
No, JDT/UI has the same problem. We don't have "proper project context" either since selections are managed by JFace. Moving back to JDT/Core.
Hi all, seems like there is more interest in this request than just mine. I would propose that selections in trees lead to a specialized IStructuredSelection, which would allow to navigate the selection path (maybe similar to javax.swing.tree.TreePath). That would perfectly fit my needs and probably the needs of JDT/UI as well. Will some of you support a feature request? Regards, Lars
Created attachment 7225 [details] Proposed patch Changing equals(...) on PackageFragmentRoot and JarPackageFragmentRoot to also consider the parent. However the element info is still shared, the key being the package fragment root's path.
Deferring post 3.1
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.
*** Bug 162037 has been marked as a duplicate of this bug. ***