Skip to content

fix: help with a language server whose template lists only socket modes, and name every listed socket mode in the hint - #2132

Open
lagergren wants to merge 3 commits into
redhat-developer:mainfrom
lagergren:fix/socket-only-template-transports
Open

lagergren wants to merge 3 commits into
redhat-developer:mainfrom
lagergren:fix/socket-only-template-transports

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Part of #1947.

Please merge with "Rebase and merge", not "Squash and merge". Each of the three commits is one behaviour change, and its title says what users will notice, so a rebase merge puts each in the release notes.

What

Two sections of #1947:

  • A language server that talks only over a socket. A template can say so by listing only socket modes in transports, but nothing used that:
    • there was no hint, and no warning for stdio;
    • without a socket, the New Language Server dialog selected stdio;
    • an installer whose command has no ${port} switched such a language server to stdio (forInstalledCommand), where it can't talk, so it couldn't start afterwards. That happens both when the server starts and from the dialog, also with a fixed port, where the command may name the port itself.
  • The hint uses only the first socket mode of transports. A template that lists startAndConnect and startAndAccept named only the first. Choosing the second swapped its argument into the command, while the hint kept naming the first one's.

No bundled template lists only socket modes, or two socket modes, so this is for imported and plugin templates.

Change

  1. Socket, a hint, and a stdio warning (dc33e2c):
    • The grey hint "This language server talks LSP only over a socket." below the transport.
    • Stdio gives the warning "The template says this language server talks LSP only over a socket" on its button. It is asWarning().withOKEnabled(), so OK and Apply still save.
    • Without a socket, the dialog selects Socket in the first listed socket mode, with an Auto port (attach: no port yet). This happens in loadFromTemplate only, so saved settings never change.
  2. The installer keeps the socket (5c84f3f):
    • The new UserDefinedTransport.forInstalledCommand(command, supportedTransports) keeps the transport of a language server whose template lists only socket modes. The one-argument method is unchanged.
    • UICommandLineUpdater finds the template by its id among the bundled ones, as the settings page does. The dialog uses the template it loaded.
    • With an Auto port, the kept socket can't start until the command takes ${port}. A notification says so, with the action that opens the settings, and the dialog shows its existing ${port} error. A fixed port, which the command may name itself, gets no warning.
  3. A hint for every listed socket mode (e2b13af):
    • One hint per socket mode, in the order of the list, with the existing wording.
    • A mode listed twice shows its first entry, which is the argument the command gets.
    • A template with one socket mode shows the same hint as before.

Docs: the Socket and Transports sections of UserDefinedLanguageServerTemplate.md, and the installer paragraph of UserDefinedLanguageServer.md.

Behaviour changes

Change Commit Who sees it
A language server whose template lists only socket modes starts on Socket in the New Language Server dialog, with a hint that it talks LSP only over a socket, and a warning that doesn't block OK or Apply when stdio is chosen. Before: stdio, with no hint or warning. dc33e2c templates that list only socket modes; no bundled one does
An installer whose command has no ${port} no longer switches such a language server to stdio, on which it can't talk. It keeps its socket, and with an Auto port a warning says that its command needs ${port}. 5c84f3f the same
The hint below the socket modes names every socket mode that the template lists, each with its argument, instead of only the first. e2b13af templates that list several socket modes; no bundled one does

Backward compatibility

  • A template without transports, or with stdio and a socket mode, behaves as before. That is every bundled template.
  • Saved settings keep their transport. A saved stdio of such a language server loads unmodified, with the hint and the warning, and Apply saves it.
  • A template's own socket is kept.
  • The template and settings formats are unchanged. The API only gains forInstalledCommand(String, List<TransportSupport>) and TransportSupport.talksOnlyOverASocket(List).
  • A language server created from an imported template gets this in the New Language Server dialog only: it has no template id, so its settings page and its installer don't find the template. fix: an exported language server keeps the transports of its template #2131 keeps transports in an export, but not with such a server.

Test

  • New tests in TransportFieldsTest, NewLanguageServerDialogTransportTest, LanguageServerViewTransportTest, UICommandLineUpdaterTransportTest and UserDefinedTransportTest: the hint, the stdio warning, the default Socket, a saved stdio, the installer with an Auto and a fixed port, and every listed socket mode. The settings-page and installer tests add a socket-only template to the bundled ones for the test, as none is bundled.
  • With each behaviour put back as on main, its new tests fail: 6 (and the dialog's installer test, which needs the default Socket) for the first commit, 4 for the second, 2 for the third.
  • The settings and launching packages and the transport tests (22 classes, 153 tests) pass on 2024.2, 2025.3 and IU 2026.3. The full suite passes on 2024.2: 1958 tests, 0 failures, 7 skipped (the Windows-only, Docker Bake and Perl tests).

…rver whose template lists only socket modes

A template can say that its language server talks LSP only over a socket,
by listing only socket modes in `transports`, but nothing used that: no
hint, no warning for stdio, and without a `socket` the New Language Server
dialog selected stdio, over which such a language server can't talk.

- A grey hint below the transport, "This language server talks LSP only
  over a socket.", in the dialog and on the settings page of a language
  server created from a bundled template.
- Stdio gives the warning "The template says this language server talks
  LSP only over a socket" on the stdio button. It is
  asWarning().withOKEnabled(), so OK and Apply still save.
- Without a `socket`, the dialog selects Socket for it, in the first socket
  mode of `transports`, with an Auto port (attach: no port yet).
- Unchanged: a template without `transports`, or with stdio and a socket
  mode; a template's own `socket`; and saved settings, which keep their
  transport (a saved stdio shows with the warning, and Apply saves it).

Part of redhat-developer#1947.
… lists only socket modes to stdio

An installer's command is taken to be for the standard input and output
unless it takes ${port}, so a language server which LSP4IJ starts over a
socket was switched to stdio by one without it. A language server whose
template lists only socket modes can't talk over stdio, so it couldn't
start at all afterwards.

- forInstalledCommand(command, supportedTransports) keeps the transport of
  such a language server, and switches any other as before. The
  one-argument forInstalledCommand is unchanged.
- The installer of a language server, at its start or from its settings,
  finds its template by its id among the bundled ones, as the settings page
  does. The New Language Server dialog uses the template it loaded,
  imported ones included.
- With an Auto port, the kept socket can't start until the command takes
  ${port}: a warning says so, with the action which opens the settings, and
  the dialog shows its error "With an Auto port, the command must take the
  port as ${port}". A fixed port, which the command may name itself, gets
  no warning.

Part of redhat-developer#1947.
…ly the first

The hint below the socket modes took the first entry of `transports`
which isn't stdio, so a template which lists both startAndConnect and
startAndAccept, each with its own argument, named only the first: after
choosing the other mode, whose argument the command then gets, the hint
still named the first one's.

- Each socket mode which the template lists has its hint, in the order of
  the list, with the wording of the hint as before: "This language server
  takes the port as {argument}, with "{mode}".", or "This language server
  supports "{mode}"." without an argument.
- A mode listed twice has the hint of its first entry, whose argument the
  command gets when the mode is chosen.
- A template which lists one socket mode shows the same hint as before.

Part of redhat-developer#1947.
@lagergren lagergren added this to the 0.30.2 milestone Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 26c8b386-bd44-4b11-a56f-d73bb4721a31
Commits

Reviewing files that changed from the base of the PR and between 9fde93e and e2b13af.

Files selected for processing: 14

  • docs/UserDefinedLanguageServer.md
  • docs/UserDefinedLanguageServerTemplate.md
  • src/main/java/com/redhat/devtools/lsp4ij/launching/ui/NewLanguageServerDialog.java
  • src/main/java/com/redhat/devtools/lsp4ij/launching/ui/UICommandLineUpdater.java
  • src/main/java/com/redhat/devtools/lsp4ij/server/definition/launching/TransportSupport.java
  • src/main/java/com/redhat/devtools/lsp4ij/server/definition/launching/UserDefinedTransport.java
  • src/main/java/com/redhat/devtools/lsp4ij/settings/ui/LanguageServerPanel.java
  • src/main/java/com/redhat/devtools/lsp4ij/settings/ui/TransportFields.java
  • src/main/resources/messages/LanguageServerBundle.properties
  • src/test/java/com/redhat/devtools/lsp4ij/UICommandLineUpdaterTransportTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/launching/ui/NewLanguageServerDialogTransportTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/server/definition/launching/UserDefinedTransportTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/settings/LanguageServerViewTransportTest.java
  • src/test/java/com/redhat/devtools/lsp4ij/settings/ui/TransportFieldsTest.java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant