| Index: pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
|
| index 7a54c9e9bba0971a89789c3da41314a90b6ab9e6..6f2b8523774ead7d0a43444adad16726963f06c2 100644
|
| --- a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
|
| +++ b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
|
| @@ -16,11 +16,12 @@ import 'package:analyzer/dart/ast/token.dart';
|
| import 'package:analyzer/dart/ast/visitor.dart';
|
| import 'package:analyzer/src/dart/ast/token.dart';
|
|
|
| -const ASYNC = 'async';
|
| const ASYNC_STAR = 'async*';
|
| -const AWAIT = 'await';
|
| +const DEFERRED_AS = 'deferred as';
|
| +const EXPORT_STATEMENT = "export '';";
|
| +const IMPORT_STATEMENT = "import '';";
|
| +const PART_STATEMENT = "part '';";
|
| const SYNC_STAR = 'sync*';
|
| -const YIELD = 'yield';
|
| const YIELD_STAR = 'yield*';
|
|
|
| /**
|
| @@ -66,7 +67,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| previous = previous.previous;
|
| }
|
| if (previous.lexeme == ')') {
|
| - _addSuggestion2(ASYNC);
|
| + _addSuggestion(Keyword.ASYNC);
|
| _addSuggestion2(ASYNC_STAR);
|
| _addSuggestion2(SYNC_STAR);
|
| }
|
| @@ -80,7 +81,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| visitAsExpression(AsExpression node) {
|
| if (identical(entity, node.asOperator) &&
|
| node.expression is ParenthesizedExpression) {
|
| - _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH);
|
| + _addSuggestion(Keyword.ASYNC, DART_RELEVANCE_HIGH);
|
| _addSuggestion2(ASYNC_STAR, relevance: DART_RELEVANCE_HIGH);
|
| _addSuggestion2(SYNC_STAR, relevance: DART_RELEVANCE_HIGH);
|
| }
|
| @@ -91,7 +92,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| Statement prevStmt = OpType.getPreviousStatement(node, entity);
|
| if (prevStmt is TryStatement) {
|
| if (prevStmt.finallyBlock == null) {
|
| - _addSuggestion2('on');
|
| + _addSuggestion(Keyword.ON);
|
| _addSuggestion(Keyword.CATCH);
|
| _addSuggestion(Keyword.FINALLY);
|
| if (prevStmt.catchClauses.isEmpty) {
|
| @@ -116,7 +117,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| }
|
| if (previous.type == TokenType.CLOSE_PAREN &&
|
| next.type == TokenType.OPEN_CURLY_BRACKET) {
|
| - _addSuggestion2(ASYNC);
|
| + _addSuggestion(Keyword.ASYNC);
|
| _addSuggestion2(ASYNC_STAR);
|
| _addSuggestion2(SYNC_STAR);
|
| }
|
| @@ -141,7 +142,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| int index = node.members.indexOf(entity);
|
| ClassMember previous = index > 0 ? node.members[index - 1] : null;
|
| if (previous is MethodDeclaration && previous.body is EmptyFunctionBody) {
|
| - _addSuggestion2(ASYNC);
|
| + _addSuggestion(Keyword.ASYNC);
|
| _addSuggestion2(ASYNC_STAR);
|
| _addSuggestion2(SYNC_STAR);
|
| }
|
| @@ -182,18 +183,18 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| !node.directives.any((d) => d is LibraryDirective)) {
|
| _addSuggestions([Keyword.LIBRARY], DART_RELEVANCE_HIGH);
|
| }
|
| - _addSuggestion2('${Keyword.IMPORT.lexeme} \'\';',
|
| + _addSuggestion2(IMPORT_STATEMENT,
|
| offset: 8, relevance: DART_RELEVANCE_HIGH);
|
| - _addSuggestion2('${Keyword.EXPORT.lexeme} \'\';',
|
| + _addSuggestion2(EXPORT_STATEMENT,
|
| offset: 8, relevance: DART_RELEVANCE_HIGH);
|
| - _addSuggestion2('${Keyword.PART.lexeme} \'\';',
|
| + _addSuggestion2(PART_STATEMENT,
|
| offset: 6, relevance: DART_RELEVANCE_HIGH);
|
| }
|
| if (entity == null || entity is Declaration) {
|
| if (previousMember is FunctionDeclaration &&
|
| previousMember.functionExpression is FunctionExpression &&
|
| previousMember.functionExpression.body is EmptyFunctionBody) {
|
| - _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH);
|
| + _addSuggestion(Keyword.ASYNC, DART_RELEVANCE_HIGH);
|
| _addSuggestion2(ASYNC_STAR, relevance: DART_RELEVANCE_HIGH);
|
| _addSuggestion2(SYNC_STAR, relevance: DART_RELEVANCE_HIGH);
|
| }
|
| @@ -283,7 +284,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| if (entity == node.body) {
|
| FunctionBody body = node.body;
|
| if (!body.isAsynchronous) {
|
| - _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH);
|
| + _addSuggestion(Keyword.ASYNC, DART_RELEVANCE_HIGH);
|
| if (body is! ExpressionFunctionBody) {
|
| _addSuggestion2(ASYNC_STAR, relevance: DART_RELEVANCE_HIGH);
|
| _addSuggestion2(SYNC_STAR, relevance: DART_RELEVANCE_HIGH);
|
| @@ -355,11 +356,11 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| if (entity == node.body) {
|
| if (node.body is EmptyFunctionBody) {
|
| _addClassBodyKeywords();
|
| - _addSuggestion2(ASYNC);
|
| + _addSuggestion(Keyword.ASYNC);
|
| _addSuggestion2(ASYNC_STAR);
|
| _addSuggestion2(SYNC_STAR);
|
| } else {
|
| - _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH);
|
| + _addSuggestion(Keyword.ASYNC, DART_RELEVANCE_HIGH);
|
| if (node.body is! ExpressionFunctionBody) {
|
| _addSuggestion2(ASYNC_STAR, relevance: DART_RELEVANCE_HIGH);
|
| _addSuggestion2(SYNC_STAR, relevance: DART_RELEVANCE_HIGH);
|
| @@ -443,7 +444,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| var obj = entity;
|
| if (obj is CatchClause ||
|
| (obj is KeywordToken && obj.value() == Keyword.FINALLY)) {
|
| - _addSuggestion2('on');
|
| + _addSuggestion(Keyword.ON);
|
| _addSuggestion(Keyword.CATCH);
|
| return null;
|
| }
|
| @@ -510,7 +511,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| _addSuggestions([Keyword.SUPER, Keyword.THIS]);
|
| }
|
| if (_inAsyncMethodOrFunction(node)) {
|
| - _addSuggestion2(AWAIT);
|
| + _addSuggestion(Keyword.AWAIT);
|
| }
|
| }
|
|
|
| @@ -522,15 +523,15 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| }
|
| if (!hasDeferredKeyword) {
|
| if (!hasAsKeyword) {
|
| - _addSuggestion2('deferred as', relevance: DART_RELEVANCE_HIGH);
|
| + _addSuggestion2(DEFERRED_AS, relevance: DART_RELEVANCE_HIGH);
|
| } else if (entity == node.asKeyword) {
|
| _addSuggestion(Keyword.DEFERRED, DART_RELEVANCE_HIGH);
|
| }
|
| }
|
| if (!hasDeferredKeyword || hasAsKeyword) {
|
| if (node.combinators.isEmpty) {
|
| - _addSuggestion2('show', relevance: DART_RELEVANCE_HIGH);
|
| - _addSuggestion2('hide', relevance: DART_RELEVANCE_HIGH);
|
| + _addSuggestion(Keyword.SHOW, DART_RELEVANCE_HIGH);
|
| + _addSuggestion(Keyword.HIDE, DART_RELEVANCE_HIGH);
|
| }
|
| }
|
| }
|
| @@ -540,10 +541,10 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| _addSuggestions([Keyword.SUPER, Keyword.THIS]);
|
| }
|
| if (_inAsyncMethodOrFunction(node)) {
|
| - _addSuggestion2(AWAIT);
|
| + _addSuggestion(Keyword.AWAIT);
|
| } else if (_inAsyncStarOrSyncStarMethodOrFunction(node)) {
|
| - _addSuggestion2(AWAIT);
|
| - _addSuggestion2(YIELD);
|
| + _addSuggestion(Keyword.AWAIT);
|
| + _addSuggestion(Keyword.YIELD);
|
| _addSuggestion2(YIELD_STAR);
|
| }
|
| if (_inLoop(node)) {
|
|
|