Commit Graph

78 Commits

Author SHA1 Message Date
Alex Hoppen
7604a1d389 Show a progress indicator in the editor if SourceKit-LSP is reloading packages
I noticed that the initial package loading can take ~5s. It’s good behavior to inform the client that sourcekit-lsp is busy reloading the package, showing the user that semantic functionality might not be ready yet.

https://github.com/apple/sourcekit-lsp/issues/620
rdar://112498447
2023-08-03 18:25:47 -07:00
Ben Barham
e540e169bc Revert "Show a progress indicator in the editor if SourceKit-LSP is reloading packages" 2023-07-17 21:56:35 -07:00
Alex Hoppen
24317f1e97 Show a progress indicator in the editor if SourceKit-LSP is reloading packages
I noticed that the initial package loading can take ~5s. It’s good behavior to inform the client that sourcekit-lsp is busy reloading the package, showing the user that semantic functionality might not be ready yet.

https://github.com/apple/sourcekit-lsp/issues/620
rdar://111917300
2023-07-17 11:08:20 -07:00
Tristan Labelle
e91c83fd72 Remove reporting diagnostic support at SourceKitServer initialization 2023-05-31 10:30:54 -04:00
Tristan Labelle
0da6291d22 Use CapabilityRegistry in ToolchainLanguageServer implementations 2023-05-26 10:35:26 -04:00
Tristan Labelle
bc444519c8 Report diagnostics support in SourceKitServer. 2023-05-26 10:35:26 -04:00
Adam Fowler
07b9cc21e4 Requested changes from PR
rename symbol to symbolUSR
Cleanup OpenInterfaceRequest.init
2023-05-22 22:37:45 +01:00
Adam Fowler
0da1d40a28 Move module name split into OpenInterfaceRequest
Use group names when running open interface request
2023-05-21 10:26:00 +01:00
Adam Fowler
45adabb3e5 Extend OpenInterface to also seatch for a symbol 2023-05-16 19:32:29 +01:00
Adam Fowler
cf702e2269 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.
2023-05-16 19:32:15 +01:00
Tristan Labelle
1077ea39a7 Add boilerplate for pull-model diagnostics 2023-05-03 11:25:28 -04: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
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
Bart Whiteley
d2f7f2f3c6 Generate textual Swift interfaces for module references 2022-12-12 12:45:21 -07: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
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
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
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
Alex Hoppen
97ccf1da0c Cache which workspace a document with a given URI should be opened in
Determining which workspace a document belongs to is potentially non-trivial (although it shouldn’t be too expensive either). But since it’s executed for every request, cache it.
2022-05-04 14:48:31 +02:00
Alex Hoppen
c04b2efbe3 Add capability to open multiple workspaces during the initialize request 2022-05-04 14:48:31 +02:00
Alex Hoppen
d02d3914c5 Query build system of workspaces to determine best workspace to open a file in
This sets the stage for multi-workspace support. Everything should be handled internally, we are just missing the API to actually open multiple workspaces at this point.
2022-05-04 14:48:31 +02:00
Alex Hoppen
2f1930c8a3 Make each toolchain language server keep track which workspaces it can open documents for
This will allow us to start multiple `clangd` instances for each workspaces root once we start supporting multiple workspace roots.
2022-05-04 14:48:31 +02:00
Alex Hoppen
daf60b1c04 Prepare SourceKitServer for multiple workspaces
This makes SourceKitServer keep track of multiple workspaces and their handling. It does not include the functionality to determine which workspace a file belongs to.
2022-05-04 14:48:31 +02:00
Alex Hoppen
d917e40410 Prepare SourceKitServer for multiple workspaces
This makes SourceKitServer keep track of multiple workspaces and their handling. It does not include the functionality to determine which workspace a file belongs to.
2022-05-04 14:48:31 +02:00
Alex Hoppen
a4118a57bb Make SourceKitServer own the DocumentManager
When we introduce multiple workspaces, they need to share the same DocumentManager so we don’t accidentally open a Swift file twice in two workspaces that share the same `SwiftLanguageService`. Thus, `SourceKitServer` needs to start owning the document manager.
2022-05-04 14:48:31 +02:00
Alex Hoppen
5deb742969 Remove regiseterWorkspaceNotification/Request methods
When we support multiple workspaces on one SourceKit-LSP instance, there won’t be a unique workspace anymore. Each request handler should determine the workspace it wants to use on its own.
2022-05-04 14:48:31 +02:00
Alex Hoppen
b2f4fe0e29 Refactor the way toolchain language servers are created
Mostly cleanup
2022-05-04 14:48:31 +02:00
Ben Langmuir
3927e639be Revert "Support opening multiple workspaces in a single sourcekit-lsp instance" 2022-05-03 13:47:19 -07:00
Alex Hoppen
798803021e Listen to DidChangeWorkspaceFolders notification 2022-05-02 09:31:07 +02:00
Alex Hoppen
09f52e9122 Cache which workspace a document with a given URI should be opened in
Determining which workspace a document belongs to is potentially non-trivial (although it shouldn’t be too expensive either). But since it’s executed for every request, cache it.
2022-05-02 09:31:07 +02:00
Alex Hoppen
28e6888662 Add capability to open multiple workspaces during the initialize request 2022-05-02 09:31:07 +02:00
Alex Hoppen
f91564a75f Query build system of workspaces to determine best workspace to open a file in
This sets the stage for multi-workspace support. Everything should be handled internally, we are just missing the API to actually open multiple workspaces at this point.
2022-05-02 09:31:07 +02:00
Alex Hoppen
437275e44a Make each toolchain language server keep track which workspaces it can open documents for
This will allow us to start multiple `clangd` instances for each workspaces root once we start supporting multiple workspace roots.
2022-04-29 14:33:01 +02:00
Alex Hoppen
8b9d6860b1 Prepare SourceKitServer for multiple workspaces
This makes SourceKitServer keep track of multiple workspaces and their handling. It does not include the functionality to determine which workspace a file belongs to.
2022-04-29 14:33:01 +02:00