mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Refactoring] Support async for function extraction
Adapt the `ThrowingEntityAnalyzer` to pick up any `await` keywords and add an `async` to the extracted function if necessary along with an `await` for its call. rdar://72199949
This commit is contained in:
@@ -1304,7 +1304,9 @@ bool RefactoringActionExtractFunction::performChange() {
|
||||
}
|
||||
OS << ")";
|
||||
|
||||
if (RangeInfo.ThrowingUnhandledError)
|
||||
if (RangeInfo.UnhandledEffects.contains(EffectKind::Async))
|
||||
OS << " async";
|
||||
if (RangeInfo.UnhandledEffects.contains(EffectKind::Throws))
|
||||
OS << " " << tok::kw_throws;
|
||||
|
||||
bool InsertedReturnType = false;
|
||||
@@ -1335,6 +1337,8 @@ bool RefactoringActionExtractFunction::performChange() {
|
||||
|
||||
if (RangeInfo.UnhandledEffects.contains(EffectKind::Throws))
|
||||
OS << tok::kw_try << " ";
|
||||
if (RangeInfo.UnhandledEffects.contains(EffectKind::Async))
|
||||
OS << "await ";
|
||||
|
||||
CallNameOffset = Buffer.size() - ReplaceBegin;
|
||||
OS << PreferredName << "(";
|
||||
|
||||
Reference in New Issue
Block a user