Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1885)

Unified Diff: pkg/analysis_server/lib/src/services/refactoring/inline_method.dart

Issue 2463493002: Fix for inlining async methods/getters. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
diff --git a/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart b/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
index ca243c4b0673c97f2f1fa17f6b40c267787927ff..d68de947477092a705025ef737382facb5a4e749 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/inline_method.dart
@@ -216,6 +216,7 @@ class InlineMethodRefactoringImpl extends RefactoringImpl
_SourcePart _methodExpressionPart;
_SourcePart _methodStatementsPart;
List<_ReferenceProcessor> _referenceProcessors = [];
+ Set<FunctionBody> _alreadyMadeAsync = new Set<FunctionBody>();
InlineMethodRefactoringImpl(this.searchEngine, this.unit, this.offset) {
utils = new CorrectionUtils(unit);
@@ -560,6 +561,15 @@ class _ReferenceProcessor {
if (!_shouldProcess()) {
return;
}
+ // If the element being inlined is async, ensure that the function
+ // body that encloses the method is also async.
+ if (ref._methodElement.isAsynchronous) {
+ FunctionBody body = _node.getAncestor((n) => n is FunctionBody);
+ if (!body.isAsynchronous && ref._alreadyMadeAsync.add(body)) {
+ SourceRange bodyStart = rangeStartLength(body.offset, 0);
+ _addRefEdit(newSourceEdit_range(bodyStart, 'async '));
+ }
+ }
// may be invocation of inline method
if (nodeParent is MethodInvocation) {
MethodInvocation invocation = nodeParent;

Powered by Google App Engine
This is Rietveld 408576698