20 Commits

Author SHA1 Message Date
Dylan Sturgeon
ce55a854b9 Emit references to shadowed variables in if-let shorthands as variables when indexing locals is enabled.
Track the original-decl/captured decl as part of the symbol passed to the IndexConsumer. This allows the Rename consumer to check if the symbol is a shadowed reference to a decl being renamed, without the index skipping the other relevant output when visiting shadowing variables.

https://github.com/swiftlang/swift/issues/76805
2024-10-22 16:43:24 -07:00
Tim Kientzle
1d961ba22d Add #include "swift/Basic/Assertions.h" to a lot of source files
Although I don't plan to bring over new assertions wholesale
into the current qualification branch, it's entirely possible
that various minor changes in main will use the new assertions;
having this basic support in the release branch will simplify that.
(This is why I'm adding the includes as a separate pass from
rewriting the individual assertions)
2024-06-05 19:37:30 -07:00
Alex Hoppen
1a67c61d19 [RelatedIdents] Fix an assertion failure if two invalid declarations have the same base name
For example, the following declarations have the same USR with a single ERROR_TYPE parameter despite being distinct declarations.

```swift
func bar(body: Invalid) {}
func bar(ignoreCase: Bool, body: Invalid) {}
```

We originally intended to check the USR so that local rename behaves more like global rename, which also looks symbols up by USR. But the above example proves that assumption wrong.

rdar://126803702
2024-05-07 18:17:11 -07:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Hamish Knight
3f4b45b012 [AST] Remove SerializedLocalDeclContext
It's not clear that its worth keeping this as a
base class for SerializedAbstractClosure and
SerializedTopLevelCodeDecl, most clients are
interested in the concrete kinds, not only whether
the context is serialized.
2024-01-18 12:03:52 +00:00
Alex Hoppen
a5530ce9b6 [SourceKit] Factor out some more bridging code to run the NameMatcher from swift-syntax 2023-12-12 12:58:15 -08:00
Alex Hoppen
32e366a98a [SourceKit] Migrate renameAvailabilityInfo to use the SwiftSyntax NameMatcher
The `NameMatcher` implemented in swift-syntax as slightly different semantics because it consideres `(callable.|callAsFunction)(x: 78)` as a reference to `callAsFunction` instead of a call with argument labels `(x: 78)`, which means that one test needs to be updated.
2023-12-12 12:49:16 -08:00
Alex Hoppen
d53e1b99f8 [SourceKit] Change RenameRangeCollector::startSourceEntity to use early returns 2023-12-06 14:33:14 -08:00
Alex Hoppen
e538a5ed61 [SourceKit] Merge RenameLoc and RenameLocation
It’s easier to understand the code if we don’t have these two nearly, but not quite, identical types.
2023-12-06 14:33:14 -08:00
Alex Hoppen
f408619ddc Address Hamish’s review comments 2023-11-27 14:17:04 -08:00
Alex Hoppen
1047328b63 [SourceKit] Lowercase members of ResolvedLoc
This type will get exposed to Swift and the members should be lowercase so that they read nicely in Swift.
2023-11-16 16:05:08 -08:00
Alex Hoppen
899368037c [SourceKit] Return results from rename using return values instead of consumers
This makes it a lot easier to follow the code.
2023-11-16 16:05:08 -08:00
Alex Hoppen
5d7200a0a1 [SourceKit] Remove the local rename refactoring action
Local refactoring should go through the `find-local-rename-ranges` request.
2023-11-16 16:05:08 -08:00
Alex Hoppen
b3ab9bffd5 [SourceKit] Remove UnresolvedLoc.ResolveArgLocs
AFAICT we can just infer whether to resolve arguments based on the presence of arguments. We don’t need the information to be passed in.
2023-11-16 16:05:07 -08:00
Alex Hoppen
d9eef8c229 [SourceKit] Remove IsNonProtocolType parameter from rename locations
The parameter was never checked anywhere.
2023-11-16 16:05:07 -08:00
Alex Hoppen
d095d0a186 [SourceKit] Remove newName from RenameLoc
We should (and do) have one new name for the entire rename operation, not a separate new name for different positions at which the renamed symbol occurs.
2023-11-16 16:05:07 -08:00
Alex Hoppen
ada3076628 [SourceKit] Share implemention of local rename and related idents
Local rename and related identifiers were sufficiently similar that we can implement related identifiers in terms of local rename.
2023-11-16 16:05:07 -08:00
Alex Hoppen
698397c309 [Refactoring] Expose findLocalRenameLocs in Refactoring.h 2023-11-16 16:05:07 -08:00
Alex Hoppen
55b3404660 [Refactoring] Move syntactic rename to its own file 2023-09-26 20:14:22 -07:00
Alex Hoppen
3074dbe5c5 [Refactoring] Move LocalRename to its own file 2023-09-11 17:14:29 -07:00