Commit Graph

230 Commits

Author SHA1 Message Date
Alex Hoppen
b2b66ca3c1 Support rename of functions across class hiearchies and protocols
rdar://123536502
2024-03-02 11:10:52 -08:00
Alex Hoppen
6f94d86305 Merge pull request #1103 from ahoppen/ahoppen/call-hierarchy-look-through-protocols
Show calls to satisfied protocol requirements in call hierarchy
2024-03-02 07:29:38 -08:00
Alex Hoppen
8fa839ca73 Show calls to satisfied protocol requirements in call hierarchy
For example in the following, we should show `proto.foo()` as a call when computing the call hierarchy of `MyStruct.foo`. Otherwise `MyStruct.foo` does not have any calls, which is misleading.

```swift
protocol MyProtocol {
  func foo()
}
struct MyStruct: MyProtocol {
  func foo() {}
}
func test(proto: MyProtocol) {
  proto.foo()
}
```

rdar://123837232
2024-03-01 15:42:38 -08:00
Alex Hoppen
cca217741a De-duplicate results from find references
We might have duplicate results for multiple references inside a macro. In this case we only want to show the macro attribute or macro expansion expr/decl once.

Fixes #1047
rdar://122237704
2024-03-01 15:32:20 -08:00
Alex Hoppen
d64a4ab136 Merge pull request #1095 from ahoppen/ahoppen/sort-index-results
Sort results returned by the index
2024-03-01 02:21:33 -08:00
Alex Hoppen
4dea06108a Merge pull request #1104 from ahoppen/ahoppen/file-handling-capability-logging
Add some logging for `testRecomputeFileWorkspaceMembershipOnPackageSwiftChange`
2024-02-29 16:15:06 -08:00
Alex Hoppen
0b2ca89903 Ensure we handle multiple results returned by the index correctly
This replaces all uses of `.first` on index results in `SourceKitServer` by code that explicitly handles multiple results.
2024-02-29 16:14:10 -08:00
Alex Hoppen
fef3cb8f64 Sort results returned by the index
rdar://123487052
2024-02-29 13:07:28 -08:00
Alex Hoppen
c6953d1554 Merge pull request #1087 from ahoppen/ahoppen/call-hierarchy
In call hierarchy look through variable accessors and show surrounding function call
2024-02-29 09:46:55 -08:00
Alex Hoppen
fd12d9df4c Add some logging for testRecomputeFileWorkspaceMembershipOnPackageSwiftChange
I just saw a failure of this test in CI, and can’t figure out what might have happened. Adding some logging that hopefully helps us if the failure happens again.
2024-02-29 09:38:49 -08:00
Alex Hoppen
7d6555c108 Merge pull request #1081 from ahoppen/ahoppen/implicit-workspace
Provide semantic functionality for packages that are subdirectories of a workspace folder
2024-02-28 12:03:23 -08:00
Alex Hoppen
dec57f9ec0 Merge pull request #1085 from ahoppen/ahoppen/capability-registry
Simplify `CapabilityRegistry`
2024-02-28 09:42:46 -08:00
Alex Hoppen
aff620481f In call hierarchy look through variable accessors and show surrounding function call
Fix two bugs in call hierarchy:
1. In the following, we used to show `myVar` as the caller of `foo`. That was a dead end and didn’t allow any further exploration
```swift
func foo() {}
func testFunc(x: String) {
  let myVar = foo()
}
```
2. Handle variables and their accessors in call hierarchy

rdar://123526105
2024-02-28 09:38:00 -08:00
Alex Hoppen
d76e9059bf Provide semantic functionality for packages that are subdirectories of a workspace folder
rdar://119740711
2024-02-28 09:20:30 -08:00
Alex Hoppen
755868a330 Merge pull request #1074 from ahoppen/ahoppen/dont-report-definition-and-declaration
Only report a single item in prepareCallHierarchy
2024-02-24 22:10:27 -08:00
Alex Hoppen
0ce6802025 Simplify CapabilityRegistry
Improve `CapabilityRegistry` and surrounding code in a couple of ways
- Make `CapabilityRegistry` an actor
- Refactor `CapabilityRegistry` to duplicate less code
- Ensure that `SourceKitServer` reports all capabilities of `SwiftLanguageServer` if the client doesn’t support dynamic capability registration. We were missing this for semantic tokens and inlay hits
- Add a few doc comments
2024-02-23 21:47:59 -08:00
Alex Hoppen
82936eb70a Fix typos in SourceKitServer.swift 2024-02-22 20:42:16 -08:00
Alex Hoppen
ff2b27acd0 Only report a single item in prepareCallHierarchy
Returning multiple doesn't make sense because they will all have the same USR (because we query them by USR) and will thus expand to the exact same call hierarchy.

Also, VS Code doesn't seem to like multiple call hiearchy items being returned and fails to display any results if they are, failing with `Cannot read properties of undefined (reading 'map')`.

rdar://118957893
2024-02-22 20:42:05 -08:00
Alex Hoppen
61dde3ff52 De-dupe locations returned from the defintions request
We might end up with duplicate locations when performing a definition request on eg. `MyStruct()` when no explicit initializer is declared. In this case we get two symbol infos, one for the declaration of the `MyStruct` type and one for the initializer, which is implicit and thus has the location of  the `MyStruct` declaration itself.

rdar://123036565
Fixes #1055
2024-02-21 19:42:13 -08:00
Alex Hoppen
a912da4158 Fix issue that caused the Reloading Package progress indicator to be stuck
If any method in `reloadPacakge` threw, the `Reloading Package` progress indicator was stuck.

Also, change the message of the indicator to `SourceKit-LSP: Reloading Package` to make it easier to differentiate from status generated by the VS Code extension.

Fixes #1050
rdar://122899093
2024-02-19 15:56:01 -08:00
Alex Hoppen
9335e1891a Log when a notification gets sent to the LSP client 2024-02-18 20:04:06 -08:00
Alex Hoppen
3b68a5394e Allow forwarding of the indexedRename request to clangd
The main purpose of this is so we can invoke it from `SkipUnless` to see if `clangd` supports the `workspace/indexedRename` request.
2024-02-14 12:52:05 -08:00
Alex Hoppen
c340e636ef Fix an issue that caused a precondition to be hit when an unknown request was sent to sourcekit-lsp
When sending an unknonw request to sourcekit-lsp, we directly called back `reply` and never set `replied` to `true` on the `RequestAndReply` object. This caused a preconditon to be hit when the `RequestAndReply` object got destroyed.
2024-02-14 12:50:35 -08:00
Alex Hoppen
d73f44c447 Support cross-language rename between Swift and clang languages
This adds support for name translation between Swift anc clang languages to allow renaming across those language boundaries.

Rename is always initiated at the symbol’s definition, so when renaming an Objective-C symbol from Swift, the user is prompeted to enter the new Objective-C method name.

rdar://118996461
2024-01-31 10:51:03 -08:00
Alex Hoppen
79cc4f9ae8 Support formatting of entire documents
Depend on the swift-format library to discover and write the swift-format configuration file. Invoke swift-format from the toolchain to actually format a document. This makes sure that the formatting of SourceKit-LSP and the swift-format executable in the toolchain never get out of sync.

Fixes #576
rdar://96159694
2024-01-23 22:31:52 -08:00
Alex Hoppen
1e72500f1a Merge pull request #1017 from ahoppen/ahoppen/secondary-cursor-info-results
Report secondary cursor info results
2024-01-11 09:30:10 -08:00
Alex Hoppen
7572fb96ee Report secondary cursor info results
rdar://119163908
2024-01-10 21:05:31 -08:00
Alex Hoppen
6f342e2b82 Remove static shared toolchain registry
Global state is never a good thing and we needed to modify it in tests. The design becomes a lot cleaner if we explicitly pass the toolchain registry around.
2024-01-09 17:17:31 -08:00
Alex Hoppen
3e73f11de0 Migrate ToolchainRegistry to be an actor 2024-01-09 17:17:31 -08:00
Alex Hoppen
527600e977 Support the prepare rename request
This allows us to return the current compound decl name when renaming a function, which will get populated as the default value for the text field in which the user enters the new symbol name.

rdar://118995649
2023-12-20 09:43:26 -08:00
Alex Hoppen
b381811710 Merge pull request #1000 from ahoppen/ahoppen/wrap-logging-category 2023-12-18 18:04:12 -08:00
Alex Hoppen
c36a854e7a Wrap request and notification ID for the purpose of logging scopes
OSLog only allows the creation of 4000 logger objects, which means that logging will crash on the 4000th request to sourcekit-lsp (which would create the 4000th os_log object because it is the 4000th distinct category in which we are logging).

To circumvent this problem, only use the last two digits of the request and notification ID for the logging scope and wrap around afterwards. This should still allow us to tell apart log messages from concurrently handled requests/notifications while only using 200 os_log objects, which means we stay well clear of the 4000 limit.

rdar://119221355
2023-12-14 08:22:36 -08:00
Alex Hoppen
e08f0a906a Set the renameProvider capability 2023-12-13 14:37:35 -08:00
Alex Hoppen
997ef38916 Support rename across Swift files
rdar://118995700
2023-12-12 17:34:34 -08:00
Alex Hoppen
d931806c69 Merge pull request #988 from z2oh/configure-workspace-type
Allow configuring workspace type via flag
2023-12-12 10:50:52 -08:00
Alex Hoppen
ce9fdf9258 Merge pull request #990 from ahoppen/ahoppen/rename
Implement local rename within the current file
2023-12-11 19:39:35 -08:00
Alex Hoppen
777f1dc463 Add support for rename within the current file
rdar://117822427
2023-12-09 08:35:13 -08:00
Jeremy Day
c006421667 Switch to more descriptive case names 2023-12-08 15:23:03 -08:00
Jeremy Day
3278ff0612 Enable per-workspace configuration of default workspace type 2023-12-08 11:06:11 -08:00
Alex Hoppen
96905aaf16 Add a request to get all tests within a file 2023-12-06 17:40:21 -08:00
Alex Hoppen
446f9280da Add a request to list all the tests within the current workspace
Fixes #611
rdar://98710526
2023-12-06 17:40:21 -08:00
Alex Hoppen
4077ce360d Don’t use the best local declaration when jumping to definition of a C function
For non-Swift symbols, we need to perform an index lookup because the best local declaration will point to a header file but jump-to-definition should prefer the implementation (there's the declaration request to jump to the function's declaration).

rdar://119243893
2023-12-06 11:08:44 -08:00
Jeremy Day
cafc63ea98 Add --workspace-type flag 2023-12-06 10:29:19 -08:00
Alex Hoppen
ed410e6503 Merge pull request #977 from ahoppen/ahoppen/jump-to-override
Show overriden functions when performing jump-to-definition on a dynamic call
2023-12-05 16:18:46 -08:00
Alex Hoppen
c7bd8c9e8f Consider all symbol replies from clangd dynamic 2023-12-04 18:49:36 -08:00
Alex Hoppen
84fdea9e05 Filter overrides in DefinitionRequest by receiver types 2023-11-29 09:03:36 -08:00
Alex Hoppen
1ffa825b3f Remove extractIndexedOccurences
`extractIndexedOccurences` mostly dealt with how to create a fallback value and we didn’t support fallback values in 3/4 cases. Remove it, simplifying the callers of `extractIndexedOccurances` along the way.
2023-11-29 09:02:19 -08:00
Alex Hoppen
4052465905 Show overriden functions when performing jump-to-definition on a dynamic call
Fixes #809
rdar://114864256
2023-11-29 09:02:02 -08:00
Alex Hoppen
33f4612243 Add support for different arguments per workspace
Fixes #663
rdar://101815704
2023-11-28 11:19:09 -08:00
Alex Hoppen
ac3eb32e65 Format sources with swift-format 2023-10-31 19:30:31 -07:00