Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

F4 shortcut (Open Type Hierarchy) disappears if LSP4E is installed #644

Open
Graou74 opened this issue Jun 26, 2023 · 29 comments
Open

F4 shortcut (Open Type Hierarchy) disappears if LSP4E is installed #644

Graou74 opened this issue Jun 26, 2023 · 29 comments

Comments

@Graou74
Copy link

Graou74 commented Jun 26, 2023

Following the latest update, the F4 shortcut is no longer possible :
Capture d’écran 2023-06-26 à 09 45 57

Whereas until now it was like this :
Capture d’écran 2023-06-26 à 09 46 29

Shortcut settings remain unchanged :
Capture d’écran 2023-06-26 à 09 47 26

Nothing blocking, just a very comfortable little feature.

My Eclipse configuration on Macos :
Version: 2023-06 (4.28.0)
Build id: 20230608-1333

@iloveeclipse iloveeclipse transferred this issue from eclipse-jdt/eclipse.jdt.core Jun 26, 2023
@iloveeclipse iloveeclipse added the needinfo Further information is requested label Jun 26, 2023
@iloveeclipse
Copy link
Member

It could be installed CDT could somehow break the shortcut.
I can't see the issue in the default SDK on master (without CDT). However, I also don't see ith with 4.25 SDK + CDT. So it could be a change in platform or CDT.

But could you please explain:

  • is this only a "visual" issue of not showing the key binding, or F4 doesn't work anymore at all?
  • do you have any errors in the log?
  • can you please try to create a fresh new workspace and check if that could be a problem with the old workspace?
  • if the issue appears in the new workspace too: can you please provide simple step by step instructions how to reproduce the issue?

@Graou74
Copy link
Author

Graou74 commented Jun 26, 2023

To put it simply, I started from a new project in a new workspace and the problem remains exactly the same :

From a new workspace I created a new Java project (tests) then I created a new class "tests.TestClass".

There are some traces in the log file but nothing that explicitly refers to F4 and "Open type hierarchy" :
log.txt

The invocation of the "Open type hierarchy" functionality is still possible by right-clicking with the contextual menu, but calling it via the F4 keyboard shortcut is no longer possible, as has always been the case.

Capture d’écran 2023-06-26 à 11 26 01

@Graou74
Copy link
Author

Graou74 commented Jun 28, 2023

The same phenomenon occurs on PC (Windows 11). Before the update the functionality is accessible via F4 and after the update it can only be accessed via the context menu.

@shadogray
Copy link

The same on Linux (OpenSUSE-Tumbleweed)
reproduced with clean installation and new maven java project
Kernel 6.2.12-1-default
GTK 3-0-3.24.38, 4-1-4.10.4

@iloveeclipse
Copy link
Member

@shadogray : you also have CDT installed?

@shadogray
Copy link

I reproduced the exakt same problem by

  • a clean installation of eclipse-jee-2023-06-R-linux-gtk-x86_64.tar.gz, no updates, no add-ons
  • JDK 17.0.4.1
  • a new Maven/Java project

@laeubi
Copy link
Contributor

laeubi commented Jul 12, 2023

I can't see the issue in the default SDK on master (without CDT). However, I also don't see ith with 4.25 SDK + CDT. So it could be a change in platform or CDT.

I see it with the platform.sdk-ide as well.

@iloveeclipse
Copy link
Member

I see it with the platform.sdk-ide as well.

Please provide exact steps to reproduce. I've just verified it works with latest I20230711-1800 build.
Note, "F4" works with opened Java editor, so might be you have opened Java file in plain text editor or generic editor etc?

@laeubi
Copy link
Contributor

laeubi commented Jul 12, 2023

I don't know how to know the editor, but it looks like a Java Editor here is a screenshot:
grafik

Beside that, I have the https://www.eclipse.org/downloads/packages/release/2023-06/r/eclipse-ide-rcp-and-rap-developers installed and see the same problem there.

@iloveeclipse
Copy link
Member

  • I'm using an IDE installed by oomph:

Can you please download https://download.eclipse.org/eclipse/downloads/drops4/I20230711-1800/ build manually, extract & start with a fresh workspace? This is what I do and I see no problems with SDK.

So I assume either some bundle or Oomph might "steal" the shortcut. If it is Oomph, you might try to clean up all user preferences. For bundles, you can compare difference between "Oomphed" installation and plain SDK and attach the list here.

@laeubi
Copy link
Contributor

laeubi commented Jul 12, 2023

Okay here is the minimal steps to reproduce the problem:

  1. Download https://www.eclipse.org/downloads/packages/release/2023-06/r/eclipse-ide-rcp-and-rap-developers
  2. choose an empty workspace
  3. create a new Java project
  4. add a Class that implements Runnable
  5. focus runnable and press F4
    grafik

Example project: test.zip

@HannesWell
Copy link
Contributor

I have the same issue with my Eclipse-SDK provided by Oomph plus full m2e and egit.
But I have also noticed this with Eclipse-modelling.

@Wittmaxi
Copy link

This also happens for my build of Eclipse.
With Eclipse SDK
Version: 2023-09 (4.29)
Build id: I20230711-0440

Notably, the "show key binding when command is invoked through mouse click/keypress" still reliably displays the action when pressing either F4 or the popup-menu entry.

@iloveeclipse
Copy link
Member

Can you please download https://download.eclipse.org/eclipse/downloads/drops4/I20230711-1800/ build manually, extract & start with a fresh workspace? This is what I do and I see no problems with SDK.

Since no one answers to that and I don't observe issue in the plain SDK, this issue is coming as a conflict with some other bundle that is not included in SDK.

Since I use egit since ever but never used m2e and I assume most of the "packages" include m2e, can anyone please try with SDK (only SDK please) + m2e?

@Graou74
Copy link
Author

Graou74 commented Jul 12, 2023

I downloaded the SDK version only :

Capture d’écran 2023-07-12 à 15 13 37

And indeed in this implementation the F4 is operational.

I am willing to try SDK+m2e if someone tells me how to proceed. How to install.

@shadogray
Copy link

shadogray commented Jul 12, 2023

I reproduced the problem by:

  • download eclipse-SDK-I20230711-1800-linux-gtk-x86_64.tar.gz
  • install Marketplace Client to
  • install M2e (I later found out, that simple "Install new Software" could have worked..)
  • No import of existing project ..
  • create new test workspace
  • create new test maven-project (simple, no archetype)
  • create new java class Test.java
  • open Test.java
  • mouse context click on class name: No F4 assigned!

image

image

@iloveeclipse
Copy link
Member

@shadogray : many thanks. Would you please create issue in m2e project providing your steps?

@HannesWell
Copy link
Contributor

It would be interesting to know if this issue occures if the M2E LemMinX Editor is not installed?
Because my first guess would be that this is related to the language-server used for that. Since I'm not aware of a change in that regard directly in M2E.

@HeikoKlare
Copy link
Contributor

HeikoKlare commented Jul 17, 2023

To me it seems @HannesWell is right and the issue occurs due to the LemMinX editor. It brings in the LSP4E feature, which defines a conflicting F4 key binding.

I use an Oomph-based setup for platform development. In that installation it is as follows:

The LemMinX feature comes into the IDE via Oomph setup:
https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/blob/8417d0b6ea35ee3684c892b9c8791be0adcf614d/oomph/Platform.setup#L778-L779

The LemMinX editor uses LSP4E:
https://github.com/eclipse-m2e/m2e-core/blob/435548b9f86ee18b63bc6884a4cbad2887491832/org.eclipse.m2e.editor.lemminx/META-INF/MANIFEST.MF#L12

And LSP4E defines the "F4" shortcut for "Show Type Hierarchy" in the "textEditor" context.
https://github.com/eclipse/lsp4e/blob/860896bd75ebf36c11df59f1e0db10ea8468f565/org.eclipse.lsp4e/plugin.xml#L394-L399

Since the "javaEditor" context is a subcontext of the "textEditor" context, the binding is inherited.

<context
name="%context.editingJavaSource.name"
description="%context.editingJavaSource.description"
parentId="org.eclipse.ui.textEditorScope"
id="org.eclipse.jdt.ui.javaEditorScope">
</context>

What could be done to proceed?

  1. The conflicting key binding is not detected as tracked here: Keybind doesn't work from editor on upgrade to 4.26 or later eclipse-platform/eclipse.platform.ui#846
  2. Since every other plugin could define an F4 key binding on the generic "textEditor" context while it might be unlikely that someone defines a binding for the specific "javaEditor" context used by JDT, it might make sense to add the binding for the "javaEditor" context in JDT as well.

@mickaelistria
Copy link
Contributor

Can you please enable Window > Preferences > General > Keys > Show key binding when command is invoked > through keyboard, and then report whether some command is at least detected or displayed or not?

@laeubi
Copy link
Contributor

laeubi commented Jul 17, 2023

This shows
grafik

but nothing happens...

@mickaelistria
Copy link
Contributor

OK, so the command is found but either the handler is not resolved, or the handler does nothing.
I will try to investigate as I suspect like @HannesWell it can be the handler for the generic editor/LSP4E which conflicts here (however, even if conflicting, it shouldn't disable another handler...).

@mickaelistria
Copy link
Contributor

Both are actually different commands but same shortcut (they're expected to have different context, so no real conflict should happen in practice, but maybe this approach has glitches).
There are multiple place where some removeBinding methods are called. One of them is probably too aggressive.

@HeikoKlare
Copy link
Contributor

From my understanding, the current behavior is as intended because:

  • "Open Type Hierarchy" is registered by JDT for the "window" context
  • "Show Type Hierarchy" is registered by LSP4E for the "textEditors" context
  • "textEditors" is a child context of the "window" context
  • The Java editor has the "javaEditors" context, which is a child context of "textEditors"

For "textEditors" contexts and its child contexts, this will result in "Show Type Hierarchy" being registered for the F4 shortcut. Since "javaEditors" is a child context of "textEditors", the shortcut is "correctly" bound to "Show Type Hierarchy" when being in some text editor (like the Java source code editor).

@mickaelistria
Copy link
Contributor

While it can make sense to prefer the shortcut from the most specialized content, it doesn't make sense to automatically unset it if we have heuristic to choose one or the other. Note that additionally to the context criterion (which IIRC is correctly used), the binding resolution also looks at command enablement and other things that are often finely tuned, to prevent from actual conflicts.
JDT's binding context could be "javaEditors", that would be fine. But then, would that mean that the F4 from LSP4E would be sometimes removed automatically? I believe we need to reconsider how Platform interprets similar conflicting bindings; warning seems fair, but removing 1 of them randoml-ish is less nice.

@laeubi
Copy link
Contributor

laeubi commented Jul 17, 2023

I think the idea is that the more specific binding can override any global one (including doing nothing).

@iloveeclipse iloveeclipse removed the needinfo Further information is requested label Jul 26, 2023
@iloveeclipse iloveeclipse changed the title The F4 shortcut (Open type hierarchy) has disappeared F4 shortcut (Open Type Hierarchy) disappears if LSP4E is installed Jul 26, 2023
@laeubi
Copy link
Contributor

laeubi commented Aug 18, 2023

@mickaelistria any chance this can be investigated? This is really annoying and degrades user experience for completely unrelated to lsp4e editors....

@mickaelistria
Copy link
Contributor

After a week, I'm still trying to recover from all the mails that I received during my 2 weeks of holidays. I don't yet have a clear view over my backlog to commit to anything.

@walterlaan
Copy link

To make it explicit, the workaround to get it working for Java editors again, is to unbind the command for the language server:
image

This will disable it for language server editors (which seems to be any 'Generic Text Editor'), which doesn't even have the open type hierarchy option anyway when I use it for (pom.)xml or xsd files which launch a XML language server in the background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants