Repository navigation
fix: a document matcher whose async match fails no longer takes away the other language servers of the file - #2164
Merged
lagergren merged 2 commits intoNov 23, 2026
Conversation
…the other language servers of the file A language server definition can match a file asynchronously, through a DocumentMatcher whose matchAsync returns a future. A request for the language servers of a file waited for every such matcher of the file in one CompletableFuture.allOf(), without handling a failure. A matcher whose future failed, or whose matchAsync threw, failed the match of the file, and with it the request: the file then got none of its language servers, not even those that matched it synchronously, nor those whose own matchers answered. A bug in the matcher of one plugin took away the language servers of every other plugin, and every user-defined one, for that file. LanguageServiceAccessor.isFileMappedToServer, which the move of an open document and the workspace diagnostics ask, failed too, even for a definition with another mapping that matches the file. A matcher that fails, or whose matchAsync throws, now counts as no match for its definition, and the other definitions, matched synchronously or not, still serve the file. Nothing else reports the failure, so it is logged as a warning, with the name of the definition and the URL of the file. A cancelled match still cancels the request, without a log, as before. An AbstractDocumentMatcher cancels its earlier matches of a file when it is asked again, as when several features ask at once as the file opens while the IDE indexes: a feature whose request is cancelled asks again, while it would keep a result without the language server of the matcher until the file changes. A cancellation that matchAsync throws, and an Error, still propagate too. Fixes redhat-developer#2161
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2164 +/- ##
==========================================
- Coverage 53.79% 53.77% -0.02%
==========================================
Files 828 828
Lines 34993 35037 +44
Branches 5481 5489 +8
==========================================
+ Hits 18825 18842 +17
- Misses 13373 13390 +17
- Partials 2795 2805 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…s away the other language servers of the file LanguageServiceAccessor.getMatchedLanguageServerDefinitions asked each synchronous DocumentMatcher of the file's mappings in a loop, with no error handling. A matcher whose match threw an exception made the match of the file throw, and with it the request for the language servers of the file: the file then got none of its language servers, not even those that other mappings matched. LanguageServiceAccessor.isFileMappedToServer threw too, even for a definition with another mapping that matches the file. A matcher that throws an exception now counts as no match for its definition, and the other mappings still match the file. Nothing else reports the exception, so it is logged as a warning, with the name of the definition and the URL of the file, as for an asynchronous matcher that fails. The exception is caught in the read action that asks the matcher, so a caller without read access, for which the matcher is asked in a read action of its own, gets the same answer as a caller with read access. A ProcessCanceledException, or another cancellation, and an Error still propagate, as before. A file name pattern mapping is found for the language of the file and again for its file type. A synchronous mapping that doesn't match the file is now asked once per match of the file instead of twice, so that the exception of a matcher is logged once. Fixes redhat-developer#2163
Collaborator
Author
|
@coderabbitai review |
Action not completed
|
Collaborator
Author
|
@coderabbitai review |
Action performed
|
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.
Please merge with "Rebase and merge", not "Squash and merge". There are 2 commits, one per issue, so that each reaches the release notes.
Fixes #2161
Fixes #2163
What
A language server definition can match a file asynchronously, through a
DocumentMatcherwhosematchAsyncreturns aCompletableFuture<Boolean>.LanguageServiceAccessor.getMatchedLanguageServerDefinitionswaited for every such matcher of a file in oneCompletableFuture.allOf(...), with no error handling.So one matcher whose future failed, or whose
matchAsyncthrew, failed the whole match, and with it the request for the file's language servers.isFileMappedToServerfailed too, even for a definition with another mapping that matches the file. The move of an open document and the workspace diagnostics ask it.The synchronous counterpart (#2163):
getMatchedLanguageServerDefinitionsasked each synchronousDocumentMatcher.matchof the file's mappings with no error handling. A matcher that threw made the match of the file throw, and with it the request for the file's language servers andisFileMappedToServer. The file got none of its language servers, not even those that other mappings matched.Change
Each asynchronous mapping of the file is matched on its own:
matchAsyncthrows, counts as no match for its definition. Its failure is logged as a warning, with the definition's name and the file's URL, since nothing else reports it.AbstractDocumentMatchercancels its earlier matches of a file when it's asked again, as when several features ask at once while the file opens during indexing. A feature whose request is cancelled asks again; with no match instead, it would keep a result without that language server until the file changes.matchAsync, and anError, still propagate.Both users of the asynchronous match get this, as the combined match no longer fails for one failing matcher: the request for a file's language servers, and
isFileMappedToServer.Second commit (#2163):
DocumentMatcher.matchthat throws an exception counts as no match for its definition. It's logged as a warning with the definition's name and the file's URL, with the same message as an asynchronous failure.runCancellableReadActionasks the matcher in a read action of its own, gets the same answer as a caller with read access.ProcessCanceledException, another cancellation, and anErrorstill propagate.Behaviour change
isFileMappedToServerfor a definition whose matcher failsfalse, ortruewhen another mapping of the definition matchesLanguageServiceAccessorisFileMappedToServerfor a definition whose synchronous matcher throwsfalse, ortruewhen another mapping of the definition matchesProcessCanceledExceptionBackward compatibility
DocumentMatcher,LanguageServerFileAssociationandLanguageServiceAccessorkeep their signatures; only private helpers are added.isFileMappedToServerno longer completes exceptionally for a failing matcher.isFileMappedToServer, as before. A cancellation thrown bymatchAsync, or anError, propagates as before.isFileMappedToServerno longer throws for a synchronous matcher that throws.Test
New tests in
AsynchronousMatcherTest:matchAsyncthat throws matches nothing, and is logged;isFileMappedToServeristruethrough another mapping of the definition, andfalsefor a definition whose only matcher fails;isFileMappedToServer, without a log.The five failure tests fail without the change. The two cancellation tests pass without it, and fail if a cancelled match counts as no match.
New tests for a synchronous matcher that throws (#2163), in
AsynchronousMatcherTest:isFileMappedToServeristruethrough another mapping of the definition, andfalsefor a definition whose only matcher throws;ProcessCanceledExceptionstill propagates.The first four fail without the second commit. The last pins the earlier behaviour, and fails if the fix catches cancellations too.
AsynchronousMatcherTest,WorkspaceDiagnosticsTest,FileDocumentMoveTestandLanguageServerInstancesTest(144 tests) pass on IC 2024.2, IC 2025.3 and IU 2026.3.