Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(586)

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart

Issue 1511553005: suggest yield and yeild* - fixes #24346 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge and cleanup imports Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1a0d1d53655a73da43920527633f41fac0ed4c3b..28de09b91cfb586d4935e1414a7f70feac485527 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,6 +16,8 @@ const ASYNC = 'async';
const ASYNC_STAR = 'async*';
const AWAIT = 'await';
const SYNC_STAR = 'sync*';
+const YIELD = 'yield';
+const YIELD_STAR = 'yield*';
/**
* A contributor for calculating `completion.getSuggestions` request results
@@ -463,6 +465,10 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
if (_inAsyncMethodOrFunction(node)) {
_addSuggestion2(AWAIT);
+ } else if (_inAsyncStarOrSyncStarMethodOrFunction(node)) {
+ _addSuggestion2(AWAIT);
+ _addSuggestion2(YIELD);
+ _addSuggestion2(YIELD_STAR);
}
if (_inLoop(node)) {
_addSuggestions([Keyword.BREAK, Keyword.CONTINUE]);
@@ -511,7 +517,12 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
bool _inAsyncMethodOrFunction(AstNode node) {
FunctionBody body = node.getAncestor((n) => n is FunctionBody);
- return body != null && body.isAsynchronous;
+ return body != null && body.isAsynchronous && body.star == null;
+ }
+
+ bool _inAsyncStarOrSyncStarMethodOrFunction(AstNode node) {
+ FunctionBody body = node.getAncestor((n) => n is FunctionBody);
+ return body != null && body.keyword != null && body.star != null;
}
bool _inCatchClause(Block node) =>
@@ -536,7 +547,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
bool _inForLoop(AstNode node) =>
node.getAncestor((p) => p is ForStatement || p is ForEachStatement) !=
- null;
+ null;
bool _inLoop(AstNode node) =>
_inDoLoop(node) || _inForLoop(node) || _inWhileLoop(node);
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698