Commit Graph

152 Commits

Author SHA1 Message Date
Alex Hoppen
135e8f935b Register diagnostics in currentDiagnostics when performing a diagnostic pull request
We were registering new diagnsotics in `currentDiagnostics` when the diagnostics got pushed to us by sourcekitd, but not when they were pulled using the diagnostic request.

Fixes #776
rdar://112539108
2023-07-21 08:05:42 -07:00
Tristan Labelle
2f0209f69b Fix bad merge resulting in duplicated method 2023-06-12 10:49:10 -04:00
Tristan Labelle
c076bd5282 Implement pull-model documentDiagnostics 2023-06-02 13:36:07 -04:00
Tristan Labelle
ea9f173339 Add boilerplate for pull-model diagnostics 2023-06-02 13:35:00 -04:00
Adam Fowler
9ca89669b2 Swiftinterface symbol lookup
Generate swiftinterface for symbol lookup

When a symbol definition returns it is in a swiftinterface file, create textual version of swiftinterface and return that in response.

Extend OpenInterface to also seatch for a symbol

Fix warning

Syntax changes after review

Move module name split into OpenInterfaceRequest

Use group names when running open interface request

Requested changes from PR

rename symbol to symbolUSR
Cleanup OpenInterfaceRequest.init

Fix tests

Added testDefinitionInSystemModuleInterface

Use SwiftPMPackage test module
Added version of buildAndIndex that includes system symbols

Merge buildAndIndexWithSystemSymbols with buildAndIndex

Added specific test project for system swiftinterface tests

Add multiple tests for various system modules
2023-05-24 18:53:37 +01:00
Alex Hoppen
6a79fe7e93 Rename IDEUtils to SwiftIDEUtils 2023-04-22 07:59:49 -07:00
Hamish Knight
fa74ac753c Update for SwiftSyntax regex changes 2023-04-03 11:58:08 +01:00
Max Desiatov
f5a30d9351 Fix uses of deprecated non-throwing AbsolutePath.init (#709)
These warnings appeared after an update to TSC deprecated this initializer.
2023-02-09 14:04:57 +00:00
Hamish Knight
9cb32f235f Update for SwiftSyntax if/switch expression work 2023-01-13 10:28:05 +00:00
Alex Hoppen
b7da2a6884 Ensure there are always newlines in a genrated markdown comment
Fixes #690
Fixes rdar://103911070
2023-01-11 11:17:52 +01:00
Saleem Abdulrasool
4bbd74f105 SourceKit: sever dependency on TSCUtility
The dependency on `TSCUtility` was strictly for identifying the platform
of execution. This logic is relatively self-contained and effectively an
extension over an enumeration. Replicate this logic with updates for new
syntactic improvements. This allows us to partially reduce dependency on
swift-tools-support-core. The dependency on TSCBasic is more complicated
to remove due to the extensive use of `AbsolutePath`.

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>
2023-01-02 12:30:28 -08:00
Ben Barham
f75d20f46b Merge pull request #680 from bnbarham/update-inlay-provider-registration
Update `inlayHintProvider` registration
2022-12-15 14:57:48 -08:00
Ben Barham
73af860ac2 Update inlayHintProvider registration
The LSP API allows a boolean here:
```
	/**
	 * The server provides inlay hints.
	 *
	 * @since 3.17.0
	 */
	inlayHintProvider?: boolean | InlayHintOptions
		 | InlayHintRegistrationOptions;
```

Update our server capabilities to allow this.

Resolves rdar://102913088.
2022-12-15 11:26:29 -08:00
Artem Chikin
05b03c124e Fix CMake build by adding missed new files to CMakeLists 2022-12-14 09:50:38 -08:00
Bart Whiteley
d2f7f2f3c6 Generate textual Swift interfaces for module references 2022-12-12 12:45:21 -07:00
Alex Hoppen
ca45a7a62b Return a .serverCancelled error code if the server cancels a request
`.cancelled` should only be returned if the client requested cancellation.
2022-12-05 08:45:36 +01:00
Alex Hoppen
975286d353 Update capability definitions to LSP 3.17 2022-12-04 19:56:51 +01:00
Alex Hoppen
93a8f91436 Update request and notification definitions to LSP 3.17 2022-12-01 10:44:40 +01:00
Saleem Abdulrasool
fb351c73d5 SourceKitLSP: add new dependency introduced in SwiftSyntax
Add a dependency on IDEUtils that is missing in the build.
2022-10-26 14:03:11 -07:00
Alex Hoppen
a7ae0edf6a Add dependency on IDEUtils
Reflect for the fact that SyntaxClassifier has moved to a new `IDEUtils` module.
2022-10-26 20:09:45 +02:00
Robert Widmann
4b9ab7f1bc Redo the Folding Range Request on top of the Syntax Tree
Building upon the infrastructure that requests the lexical structure of the document from SwiftSyntax, redo the folding ranges request using the tree directly. This corrects a number of inconsistencies in the tests mostly due to incorrect SourceLocations in the semantic ASTs and the line comment merging logic.
2022-10-19 23:37:11 -07:00
Robert Widmann
bba47a4d72 Update CMake Build to Include SwiftSyntax 2022-10-19 20:22:46 -07:00
Robert Widmann
fdae671359 Refactor DocumentTokens to Use the New Parser
Re-core the "lexical" token stream on top of SwiftSyntax and call into the parser to (re-)generate these "lexical tokens" when the document changes. Leave the semantic tokens alone since they take some non-zero amount of name lookup to fully resolve references to fully replicate.
2022-10-18 00:47:20 -07:00
Robert Widmann
0b89da4920 Implement textDocument/declaration
A declaration request is similar to a definition request, except that it is expected to return (potentially) many results across the workspace for a given reference. For example, an inline function or macro may have many declarations in the workspace, but only one "good" or canonical definition. For now, this is only implemented by forwarding the request on to clangd since I'm unfamiliar with a SourceKit query for this.

For languages like Swift that lack such a sharp declaration/definition split, we could potentially use this request to provide navigable metadata on linked definitions. For example, the declaration for a type reference would include all extensions of that type in the workspace.
2022-10-10 11:29:07 -07:00
Saleem Abdulrasool
44414c5f1f SourceKitLSP: use AbsolutePath to compute the filename
Rather than treating the filename as an opaque string and splitting on
`/`, use `AbsolutePath` to perform the `basename` operation on the path.
This ensures that we split the path properly on platforms which do not
use the POSIX path separator `/`.
2022-09-29 13:26:37 -07:00
Saleem Abdulrasool
7d1bcee1b0 explicitly import TSCBasic types
Explicitly import interfaces from TSCBasic which now allows us to
identify all the swift-tools-support-core interfaces which are in
use in SourceKit-LSP.
2022-09-10 12:53:30 -07:00
Saleem Abdulrasool
b668f992cb SourceKitLSP: normalise paths for clangd
Ensure that we use the native path representation for clangd rather than
the POSIX spelling.  This is required to map the command for the source
file.
2022-09-01 08:47:02 -07:00
Saleem Abdulrasool
169a257ad8 SourceKitD,SourceKitLSP: replace use of Lock with NSLock
Replace the use of the deprecated `Lock` from swift-tools-support-core
with `NSLock`.  The benefit of the deprecated interface was the
`withLock` function which is easily replicated and very unlikely to
change.  By doing so we avoid the warnings about `Lock` being deprecated
when building SourceKit-LSP.
2022-08-23 11:38:50 -07:00
Saleem Abdulrasool
d4b56e334a LSP: always use FSR for URI
When converting the URI to a path string, ensure that we convert to the
file system representation.  This is important as this ensures that we
are always passing SourceKit the native path string.  With this change,
the code completion behaviour for the LSP test suite on Windows is
repaired.
2022-08-19 08:04:12 -07:00
Alex Hoppen
0d83557f87 Provide semantic highlighting for operators in declarations
Adopts https://github.com/apple/swift/pull/60210

Resolves #595
rdar://97961816
2022-08-12 14:21:57 +02:00
Ian Hanken
e36eb50b41 Empty TextEdits now return nil
This adds a check when creating a `TextEdit` to return `nil` if both the fixit and the replacement being used to create a `TextEdit` are empty. A `TextEdit` being created like this can cause a crash.
2022-08-02 10:09:28 -07:00
Alex Hoppen
711c22544f Pass manual build arguments that specified using -Xswiftc when starting sourcekit-lsp, to the fallback build system
Previously, we weren’t respecting these arguments in the fallback build system.

rdar://97044457
2022-07-20 00:51:27 +02:00
Saleem Abdulrasool
586218448a SourceKitLSP: change an assert to a check
Rather than asserting, raise an error for the user and abort the
operation.  This is motivated by the desire to get the test suite mostly
working on Windows so that the underlying issues can be worked through
more easily.
2022-07-12 12:47:59 -07:00
fwcd
9cdd025fc4 Include module names in call hierarchy items 2022-07-11 14:18:02 +02:00
fwcd
4ec6a49a8f Resolve retroactive conformances in supertype hierarchy 2022-07-08 17:43:19 +02:00
fwcd
7dd90ab40a Improve multi-protocol extension formatting in type hierarchy 2022-07-08 04:58:43 +02:00
fwcd
25f4bd6ea3 Implement type hierarchy
- Add typeHierarchyProvider
- Implement prepareTypeHierarchy request
- Add supertype and subtype request handlers
- Implement supertypes and subtypes request
- Display location and conformance of extensions in type hierarchy
- Include extensions in the type hierarchy
- Include module names in type hierarchy
2022-07-06 05:05:25 +02:00
fwcd
3e90b82755 Use if-let for local symbol occurrence fallback
Co-authored-by: Alex Hoppen <alex@alexhoppen.de>
2022-07-04 23:32:54 +02:00
fwcd
411dae172c Implement call hierarchy
- Add prepareCallHierarchy handler
- Register callHierarchyProvider capability
- Use proper symbol kind in prepareCallHierarchy
- Stub out implementation of outgoingCalls
- Encode usr and uri in indexToLSPCallHierarchyItem
- Extract call hierarchy item data parser
- Implement incomingCalls
- Add Call Hierarchy to the list of supported features
- Resolve caller/callee definition locations for call hierarchy
2022-07-02 05:24:13 +02:00
fwcd
51f10e29f4 Factor out indexToLSPLocation 2022-06-30 20:04:32 +02:00
fwcd
33d9e4bcea Return SymbolOccurrence info in extractIndexedOccurrences 2022-06-30 19:50:30 +02:00
fwcd
143abb9a86 Add doc comment to extractIndexedOccurrences 2022-06-30 03:32:10 +02:00
fwcd
146531ca7b Clean up index lookup requests
- Add missing useLocalFallback
- Address PR suggestions regarding index request handlers
2022-06-29 15:30:20 +02:00
Alex Hoppen
44990b6e6b Merge pull request #465 from fwcd/upstream-inlay-hints
Migrate to upstream LSP inlay hints request
2022-06-14 15:10:13 +02:00
David Goldman
472a06c88a Support index store path remappings (#562)
This allows sourcekit-lsp to make use of the path remappings recently added to
the index store and IndexStoreDB to remap remote paths into local paths
when loading index data locally.

These remappings can be provided via the `-index-prefix-map` command line flag to sourcekit-lsp or via the `BuildSystem` integration point.
2022-06-09 10:45:52 -04:00
Alex Hoppen
1ad7e30416 Close temporarily opened documents
We only open a document e.g. with the `FoldingRanges:` prefix to get the document structure as a one-off task, so we should be closing it afterwards.

Fixes #553 (rdar://93154201)
2022-06-07 18:03:00 +02:00
Alex Hoppen
79b07fd6bf When receiving a didChangeWorkspaceFolders notificaiton, reopen documents that moved to a different workspace
A didChangeWorkspaceFolders notification might cause documents that are already open to now be considered part of a different workspace. To reflect this, close documents whose workspace has changed in the old workspace and re-open them in the new workspace.

rdar://94026341 [#557]
2022-05-31 23:00:20 +02:00
fwcd
818c44d990 Migrate to upstream LSP inlay hints
- Use official textDocument/inlayHint request
- Rename InlayHintCategory to InlayHintKind
- Additionally, represent it using an Int, as in the proposed LSP API.
- Add inlay hint client capabilities
- Add inlay hint server capabilities
- Add dynamic registration of inlay hint request
- Rename InlayHintsRequest -> InlayHintRequest
  This is to be consistent with the request itself being named in singular
  in LSP and the other requests (e.g. DocumentSymbolRequest).
- Forward inlay hint requests to clangd
- Add colon before inlay hints
- Add other properties to InlayHint
- Add InlayHintLabel structures
- Conform InlayHintLabel to ExpressibleByStringX protocols
- Attach TextEdit to inlay hints for committing them
- Add InlayHint.data
- Fix InlayHintTests
  We need to include text edits in the expected inlay hints.
2022-05-24 16:50:17 +02:00
Alex Hoppen
0942e74f89 Keep track of existing language servers separately by language server type
Otherwise we can run into situations where a Swift toolchain language server is asked to handle C files.

rdar://92690379
2022-05-04 14:48:31 +02:00
Alex Hoppen
cfdb2f8bad Listen to DidChangeWorkspaceFolders notification 2022-05-04 14:48:31 +02:00