- Add DefinitionLocations.swift to CMakeLists.txt
- Add proper documentation comments to functions in DefinitionLocations.swift
- Make indexToLSPLocation private since it's only used within the file
- Revert unrelated comment changes in InlayHintResolve.swift
- Use .only instead of .first in InlayHintResolve to avoid ambiguous types
- Refactor TypeDefinition.swift to use cleaner control flow with guard/else
- Add test for jumping to generated interface (String)
- Use cursorInfo USR lookup instead of index (more accurate)
- Add document version tracking to reject stale resolve requests
- Make InlayHintResolveData conform to LSPAnyCodable
- Reference swiftlang/swift#86432 for mangled type workaround
- cursorInfoFromTypeUSR takes DocumentSnapshot for version safety
- Remove TypeDefinition.swift (defer to follow-up PR)
- Remove unnecessary comments
- Tests work without index
Add support for the textDocument/typeDefinition LSP request, which
finds the type of the symbol at a given position and returns the
location of that type's definition.
This uses the same type definition lookup mechanism as the inlay hint
resolution feature, which queries cursorInfo for the new type
declaration location fields (typeDeclFilePath/Line/Column) with
fallback to index lookup using typeDeclUsr.
Fixes#548
Implements resolveProvider for inlay hints to enable navigating to type
definitions. When an inlay hint showing a type is resolved, the server
looks up the type's definition location using cursorInfo and the index.
- store variable position in InlayHint.data for resolution
- add inlayHintResolve to LanguageService protocol
- implement resolve handler using cursorInfo and index lookup
- enable resolveProvider: true in capabilities
- add test for resolve functionality
Addresses #2318
Shut down language services when a workspace is closed
- Added allLanguageServices property to Workspace to get all services it references
- Added shutdownOrphanedLanguageServices to clean up services no longer in use
- When workspace folders are removed, we now shut down their associated language services
- This properly terminates clangd and other language server processes when workspaces close
Closes#2209
- Only call `setLanguageServices` from `openDocument` to avoid race conditions
- Remove language services when documents are closed via `removeLanguageServices`
- `SourceKitLSPServer.languageServices` now just returns services without storing them
- Fixed a small typo (serveer -> server) while I was in there
This way the languageServices dictionary only tracks documents that are actually open,
and we avoid race conditions since openDocument is a blocking request for that document.
Currently, `indexBasedDefinition` relies heavily on IndexStoreDB. If a symbol
belongs to a binary framework or a library that hasn't been indexed (but has
module info provided by sourcekitd), the definition request fails or returns
empty results.
This change adds a fallback mechanism in `definitionLocations`. When no
occurrences are found in the index, we check if `systemModule` information
is available on the symbol. If so, we trigger `definitionInInterface` to
generate the textual interface (via `editor.open.interface`) and return that
location.
This improves navigation for binary dependencies (XCFrameworks) and SDKs
partially covered by the index.
- Refactor supertypes/subtypes to use indexToLSPTypeHierarchyItem helper
instead of duplicating ~80 lines of TypeHierarchyItem creation code
- Remove unused workaround helper functions (indexToLSPLocation2,
indexToLSPTypeHierarchyItem2)
- Fix test ordering: use deterministic sorted order instead of Set comparison
- Enable testFindImplementationInCopiedHeader test
- Add implementation request support for C/C++/ObjC functions with
separate declaration and definition (finds definition when declarations
exist without definitions at the same location)
- Fix whitespace/indentation issues
- Remove async from workspaceEditAdjustedForCopiedFiles
- Refactor to use uriAdjustedForCopiedFiles helper
- Update dictionary update logic with +=
- Adjust LocationLink creation to use adjusted ranges
- Ensure selectionRange adjustment in prepareCallHierarchy
- Provide default WorkspaceEdit in ClangLanguageService
- Revert asyncMap to map and remove await in SourceKitLSPServer
- Chain workspace and index retrieval in incomingCalls
- Use indexToLSPCallHierarchyItem and shared helper for CallHierarchyItem
- Fix indentation and remove duplicated detail setting
- Use shared helper for TypeHierarchyItem
- Remove .sort() from expected array in tests
- Enable testFindImplementationInCopiedHeader
- Add await for actor-isolated BuildServerManager calls
This addresses issue #2276 by ensuring that all LSP requests that return source file locations
map copied header files back to their original locations, not just jump-to-definition.
Previously, only the definition request applied this mapping. Now, the following requests
also adjust locations for copied files:
- textDocument/references
- textDocument/implementation
- workspace/symbol
- callHierarchy/prepare
- callHierarchy/incomingCalls
- callHierarchy/outgoingCalls
- typeHierarchy/prepare
- typeHierarchy/supertypes
- typeHierarchy/subtypes
This provides consistent navigation behavior, ensuring users are always taken to the original
source files instead of build artifacts when possible.
Apply the following changes:
- Check for the presence of `#Playgrounds` textually before getting the module name in `SwiftPlaygroundsScanner`. This is important because getting the module name requires us to get build settings for the file, which can be expensive. Do the cheaper check first
- Make `syntacticTests` and `syntacticPlaygrounds` closures capture the workspace instead of passing the workspace from the `SwiftSyntacticIndex` back out. I like this better because now we can’t accidentally pass the wrong workspace to a `SwiftSyntacticIndex`, eg. to `buildTargetsChanges`.
- Capture the initialize result in `TestSourceKitLSPClient` instead of using `postInitialization` to capture the result
- Minor cleanup of unnecessary abstractions, likely artifacts of earlier iterations
- Restructure tests so that every test has its own list of source files, allowing for easier local reasoning – turns out some of these tests didn’t even need to open a workspace, just to check the initialize response