Commit Graph

19 Commits

Author SHA1 Message Date
Rintaro Ishizaki 626861d316 Merge pull request #2654 from rintaro/per-workspace-language-services
Scope language service lifetime to workspace
2026-05-18 14:59:47 -07:00
Rintaro Ishizaki f84abc1eb2 Use 'weak let' for immutable weak references (SE-0481)
Replace 'weak var' with 'weak let' for weak reference properties that are
set in init and never reassigned, using the Swift 6.3 feature introduced
by SE-0481.
2026-05-18 09:28:10 -07:00
Rintaro Ishizaki f2a121453d Scope language service instances per workspace
Previously, language services were held in a global registry on
SourceKitLSPServer and shared across workspaces, requiring complex
lifetime tracking (isImmortal, shutdownOrphanedLanguageServices) to
decide when to tear them down. In practice, every language service
already stored workspace-specific properties (buildServerManager,
semanticIndexManagerTask), so sharing them across workspaces was never
truly safe. Giving each Workspace its own service instances simplifies
lifetime management: services are created when needed and shut down
with their workspace.

Remove LanguageService.isImmortal, the workspace parameter from
canHandle(toolchain:), and the initialize/clientInitialized protocol
requirements.
2026-05-18 09:21:01 -07:00
25harsh 90ceac197d Use ExpressibleByLiteral conformances for LSPAny 2026-05-13 16:19:42 +05:30
Rintaro Ishizaki 1c99daabef [TestDiscovery] Prefer syntactic scan results over semantic index
Previously, test discovery used the semantic index as the primary
source and fell back to the syntactic index only for files where the
semantic index was out-of-date. This meant test locations came from the
semantic index, which only records a point position rather than the
full symbol range.

Flip the priority: use syntactic scan results as the primary source
(which have correct location ranges) and supplement with semantic index
results. The semantic results are range-fixed via
'textDocument/documentSymbol' before being returned.

This logic is unified into a single 'combineTests' helper shared by
both 'workspaceTests' and 'documentTests'.

Also fix 'SyntacticSwiftXCTestScanner' to emit extensions as proper
'AnnotatedTestItem' nodes (with 'isExtension: true') rather than a flat
list of methods, so extension test methods are correctly merged into
their class via 'mergingTestsInExtensions'. The class and extension
visitors are unified through a shared 'handleClassOrExtension' helper.
2026-03-04 16:58:21 -08:00
Adam Ward 308375a135 Move syntactic index back to Workspace 2025-12-08 15:16:36 -05:00
Adam Ward 9602433d2a Add new workspace/playgrounds request 2025-12-08 15:16:36 -05:00
Owen Voorhees f04b971726 Adopt swift-tools-protocols 2025-10-31 14:11:11 -07:00
Alex Hoppen 36ccc68784 Merge pull request #2275 from ahoppen/fix-warnings
Fix build warnings
2025-09-01 22:59:07 +02:00
Alex Hoppen 87a945d692 Fix build warnings 2025-09-01 17:26:44 +02:00
Alex Hoppen ef665080c9 Explicitly implement syntacticTestItems in DocumentationLanguageService
`SyntacticTestIndex` queries all language services for a document for its syntactic test items. This caused `syntacticDocumentTests not implemented in DocumentationLanguageService` to be logged for every Swift file in the project. Remove the default implementation of `syntacticDocumentTests` in `LanguageService` and instead provide an implementation that returns an empty array in `DocumentationLanguageService`.

While at it, also log the files for which unimplemented methods are called on `LanguageService`. This makes it easier to dermine why they are called.
2025-09-01 16:52:31 +02:00
Alex Hoppen 4040a5e4ac Add default implementations to LanguageService for methods that are not expected to be implemented by all language services
With the introduction of secondary language services, we don’t expect every language service to implement every request anymore. To simplify the addition of language services like `DocumentationLanguageService` add default implementations for methods that satisfy the following criteria:
 - `SourceKitLSPServer` does not expect side effects to happen when they are called
 - The method can throw or there is a reasonable default value
 - It is reasonable to expect that not all language services need to implement it
2025-08-26 16:10:36 +02:00
Alex Hoppen 49e1c3839c Merge DocumentationLanguageService and DocCDocumentation 2025-08-25 07:07:55 +02:00
Alex Hoppen 64fe439f24 Make DocumentationLanguageService the only module that imports DocCDocumentation 2025-08-21 10:10:54 +02:00
Alex Hoppen 1ca9780cd7 Merge pull request #2248 from ahoppen/lang-service-init-not-failable
Make `LanguageService` initializer non-failable
2025-08-20 06:51:27 +02:00
Alex Hoppen 08faa197af Make LanguageService initializer non-failable 2025-08-20 00:21:45 +02:00
Alex Hoppen 22fae21153 Handle documentation requests for Swift files in DocumentationLanguageService
This cleanly separates the responsibilities for handling documentation from those of handling Swift files. It also simplifies providing docc support for clang because we just need to implement the two `symbolGraph` methods in `ClangLanguageService` and can re-use the remaining infrastructure from `DoccLanguageService`.
2025-08-20 00:20:27 +02:00
Alex Hoppen 0e75e951d3 Allow multiple language services to handle a single document
This allows us to implement all of `doccDocumentation` in `DocumentationLanguageService`. `DocumentationLanguageService` will be a secondary language service for Swift files and can also provide the docc documentation support that’s currently in `SwiftLangaugeService`.
2025-08-18 07:52:19 +02:00
Alex Hoppen 83cc023b25 Move DocumentationLanguageService to a separate module 2025-08-15 11:48:27 +02:00