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
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
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.
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
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
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
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
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
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.
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
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
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.
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
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
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
`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.