Repository navigation
feat: warn when IntelliJ's own LSP client also serves a file of LSP4IJ, from 2026.3 on - #2077
Merged
lagergren merged 2 commits intoNov 22, 2026
Conversation
…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
Collaborator
Author
|
@coderabbitai review |
Action not completed
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
muescha
reviewed
Nov 22, 2026
Contributor
|
Related: #212 There is a status widget called "Language Service". Maybe this could be a good follow-up? |
This was referenced Nov 24, 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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
JetBrainsLanguageServersreads the servers in the form that IntelliJ stores them in:projectConfigurableidlsp.servers), and loads the settings interface through the class loader of the page's plugin module, which depends on IntelliJ's LSP module.PersistentStateComponent, and serializes its state withXmlSerializer, as IntelliJ does forworkspace.xml.enabledand the;-separated file name patterns of each<server>. Like IntelliJ, it matches the patterns withFileNameMatcherFactory.That form is less likely to change than the internal getter, because existing
workspace.xmlfiles 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
LspIntegrationSettingsProviderextension point.Test
JetBrainsLanguageServersTestreads the state that IntelliJ IDEA 2026.3 (263.7307) stores, which I took from a realLspIntegrationSettingsImplserialized withXmlSerializer. 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.testTheServersOfTheRealSettingsPageAreReadreads 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.JetBrainsLanguageServerEditorNotificationProviderTestchecks 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.uitests pass on 2024.2 and on 2026.3 (IU), and the full suite passes (1,822 tests, 0 failures, 7 skipped).*.lsptestin itsworkspace.xmland 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 thePluginClassLoaderof the content moduleintellij.lsp.ui.frontend, the server of IntelliJ was read, and the warning was given for the file.