eclipse-lsp4e / eclipse-lsp4e/lsp4e

Unexpected "Source > Format" Context Menu in Project Explorer

Open
#1,499 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
85
Forks
69
Avg merge
8h 33m
Merged PRs (30d)
6

Description

In our Product we see unexpected "Source > Format" context menu entries in the project explorer basically everywhere.

See:
Image
But this can also be seen e.g. with plain JDT.

This is confusing because there is already a "Source" context menu entry that has a "Format" entry in it's sub-menu.

The cause is https://github.com/eclipse-lsp4e/lsp4e/pull/364. This part in the plugin.xml looks a bit too broad for me:

      <menuContribution locationURI="popup:org.eclipse.ui.popup.any?endof=group.generate">
         <menu label="Source" mnemonic="S" >
            <command commandId="org.eclipse.lsp4e.formatfile">
               <visibleWhen>
                  <iterate>
                     <or>
                         <adapt type="org.eclipse.core.resources.IFile">
                            <test property="org.eclipse.lsp4e.hasLanguageServer" />
                         </adapt>
                         <adapt type="org.eclipse.core.resources.IFolder" />
                         <adapt type="org.eclipse.core.resources.IProject" />
                     </or>
                  </iterate>
               </visibleWhen>
            </command>
         </menu>
      </menuContribution>

Can we improve this?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the menuContribution in plugin.xml introduced by pull request 364, focusing on its popup location and visibility conditions. Reproduce the context menu in Project Explorer and with plain JDT, then adjust the contribution so it does not create an unexpected duplicate Source > Format entry. Done means the unintended menu is absent while the intended formatting action remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
desktop, devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.