Commit Graph

4570 Commits

Author SHA1 Message Date
Bri Peticca da0c9a9ad9 Fix spm API usage for appropriate trait configuration
The `WorkspaceConfiguration.default` was being used to populate
the `Workspace`; there was an extra step here needed to assure that
we are propagating the trait configuration to the workspace.

The added test assures that non-default traits that are enabled are
indeed processed as enabled.
2026-05-27 12:57:16 -04:00
Rintaro Ishizaki 8e8a6ce79a Merge pull request #2665 from rintaro/atomics-test-migration
Migrate test-case atomic usages to ThreadSafeBox / Atomic
swift-DEVELOPMENT-SNAPSHOT-2026-05-27-a
2026-05-26 10:05:54 -07:00
Rintaro Ishizaki f9cbba2c2c Migrate test-case atomic usages to ThreadSafeBox / Atomic
Migrate remaining AtomicBool / AtomicUInt32 usages in test cases to
ThreadSafeBox / Atomic.

- Closure-captured `AtomicBool` flags become `ThreadSafeBox<Bool>` for
  now. We will revisit this when eliminating ThreadSafeBox.
- One `AtomicUInt32` counter (SourceKitDRegistryTests.swift's
  `nextToken`) to `Atomic<UInt32>`.
2026-05-22 16:40:29 -07:00
Rintaro Ishizaki 70f4c333ea Merge pull request #2662 from rintaro/migrate-atomics-to-synchronization
Migrate atomic call sites to Synchronization.Atomic
2026-05-22 11:34:13 -07:00
Alex Hoppen f53b3eaaf0 Merge pull request #2659 from Steffeeen/rename-fix 2026-05-21 21:50:15 +02:00
Rintaro Ishizaki a6c926fa34 Relax atomic memory orderings; switch semaphore to release/acquire
For ID counters and standalone flags (most sites), drop to .relaxed
since nothing reads other memory based on the atomic's value.

MultiEntrySemaphore.signaled is the exception: it is used as a
signal/wait primitive where waiters proceed to use state set up
before signal(). Use .releasing on store and .acquiring on load so
that pre-signal writes are visible to waiters that observe `true`.
.relaxed there would be incorrect on weakly-ordered architectures.
2026-05-21 11:16:17 -07:00
Rintaro Ishizaki 83de30d29f Migrate atomic call sites to Synchronization.Atomic and ThreadSafeBox
Replace AtomicBool/UInt8/UInt32/Int32 from
ToolsProtocolsSwiftExtensions with Synchronization.Atomic<T> where
the storage is a static, module-level let, or class stored property.
For local lets captured by @Sendable closures (where Atomic's
~Copyable nature prevents capture), use ThreadSafeBox<T> instead.
2026-05-21 10:58:34 -07:00
Rintaro Ishizaki f4117f68c1 Merge pull request #2661 from rintaro/langservice-tweak 2026-05-21 06:28:15 -07:00
Steffeeen a7f43dc54c Fix rename target selection for initializer calls
When rename is invoked on a type name in an initializer call, prefer
renaming the nominal type symbol instead of the constructor symbol.
2026-05-21 10:55:47 +02:00
Rintaro Ishizaki a39c92022f Add forOpenDocument label to language service lookup methods
Rename languageServices(for:), primaryLanguageService(for:), and their
internal counterparts to use the `forOpenDocument` label, so the
precondition that the document must already be open is visible at call
sites.

Also make primaryLanguageService(forOpenDocument:) throw instead of
returning an optional, and switch several resolve-style handlers from
the find-or-create primaryLanguageService(for:_:) to
primaryLanguageService(forOpenDocument:), since those call sites already
have an open document in hand.
2026-05-20 10:31:44 -07:00
Rintaro Ishizaki 876fbad114 Merge pull request #2658 from rintaro/warnings-20260518
Fix build warnings
swift-DEVELOPMENT-SNAPSHOT-2026-05-20-a
2026-05-19 05:37:48 -07:00
Rintaro Ishizaki b7fc4b5f1b Merge pull request #2655 from femaref/feature/proper-end
provide proper start and end positions in the LSP protocol
2026-05-18 21:03:48 -07:00
Rintaro Ishizaki f56a27b996 Fix build warnings 2026-05-18 18:04:44 -07:00
femaref c4c552203a provide proper start and end positions in the LSP protocol
vscode provides an alternative action if the target of goto definition is in the same character range we requested.
this requires the start and end in the LSP response to be properly set, so vscode can see that the current character
is actually part of the request
2026-05-19 00:02:17 +02:00
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 8dc98fb8b8 Merge pull request #2657 from rintaro/weak-let
Use 'weak let' for immutable weak references (SE-0481)
2026-05-18 14:28:49 -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
Alex Hoppen 0cacc26db3 Merge pull request #2591 from ahoppen/require-6.3
Require Swift 6.3
2026-05-18 15:27:18 +02:00
Rintaro Ishizaki 7519e7755c Merge pull request #2656 from rintaro/fix-deployment-target-mismatch swift-DEVELOPMENT-SNAPSHOT-2026-05-18-a 2026-05-18 05:36:44 -07:00
Rintaro Ishizaki 829802891d [Test] Fix deployment target mismatch in SwiftPMBuildServerTests
testToolsets: sourcekit-lsp is built against a just-built SwiftPM,
which can use macOS 10.13 as the minimum for packages with no explicit
platforms requirement. The preparation step runs the toolchain's
'swift build', which can use a higher macOS minimum deployment target.
The resulting module embeds a higher deployment target, causing a
spurious mismatch diagnostic when the other target imports it.

testBasicSwiftArgs (swiftbuild variant): swift-build can clamp the
deployment target to the SDK's MinimumDeploymentTarget, which can be
above the 10.13 the BSP reports, so the expected triple no longer
matches.

Fix by explicitly setting the deployment target to 13.0 in both test
packages via 'platforms: [.macOS(.v13)]'.
2026-05-17 15:52:31 -07:00
Alex Hoppen c8fb7afb6d Merge pull request #2644 from YooGyeongMo/fix-references-includes-definition 2026-05-17 22:04:56 +02:00
Rintaro Ishizaki a559d60451 Merge pull request #2648 from rintaro/language-service-close
Preserve language service when closing generated interface
swift-DEVELOPMENT-SNAPSHOT-2026-05-17-a swift-DEVELOPMENT-SNAPSHOT-2026-05-16-a swift-DEVELOPMENT-SNAPSHOT-2026-05-15-a
2026-05-14 16:26:50 -07:00
Rintaro Ishizaki 5c820cf61f Fix testClosingGeneratedInterfacePreservesOriginatingLanguageService 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.
2026-05-14 11:09:08 -07:00
Rintaro Ishizaki 1d20e3f32e Merge pull request #2647 from rintaro/open-quickly-revise
Move Open Quickly and Jump to Definition docs to Contributor Documentation
2026-05-14 06:41:48 -07:00
Rintaro Ishizaki b60b9582ac Move language-service retention check into Workspace
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.
2026-05-13 20:59:29 -07:00
Edward Lee ca91f5ff4f Preserve language service when closing generated interface documents
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 #2209
2026-05-13 15:56:27 -07:00
Alex Hoppen 310c701583 Merge pull request #2645 from 25harsh/use-lspany-literal-conformance 2026-05-13 23:29:28 +02:00
Rintaro Ishizaki 292985e7dd Remove redundant fragment-clearing when constructing moduleFileURI 2026-05-13 10:25:09 -07:00
Rintaro Ishizaki 77f474de45 Move Open Quickly and Jump to Definition docs to Contributor Documentation 2026-05-13 10:22:16 -07:00
G.M_YOO a1fc1ed917 Remove testReferencesWithDeclaration covered by existing tests 2026-05-13 22:38:45 +09:00
25harsh 90ceac197d Use ExpressibleByLiteral conformances for LSPAny 2026-05-13 16:19:42 +05:30
Rintaro Ishizaki 223a88cb8c Add workspace/symbolNames and workspace/symbolInfo LSP extensions (#2619)
- **`sourcekit/workspace/symbolNames`** — returns a flat, deduplicated
list of every symbol name in the workspace index (source and indexed
system modules). Clients use this to drive their search UI locally.

- **`sourcekit/workspace/symbolInfo`** — given a list of exact symbol
names, returns `WorkspaceSymbolItem` for each occurrence across all
workspaces, for display in the search result list. Source-file symbols
get `SymbolInformation` with a `file://` location. SDK/stdlib symbols
get a `WorkspaceSymbol` with `location: .uri(…)` The client must call
`workspaceSymbol/resolve` after the user selects an SDK/stdlib symbol to
obtain the concrete interface location.

- **`workspaceSymbol/resolve`** — resolves the deferred
`WorkspaceSymbol` location from `sourcekit/workspace/symbolInfo`. Parses
the `?module=` value into `moduleName`/`groupName`, finds a real source
file via `mainFiles(containing:)`, calls `openGeneratedInterface`, and
returns the symbol with `location` replaced by a full
`sourcekit-lsp://generated-swift-interface/` URI + range (or a temp
`file://` path for clients without `workspace/getReferenceDocument`
support).
2026-05-12 22:21:17 -07:00
Alex Hoppen 0dbad3f7fe Merge pull request #2642 from 25harsh/code-actions-to-module
[SwiftSyntaxCodeActions] Moved syntactic code actions into a new module
2026-05-12 15:49:34 +02:00
G.M_YOO a6a9c4412e Add test coverage for ReferencesContext.includeDeclaration
Revert the earlier behavior change and add regression test coverage for both modes of `includeDeclaration`. sourcekit-lsp already handles this per the LSP spec.

These tests pin the behavior so it cannot regress.

Related to #2638
2026-05-12 21:20:36 +09:00
G.M_YOO f874cc73d3 Exclude the symbol's own definition from the references response
References should return use sites, not the definition itself.
The textDocument/references request was including the symbol's own definition, adding noise when navigating from a definition.

This change removes .definition from the roles set when includeDeclaration is true. The existing testReferencesInMacro test was also updated to apply the same principle consistently across the macro case.

Fixes #2638
2026-05-12 20:08:03 +09:00
Rintaro Ishizaki 16322f9efd Merge pull request #2641 from rintaro/contributor-doc-swift-operations
Add links to contributing guides in CONTRIBUTING.md
swift-DEVELOPMENT-SNAPSHOT-2026-05-12-a
2026-05-11 14:32:13 -07:00
Rintaro Ishizaki 127492d655 Merge pull request #2640 from rintaro/copied-file-map-missing-adjustment
Fix and simplify CopiedFileMap adjustments
2026-05-11 09:32:57 -07:00
25harsh f185bc404f [SwiftSyntaxCodeActions] Moved syntactic code actions into a new module 2026-05-11 11:10:40 +05:30
Rintaro Ishizaki 549eaf6292 Add links to contributing guides in CONTRIBUTING.md 2026-05-10 18:06:11 -07:00
Rintaro Ishizaki e638498119 Merge pull request #2580 from Steffeeen/local-sourcekit-build-docs
[ContributorDoc] Add detailed docs for using a local build of SourceKit
2026-05-10 17:59:30 -07:00
Rintaro Ishizaki eab4f58f32 Simplify adjusted(for:) implementations in LSP+CopiedFileMap
The range is never changed by URI adjustment, so there's no need to
construct intermediate Location values just to extract the URI.
2026-05-10 17:12:15 -07:00
Rintaro Ishizaki 2d320b288c Fix missing CopiedFileMap adjustments for WorkspaceEdit and TypeHierarchyItem
- WorkspaceEdit.adjusted(for:) was using originalURI(for:) ?? uri, which
  skips the file-existence check; switch to adjustedURI(for:)
- TypeHierarchyItem.adjusted(for:) was not adjusting the URI stored in
  data, unlike CallHierarchyItem
2026-05-10 17:12:12 -07:00
Rintaro Ishizaki 01b793dab4 Merge pull request #2637 from rintaro/lsp-messsage-metadata-structs
Replace manual LSPAny data handling with typed structs
2026-05-10 11:22:35 -07:00
Steffeeen 7d6594af49 [ContributorDoc] Add detailed docs for using a local build of SourceKit 2026-05-10 16:40:40 +02:00
Steffeeen 7166514240 Add SOURCEKIT_LSP_RUN_SOURCEKITD_IN_PROCESS environment variable
This environment variable can be used to force SourceKit-LSP to run
SourceKitD in-process on macOS. This can be useful for debugging.
2026-05-10 16:40:40 +02:00
Rintaro Ishizaki 2773bcdfa2 Merge pull request #2633 from rintaro/sourcekitd-inject
Allow injection of a pre-initialized sourcekitd connection
2026-05-07 19:57:41 -07:00
Rintaro Ishizaki 83afc9d1e1 Move CopiedFileMap LSP adjustments to extensions on LSP types
`CopiedFileMap` previously held methods like
`workspaceEditAdjustedForCopiedFiles`,
`callHierarchyItemAdjustedForCopiedFiles`, etc. that encoded knowledge
of high-level LSP message types into `BuildServerIntegration`.

Replace them with `adjusted(for:)` methods on each LSP type
(`Location`, `[Location]`, `LocationsOrLocationLinksResponse`,
`WorkspaceEdit`, `CallHierarchyItem`, `TypeHierarchyItem`) in a new
`LSP+CopiedFileMap.swift` in the SourceKitLSP module. The primitive
URI remapping is extracted into `CopiedFileMap.adjustedURI(for:)`
which remains in `BuildServerIntegration`.

`CallHierarchyItem.adjusted(for:)` also drops manual `LSPAny`
dictionary construction in favour of `HierarchyItemData`.
2026-05-07 16:10:02 -07:00
Rintaro Ishizaki 070bc52b8c Use typed structs for LSP item data fields instead of manual LSPAny 2026-05-07 15:25:18 -07:00
Rintaro Ishizaki 6be68bbf5b Merge pull request #2636 from jakepetroules/patch-1
Update minimum macOS version to v15
2026-05-07 15:01:28 -07:00