21 Commits

Author SHA1 Message Date
Doug Gregor
49aa0e966f Ensure that SourceFiles always have a backing buffer in the SourceManager
The "buffer ID" in a SourceFile, which is used to find the source file's
contents in the SourceManager, has always been optional. However, the
effectively every SourceFile actually does have a buffer ID, and the
vast majority of accesses to this information dereference the optional
without checking.

Update the handful of call sites that provided `nullopt` as the buffer
ID to provide a proper buffer instead. These were mostly unit tests
and testing programs, with a few places that passed a never-empty
optional through to the SourceFile constructor.

Then, remove optionality from the representation and accessors. It is
now the case that every SourceFile has a buffer ID, simplying a bunch
of code.
2024-09-16 21:46:42 -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
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
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
9219b0cd71 [SourceKit] Address FIXMEs for the NameMatcher
rdar://118996561
2023-12-11 16:56:01 -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
a710111001 [SourceKit] Support building sourcekitd without building swift-syntax
This allows building sourcekitd and swift-refactor with `SWIFT_BUILD_SWIFT_SYNTAX=NO`. In these builds, the `relatedidents` and `find-syntactic-rename-ranges` requests will always return an error.
2023-12-04 19:14:01 -08:00
Alex Hoppen
bc5cc43a06 Don’t include <vector> in IDEBridging.h 2023-11-28 14:04:37 -08:00
Alex Hoppen
d224549030 [SourceKit] Don’t use C++ to Swift interop to run NameMatcher 2023-11-20 11:30:18 -08:00
Alex Hoppen
8fd025625b [SourceKit] Use NameMatcher that is rewritten in Swift for syntactic rename 2023-11-17 09:30: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
ec267e2c08 [SourceKit] Hide RenameRangeDetailCollector as an implementation detail
The usage becomes a lot clearer if there’s just a top-level function that returns the details for the syntactic rename ranges.
2023-11-16 16:05:08 -08:00
Alex Hoppen
a0313e3005 [SourceKit] Merge Renamer and RenameRangeDetailCollector
With `TextReplacementsRenamer` gone, `RenameRangeDetailCollector` was the only remaining subclass of `Renamer`.
2023-11-16 16:05:08 -08:00
Alex Hoppen
bfad46d524 [SourceKit] Remove the -syntactic-rename option from swift-refactor
With the local refactoring being removed, all production refactoring paths return a set of ranges to rename and don’t apply edits to the file. Thus, the `syntactic-rename` action also doesn’t make sense anymore.
2023-11-16 16:05:08 -08:00
Alex Hoppen
ba06b5c075 [SourceKit] Replace UnresolvedLoc by SourceLoc
`UnresolvedLoc` was just a wrapper around `SourceLoc` and isn’t needed anymore.
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
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
55b3404660 [Refactoring] Move syntactic rename to its own file 2023-09-26 20:14:22 -07:00