Skip to content

feat: warn when IntelliJ's own LSP client also serves a file of LSP4IJ, from 2026.3 on - #2077

Merged
lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:feat/warn-jetbrains-lsp-overlap
Nov 22, 2026
Merged

lagergren merged 2 commits into
redhat-developer:mainfrom
lagergren:feat/warn-jetbrains-lsp-overlap

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #1933

What

IntelliJ IDEA 2026.3 bundles the plugin LSP Connection Manager (com.intellij.lsp.ui). Its page Settings | Languages & Frameworks | Language Servers starts IntelliJ's own LSP client for the files that a server's file name patterns match. When a file is also served by a language server of LSP4IJ, two clients run for it, and the user sees each diagnostic, completion item and hover twice, with nothing to say why.

Now, when an enabled server of that page and an enabled server of LSP4IJ both serve a file, its editor shows a warning:

This file is served twice: by 'X' of LSP4IJ, and by 'Y' of IntelliJ's Language Servers settings. Disable one of them to avoid duplicate results.

Its links open either settings page, or turn the warning off. After a settings page closes, the warning is checked again.

How the servers of IntelliJ's page are read

Their list isn't public API: getServers() of the settings service is Kotlin-internal, and the service interface, com.intellij.platform.lsp.api.LspIntegrationSettings, is in IntelliJ's LSP module. LSP4IJ doesn't depend on that module, which also has its own copy of lsp4j.

So JetBrainsLanguageServers reads the servers in the form that IntelliJ stores them in:

  • It finds the page (projectConfigurable id lsp.servers), and loads the settings interface through the class loader of the page's plugin module, which depends on IntelliJ's LSP module.
  • It gets the project service, which is a PersistentStateComponent, and serializes its state with XmlSerializer, as IntelliJ does for workspace.xml.
  • It reads the name, enabled and the ;-separated file name patterns of each <server>. Like IntelliJ, it matches the patterns with FileNameMatcherFactory.

That form is less likely to change than the internal getter, because existing workspace.xml files must keep loading. Before 2026.3, without the plugin, or if anything fails, it reads no servers and no warning shows. The servers that other plugins contribute to the page aren't read.

On the LSP4IJ side, the new LanguageServiceAccessor.getMatchedLanguageServerDefinitions(PsiFile) gives the enabled definitions whose mappings match the file, whether their servers are started or not.

Not done

  • The issue's second proposal, which marks a server on LSP4IJ's page whose file patterns also appear on IntelliJ's page.
  • Listing LSP4IJ's servers on IntelliJ's page, through its LspIntegrationSettingsProvider extension point.

Test

  • JetBrainsLanguageServersTest reads the state that IntelliJ IDEA 2026.3 (263.7307) stores, which I took from a real LspIntegrationSettingsImpl serialized with XmlSerializer. It also reads servers through a stand-in settings page and service, and reads none without the page, without the settings class, without the service, or without a state.
  • Its testTheServersOfTheRealSettingsPageAreRead reads the servers of IntelliJ's real settings service. On CI's 2026.3 leg, the tests load LSP Connection Manager, so this test catches a change in how IntelliJ stores its servers. Before 2026.3, it checks that no servers are read.
  • JetBrainsLanguageServerEditorNotificationProviderTest checks the warning's text, and that no warning shows for a disabled server on either side, for a server of IntelliJ that serves other files, for a file that no server of LSP4IJ serves, or once the user turned it off.
  • The ui tests pass on 2024.2 and on 2026.3 (IU), and the full suite passes (1,822 tests, 0 failures, 7 skipped).
  • In the tests, every class has one class loader. So I also ran a real IntelliJ IDEA 2026.3 (263.7307.200), headless, on a project with a server for *.lsptest in its workspace.xml and a user-defined server of LSP4IJ for *.lsptest. A throwaway startup activity, not in this PR, logged what LSP4IJ found. The page's class loader was the PluginClassLoader of the content module intellij.lsp.ui.frontend, the server of IntelliJ was read, and the warning was given for the file.

…J, from 2026.3 on

IntelliJ IDEA 2026.3 bundles LSP Connection Manager, whose page Settings |
Languages & Frameworks | Language Servers starts IntelliJ's own LSP client for
the files that a server's patterns match. A file that a language server of
LSP4IJ also serves then has two clients, and each result shows twice.

The editor of such a file now shows a warning that names both servers, with
links to both settings pages and one to turn it off.

The servers of IntelliJ's page aren't public API, and LSP4IJ doesn't depend on
IntelliJ's LSP module. JetBrainsLanguageServers reads them in the form IntelliJ
stores them in: the state of the page's settings service, loaded through the
class loader of the page's plugin module and serialized with XmlSerializer.
Without the page, or if anything fails, it reads no servers.

Fixes redhat-developer#1933
@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added an editor warning when both LSP4IJ and an IntelliJ language server support the open file. The warning identifies the matching servers, links to their settings, and offers an option to hide future warnings. It appears only when both servers are enabled and match the file.
  • Tests
    • Added coverage for warning visibility, server matching, and behavior when either server is disabled, settings are unavailable, or warnings have been hidden.

The change reads IntelliJ’s language-server settings and adds an editor notification when an enabled IntelliJ server and an LSP4IJ server both match a file. The notification provides settings links and an option to suppress future warnings.

Changes: Duplicate server warning

Layer / File(s) Summary
Read IntelliJ server settings
src/main/java/com/redhat/devtools/lsp4ij/ui/JetBrainsLanguageServers.java, src/test/java/com/redhat/devtools/lsp4ij/ui/JetBrainsLanguageServersTest.java
JetBrainsLanguageServers reads and parses IntelliJ’s serialized server settings. Its tests cover server state, file-pattern matching, settings-page lookup, and unavailable settings.
Detect overlap and show the warning
src/main/java/com/redhat/devtools/lsp4ij/LanguageServiceAccessor.java, src/main/java/com/redhat/devtools/lsp4ij/ui/JetBrainsLanguageServerEditorNotificationProvider.java, src/main/resources/META-INF/plugin.xml, src/main/resources/messages/LanguageServerBundle.properties, src/test/java/com/redhat/devtools/lsp4ij/ui/JetBrainsLanguageServerEditorNotificationProviderTest.java
LanguageServiceAccessor exposes synchronous matched definitions. The notification provider checks for matches from both clients and offers settings and dismissal actions. The plugin registers the provider, and tests cover the notification and its suppression conditions.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Editor
  participant Provider as JetBrainsLanguageServerEditorNotificationProvider
  participant Settings as JetBrainsLanguageServers
  participant Accessor as LanguageServiceAccessor
  Editor->>Provider: collectNotificationData(project, file)
  Provider->>Settings: getServers(project)
  Settings-->>Provider: server names, enabled flags, file patterns
  Provider->>Accessor: getMatchedLanguageServerDefinitions(psiFile)
  Accessor-->>Provider: synchronous matching definitions
  Provider-->>Editor: notification panel when both clients match
Loading

Suggested reviewers: muescha

Merge Risk: Minimal · up to 0aa15

This adds a warning when a file is served by both an LSP4IJ server and a server from IntelliJ's own Language Servers settings. If IntelliJ's settings cannot be read, no warning appears and nothing else changes. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: a warning when IntelliJ's own LSP client also serves a file that LSP4IJ serves, starting with IntelliJ 2026.3. This matches the changeset, which adds the editor notif…
Description check Passed The description covers the change in detail. It explains the duplicate-client problem, the warning text, the links and dismiss option, how IntelliJ's server list is read (projectConfigurable lsp.serve…
Linked Issues check Passed Directly linked issue #1933 asks for a warning when an enabled LSP4IJ server and an enabled server on IntelliJ's Language Servers page both serve a file, with links to both settings pages, for Intelli…
Out of Scope Changes check Passed All changed areas support the warning for #1933: the new LanguageServiceAccessor method (LSP4IJ side of the match), the editor notification provider and its plugin.xml registration, the message bundle…
Full details: Title check

Explanation

The title states the main change: a warning when IntelliJ's own LSP client also serves a file that LSP4IJ serves, starting with IntelliJ 2026.3. This matches the changeset, which adds the editor notification provider, the reader for IntelliJ's server settings, and the LSP4IJ accessor method. The title is long (86 characters), but it is specific and on topic.

Full details: Description check

Explanation

The description covers the change in detail. It explains the duplicate-client problem, the warning text, the links and dismiss option, how IntelliJ's server list is read (projectConfigurable lsp.servers, XmlSerializer, FileNameMatcherFactory), the new LanguageServiceAccessor method, the items not done, and the tests run. It matches the changeset.

Full details: Linked Issues check

Explanation

Directly linked issue #1933 asks for a warning when an enabled LSP4IJ server and an enabled server on IntelliJ's Language Servers page both serve a file, with links to both settings pages, for IntelliJ 2026.3 and later, and with no failure when the JetBrains settings cannot be read. The reviewed head supports these points. JetBrainsLanguageServers.getServers reads the page through its plugin class loader, serializes the settings service state with XmlSerializer, and returns no servers when the page, class, service, or state is missing or reading fails. The head version logs at debug level when the state is null, as the PR description states. LanguageServiceAccessor.getMatchedLanguageServerDefinitions(PsiFile) supplies the LSP4IJ side. JetBrainsLanguageServerEditorNotificationProvider shows the warning and its links, and the tests cover the no-warning cases. The two proposals the issue marks as possibly later are excluded, as the PR states. The incremental diff since the previous reviewed head could not be read, so the changes since that review were checked only through the head file content. The plugin.xml diff could not be read, so an explicit optional-depends entry was not confirmed. Real-IDE behaviour was reported by the author and was not independently verified.

Full details: Out of Scope Changes check

Explanation

All changed areas support the warning for #1933: the new LanguageServiceAccessor method (LSP4IJ side of the match), the editor notification provider and its plugin.xml registration, the message bundle strings, JetBrainsLanguageServers (reading IntelliJ's server list), and the two test classes. The head version of JetBrainsLanguageServers contains only code tied to this purpose. The incremental diff since the previous reviewed head could not be read, so the changes made after the previous review were not checked line by line. The plugin.xml diff could not be read, so its exact content beyond the summary was not checked.

Recent review info

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: 6598f23f-4175-4c8b-b61c-dba7cb4b3e93
Commits

Reviewing files that changed from the base of the PR and between c0cebf2 and 0aa1524.

Files selected for processing: 1

  • src/main/java/com/redhat/devtools/lsp4ij/ui/JetBrainsLanguageServers.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.41176% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.27%. Comparing base (c076544) to head (0aa1524).

Files with missing lines Patch % Lines
...rainsLanguageServerEditorNotificationProvider.java 64.28% 14 Missing and 1 partial ⚠️
...t/devtools/lsp4ij/ui/JetBrainsLanguageServers.java 73.80% 9 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2077      +/-   ##
==========================================
+ Coverage   50.20%   50.27%   +0.07%     
==========================================
  Files         814      816       +2     
  Lines       33614    33699      +85     
  Branches     5249     5261      +12     
==========================================
+ Hits        16875    16942      +67     
- Misses      14104    14114      +10     
- Partials     2635     2643       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@muescha

muescha commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Related: #212

There is a status widget called "Language Service". Maybe this could be a good follow-up?

@lagergren lagergren added this to the 0.30.2 milestone Nov 22, 2026
@lagergren
lagergren merged commit 8b83e2d into redhat-developer:main Nov 22, 2026
9 checks passed
@lagergren lagergren added enhancement New feature or request UI labels Nov 22, 2026
lagergren added a commit that referenced this pull request Nov 26, 2026
…nguage servers of IntelliJ's settings

The plugin verifier reports `PluginDescriptor.getClassLoader()` as deprecated on 2026.1 and later (and experimental on
all the supported versions), from `JetBrainsLanguageServers.getClassLoaderOfPage`, which loads the settings service of
IntelliJ's Language Servers page for the warning of a file that both clients serve (#2077).

It now does as #2040 did in `ServerExtensionPointBean` and `DebugAdapterServerExtensionPointBean`:
`getPluginClassLoader()`, or else the class loader of the descriptor's class, which is what the default
`getClassLoader()` returns on all the supported versions. `getPluginClassLoader()` is public on 2024.2 to 2026.3, and
neither internal, experimental, deprecated nor scheduled for removal on any of them.

`JetBrainsLanguageServersTest.testTheServersAreReadThroughTheSettingsPage` covers it: with no class loader for the page,
it fails.

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

Labels

enhancement New feature or request UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn when a file is served both by LSP4IJ and by IntelliJ's own "Language Servers" settings (2026.3+)

2 participants