Preserve language service when closing generated interface#2648
Merged
Conversation
Closing a generated interface document (sourcekit-lsp:// URI) was removing the language service for the originating source file because both share the same buildSettingsFile key. Guard the removal so it only happens when no other open document shares that key. Relates to swiftlang#2209
The buildSettingsFile key is an implementation detail of Workspace's language-service dictionary, so the guard that prevents removing a still-needed service belongs there rather than in SourceKitLSPServer.
…on CI Use IndexedSingleSwiftFileTestProject with -ignore-module-source-info to force the generated interface code path. Without this, CI toolchains (built from source) resolve String to actual stdlib source files, causing GetReferenceDocumentRequest to receive a file:// URI instead of sourcekit-lsp://, resulting in an "Invalid Scheme" error.
Member
Author
|
@swift-ci Please test |
hamishknight
approved these changes
May 14, 2026
ahoppen
reviewed
May 15, 2026
| } | ||
| """, | ||
| capabilities: ClientCapabilities(experimental: [ | ||
| GetReferenceDocumentRequest.method: .dictionary(["supported": true]) |
Member
There was a problem hiding this comment.
Should be able to use LSPAny conformance to ExpressibleByDictionaryLiteral.
Suggested change
| GetReferenceDocumentRequest.method: .dictionary(["supported": true]) | |
| GetReferenceDocumentRequest.method: ["supported": true] |
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 a bug where closing a generated interface document (e.g. a
sourcekit-lsp://Swift interface) would remove the language service for the originating source file, breaking subsequent requests like hover.Both the generated interface and its originating source file share the same
buildSettingsFilekey inWorkspace.languageServices, so closing the interface caused the service to be removed even while the source document was still open.Based on #2598 by @edwardlee. The test has been updated to use
IndexedSingleSwiftFileTestProjectwith-ignore-module-source-infoto avoid CI failures on source-built toolchains, where sourcekitd resolves stdlib types to real source files rather than generated interfaces.