[Refactorings] Add cursor refactorings for the start of the range

When a range is a single expression/statement/decl or part of
expression, also return cursor based refactorings for the start of the
range.

This is a stop gap until the available refactorings are properly fixed
to be more lenient in general - the current fix is a little odd as eg.
if all of `foo.bar()` is selected, rename will be returned as an
available refactoring for `foo`. Still an improvement over completely
missing cursor based refactorings, however.

Resolves rdar://82060063
This commit is contained in:
Ben Barham
2021-08-18 14:04:10 +10:00
parent f846126d58
commit c7620fa979
5 changed files with 51 additions and 68 deletions

View File

@@ -399,9 +399,9 @@ int main(int argc, char *argv[]) {
if (options::Action == RefactoringKind::None) {
llvm::SmallVector<RefactoringKind, 32> Kinds;
bool RangeStartMayNeedRename = false;
collectAvailableRefactorings(SF, Range, RangeStartMayNeedRename, Kinds,
{&PrintDiags});
bool CollectRangeStartRefactorings = false;
collectAvailableRefactorings(SF, Range, CollectRangeStartRefactorings,
Kinds, {&PrintDiags});
llvm::outs() << "Action begins\n";
for (auto Kind : Kinds) {
llvm::outs() << getDescriptiveRefactoringKindName(Kind) << "\n";