File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
lib/src/services/refactoring/legacy Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import 'package:analysis_server/src/utilities/strings.dart';
15
15
import 'package:analyzer/dart/analysis/results.dart' ;
16
16
import 'package:analyzer/dart/ast/ast.dart' ;
17
17
import 'package:analyzer/dart/ast/precedence.dart' ;
18
+ import 'package:analyzer/dart/ast/token.dart' ;
18
19
import 'package:analyzer/dart/ast/visitor.dart' ;
19
20
import 'package:analyzer/dart/element/element.dart' ;
20
21
import 'package:analyzer/source/source_range.dart' ;
@@ -572,6 +573,12 @@ class _ReferenceProcessor {
572
573
}
573
574
// do replace
574
575
var methodUsageRange = range.node (usage);
576
+ var awaitKeyword = Keyword .AWAIT .lexeme;
577
+ if (usage.parent is AwaitExpression &&
578
+ source.startsWith (awaitKeyword)) {
579
+ // remove the duplicate await keyword and the following whitespace.
580
+ source = source.substring (awaitKeyword.length + 1 );
581
+ }
575
582
var edit = newSourceEdit_range (methodUsageRange, source);
576
583
_addRefEdit (edit);
577
584
} else {
Original file line number Diff line number Diff line change @@ -1321,6 +1321,22 @@ void f() {
1321
1321
''' );
1322
1322
}
1323
1323
1324
+ Future <void > test_topLevelFunction_async () {
1325
+ addTestFile ('''
1326
+ Future<int> a() async => 3;
1327
+ Future<int> b() async => await a();
1328
+ Future<int> c() async => await b();
1329
+ }
1330
+ ''' );
1331
+ return assertSuccessfulRefactoring (() {
1332
+ return _sendInlineRequest ('b(' );
1333
+ }, '''
1334
+ Future<int> a() async => 3;
1335
+ Future<int> c() async => await a();
1336
+ }
1337
+ ''' );
1338
+ }
1339
+
1324
1340
Future <void > test_topLevelFunction_oneInvocation () {
1325
1341
addTestFile ('''
1326
1342
test(a, b) {
You can’t perform that action at this time.
0 commit comments