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 9c32f9f14b0dad568c2906e07a38e514b123e95b..bdd477dd86a99f35506f6fd698aec846b3ff480c 100644 |
--- a/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart |
+++ b/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart |
@@ -232,6 +232,15 @@ class _KeywordVisitor extends GeneralizingAstVisitor { |
} |
@override |
+ visitIsExpression(IsExpression node) { |
+ if (entity == node.isOperator) { |
+ _addSuggestion(Keyword.IS, DART_RELEVANCE_HIGH); |
+ } else { |
+ _addExpressionKeywords(node); |
+ } |
+ } |
+ |
+ @override |
visitLibraryIdentifier(LibraryIdentifier node) { |
// no suggestions |
} |
@@ -404,9 +413,14 @@ class _KeywordVisitor extends GeneralizingAstVisitor { |
if (_inAsyncMethodOrFunction(node)) { |
_addSuggestion2(AWAIT); |
} |
+ if (_inLoop(node)) { |
+ _addSuggestions([Keyword.BREAK, Keyword.CONTINUE]); |
+ } |
+ if (_inSwitch(node)) { |
+ _addSuggestions([Keyword.BREAK]); |
+ } |
_addSuggestions([ |
Keyword.ASSERT, |
- Keyword.CONTINUE, |
Keyword.DO, |
Keyword.FINAL, |
Keyword.FOR, |
@@ -434,8 +448,13 @@ class _KeywordVisitor extends GeneralizingAstVisitor { |
offset = completion.length; |
} |
request.addSuggestion(new CompletionSuggestion( |
- CompletionSuggestionKind.KEYWORD, relevance, completion, offset, 0, |
- false, false)); |
+ CompletionSuggestionKind.KEYWORD, |
+ relevance, |
+ completion, |
+ offset, |
+ 0, |
+ false, |
+ false)); |
} |
void _addSuggestions(List<Keyword> keywords, |
@@ -463,4 +482,20 @@ class _KeywordVisitor extends GeneralizingAstVisitor { |
node = parent; |
} |
} |
+ |
+ bool _inDoLoop(AstNode node) => |
+ node.getAncestor((p) => p is DoStatement) != null; |
+ |
+ bool _inForLoop(AstNode node) => |
+ node.getAncestor((p) => p is ForStatement || p is ForEachStatement) != |
+ null; |
+ |
+ bool _inLoop(AstNode node) => |
+ _inDoLoop(node) || _inForLoop(node) || _inWhileLoop(node); |
+ |
+ bool _inSwitch(AstNode node) => |
+ node.getAncestor((p) => p is SwitchStatement) != null; |
+ |
+ bool _inWhileLoop(AstNode node) => |
+ node.getAncestor((p) => p is WhileStatement) != null; |
} |