Bug 533633 - "Link with Editor" and "Show In > Project Explorer" fail for JDT editor out of a JDT source folder
Summary: "Link with Editor" and "Show In > Project Explorer" fail for JDT editor out o...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 normal with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
: 364789 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-04-16 12:51 EDT by Mickael Istria CLA
Modified: 2022-07-11 12:34 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mickael Istria CLA 2018-04-16 12:51:03 EDT
Steps to reproduce:
0. Get a workbench with Project Explorer and "Link with Editor" enabled
1. Create a raw (non-Java) project
2. Create a file t.java in the project. JDT Editor opens the empty t.java file.
3. Click on another editor, and back in t.java.
EXPECTED: t.java node selected in Project Explorer
GOT: no selection in project explorer
4. From the JDT editor for t.java, right-click > Show In > Project Explorer
EXPECTED: t.java node selected in Project Explorer
GOT: no selection in project explorer

Variations of the failure:
* A variant of those steps to reproduce can be achieved by opening a .java from a JDT project, but with the .java file that's not under a source folder.

Working variations:
* Same actions with a .java file opened with JDT editor in a JDT project and with file under a JDT source folder work
* Using another editor than JDT one (such as plain text editor) to open the .java file allows to get link with editor working.


Code analysis:
When opening a .java file with JDT editor, the JavaFileLinkHelper participates to resolution. Later, in CommonViewer.setSelection(...), update.getRefreshTargets() is used and returns only the working copy of installation unit, but the CommonViewer doesn't have any node for this CU and fails at selecting the file.
When using on a non .java file or another editor, the JavaFileLinkHelper doesn't participate so it fails back to plain file resolution which works well.
When inside opening a .java file that's inside a JDT source folder, the CommonViewer does has a node for the CompilationUnit and shows it.

Remediation proposal:
The JavaFileLinkHelper should only contribute for .java files open with JDT editor which are part of the build path (with a compilation unit existing in the CommonViewer).
Comment 1 Mickael Istria CLA 2018-04-16 14:46:16 EDT
Note that it could be the NavigatorPipelineService#interceptRefresh method which erroneously removes the file from the item to select, but I'm currently not able to understand whether it can be the source of the bug and am still in the idea that JDT is to blame so far.
Comment 2 Mickael Istria CLA 2018-04-16 15:00:19 EDT
*** Bug 364789 has been marked as a duplicate of this bug. ***
Comment 3 Eclipse Genie CLA 2018-04-16 15:27:54 EDT
New Gerrit change created: https://git.eclipse.org/r/121215
Comment 4 Noopur Gupta CLA 2018-04-17 06:45:57 EDT
(In reply to Eclipse Genie from comment #3)
> New Gerrit change created: https://git.eclipse.org/r/121215
Is this patch ready for review?
Comment 5 Mickael Istria CLA 2018-04-17 07:20:44 EDT
(In reply to Noopur Gupta from comment #4)
> (In reply to Eclipse Genie from comment #3)
> > New Gerrit change created: https://git.eclipse.org/r/121215
> Is this patch ready for review?

It is for the part about "Link With Editor", but the "Show In > Project Explorer" still doesn't work.
Comment 6 Lars Vogel CLA 2018-04-17 14:44:19 EDT
Please consider for M7, I see this error every day in my documentation projects in which I have lots of Java example file which are not in the build path.
Comment 7 Mickael Istria CLA 2018-04-18 04:13:00 EDT
(In reply to Mickael Istria from comment #5)
> (In reply to Noopur Gupta from comment #4)
> > (In reply to Eclipse Genie from comment #3)
> > > New Gerrit change created: https://git.eclipse.org/r/121215
> > Is this patch ready for review?
> 
> It is for the part about "Link With Editor", but the "Show In > Project
> Explorer" still doesn't work.

I think my answer wasn't clear.
Is it ready for review -> Yes, this patch is ready for review as it fixes half of the request of this report.
Comment 9 Noopur Gupta CLA 2018-04-18 05:41:43 EDT
(In reply to Mickael Istria from comment #7)
> Is it ready for review -> Yes, this patch is ready for review as it fixes
> half of the request of this report.
Thanks, I have released this patch.

We can set the target again once we have a patch for the other part.
Comment 10 Eclipse Genie CLA 2020-06-13 16:58:45 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 11 Mauro Molinari CLA 2020-06-16 11:54:29 EDT
This still applies to 2019-12 and, together with bug #364600, makes it hard to deal with Gradle build files.
Comment 12 Eclipse Genie CLA 2022-07-11 12:34:57 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.