| Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| index c46ee05bf9cd47c09a9c2318bdd6e25849acff74..cc4311647f8e294f6e5c0d6f7c63ed2400ac678b 100644
|
| --- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| +++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
|
| @@ -198,12 +198,15 @@ class FixProcessor {
|
| _addFix_undefinedClass_useSimilar();
|
| }
|
| if (errorCode == StaticWarningCode.UNDEFINED_IDENTIFIER) {
|
| - _addFix_createField();
|
| - _addFix_createGetter();
|
| - _addFix_createFunction_forFunctionType();
|
| - _addFix_importLibrary_withType();
|
| - _addFix_importLibrary_withTopLevelVariable();
|
| - _addFix_createLocalVariable();
|
| + bool isAsync = _addFix_addAsync();
|
| + if (!isAsync) {
|
| + _addFix_createField();
|
| + _addFix_createGetter();
|
| + _addFix_createFunction_forFunctionType();
|
| + _addFix_importLibrary_withType();
|
| + _addFix_importLibrary_withTopLevelVariable();
|
| + _addFix_createLocalVariable();
|
| + }
|
| }
|
| if (errorCode == StaticTypeWarningCode.INSTANCE_ACCESS_TO_STATIC_MEMBER) {
|
| _addFix_useStaticAccess_method();
|
| @@ -264,6 +267,22 @@ class FixProcessor {
|
| exitPosition = null;
|
| }
|
|
|
| + /**
|
| + * Returns `true` if the `async` proposal was added.
|
| + */
|
| + bool _addFix_addAsync() {
|
| + AstNode node = this.node;
|
| + if (_isAwaitNode()) {
|
| + FunctionBody body = node.getAncestor((n) => n is FunctionBody);
|
| + if (body.keyword == null) {
|
| + _addReplaceEdit(rf.rangeStartLength(body, 0), 'async ');
|
| + _addFix(FixKind.ADD_ASYNC, []);
|
| + return true;
|
| + }
|
| + }
|
| + return false;
|
| + }
|
| +
|
| void _addFix_boolInsteadOfBoolean() {
|
| SourceRange range = rf.rangeError(error);
|
| _addReplaceEdit(range, 'bool');
|
| @@ -1164,6 +1183,9 @@ class FixProcessor {
|
|
|
| void _addFix_insertSemicolon() {
|
| if (error.message.contains("';'")) {
|
| + if (_isAwaitNode()) {
|
| + return;
|
| + }
|
| int insertOffset = error.offset + error.length;
|
| _addInsertEdit(insertOffset, ';');
|
| _addFix(FixKind.INSERT_SEMICOLON, []);
|
| @@ -2065,6 +2087,11 @@ class FixProcessor {
|
| return method != null && method.isStatic;
|
| }
|
|
|
| + bool _isAwaitNode() {
|
| + AstNode node = this.node;
|
| + return node is SimpleIdentifier && node.name == 'await';
|
| + }
|
| +
|
| _ConstructorLocation
|
| _prepareNewConstructorLocation(ClassDeclaration classDeclaration) {
|
| List<ClassMember> members = classDeclaration.members;
|
|
|