| Index: pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart b/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
|
| index b979b8ba30bdcde748ba6680d5ee639d174d459d..a202fba4da25145b2ba987049e40f385a5c66bd5 100644
|
| --- a/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
|
| +++ b/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
|
| @@ -41,27 +41,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
|
|
| @override
|
| visitBlock(Block node) {
|
| - if (_isInClassMemberBody(node)) {
|
| - _addSuggestions([Keyword.SUPER, Keyword.THIS,]);
|
| - }
|
| - _addSuggestions([
|
| - Keyword.ASSERT,
|
| - Keyword.CASE,
|
| - Keyword.CONTINUE,
|
| - Keyword.DO,
|
| - Keyword.FINAL,
|
| - Keyword.FOR,
|
| - Keyword.IF,
|
| - Keyword.NEW,
|
| - Keyword.RETHROW,
|
| - Keyword.RETURN,
|
| - Keyword.SWITCH,
|
| - Keyword.THROW,
|
| - Keyword.TRY,
|
| - Keyword.VAR,
|
| - Keyword.VOID,
|
| - Keyword.WHILE
|
| - ]);
|
| + _addStatementKeywords(node);
|
| }
|
|
|
| @override
|
| @@ -138,6 +118,13 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| }
|
|
|
| @override
|
| + visitIfStatement(IfStatement node) {
|
| + if (entity == node.thenStatement) {
|
| + _addStatementKeywords(node);
|
| + }
|
| + }
|
| +
|
| + @override
|
| visitImportDirective(ImportDirective node) {
|
| if (entity == node.asKeyword) {
|
| if (node.deferredKeyword == null) {
|
| @@ -149,15 +136,6 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| }
|
| }
|
|
|
| - void _addImportDirectiveKeywords(ImportDirective node) {
|
| - if (node.asKeyword == null) {
|
| - _addSuggestion(Keyword.AS, DART_RELEVANCE_HIGH);
|
| - if (node.deferredKeyword == null) {
|
| - _addSuggestion(Keyword.DEFERRED, DART_RELEVANCE_HIGH);
|
| - }
|
| - }
|
| - }
|
| -
|
| void _addClassDeclarationKeywords(ClassDeclaration node) {
|
| // Very simplistic suggestion because analyzer will warn if
|
| // the extends / with / implements keywords are out of order
|
| @@ -171,6 +149,39 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
|
| }
|
| }
|
|
|
| + void _addImportDirectiveKeywords(ImportDirective node) {
|
| + if (node.asKeyword == null) {
|
| + _addSuggestion(Keyword.AS, DART_RELEVANCE_HIGH);
|
| + if (node.deferredKeyword == null) {
|
| + _addSuggestion(Keyword.DEFERRED, DART_RELEVANCE_HIGH);
|
| + }
|
| + }
|
| + }
|
| +
|
| + void _addStatementKeywords(AstNode node) {
|
| + if (_isInClassMemberBody(node)) {
|
| + _addSuggestions([Keyword.SUPER, Keyword.THIS,]);
|
| + }
|
| + _addSuggestions([
|
| + Keyword.ASSERT,
|
| + Keyword.CASE,
|
| + Keyword.CONTINUE,
|
| + Keyword.DO,
|
| + Keyword.FINAL,
|
| + Keyword.FOR,
|
| + Keyword.IF,
|
| + Keyword.NEW,
|
| + Keyword.RETHROW,
|
| + Keyword.RETURN,
|
| + Keyword.SWITCH,
|
| + Keyword.THROW,
|
| + Keyword.TRY,
|
| + Keyword.VAR,
|
| + Keyword.VOID,
|
| + Keyword.WHILE
|
| + ]);
|
| + }
|
| +
|
| void _addSuggestion(Keyword keyword,
|
| [int relevance = DART_RELEVANCE_DEFAULT]) {
|
| String completion = keyword.syntax;
|
|
|