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

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

Issue 1135613004: suggest async for closures (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 months 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/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/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 7a8763bd47b98c9a3c2d80621c55f8289d5d8ed8..d4379d9ce96ef4fe697daf4236656064064fb601 100644
--- a/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
@@ -52,6 +52,23 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
@override
visitBlock(Block node) {
+ if (entity is ExpressionStatement) {
+ Expression expression = (entity as ExpressionStatement).expression;
+ if (expression is SimpleIdentifier) {
+ Token token = expression.token;
+ Token previous = token.previous;
+ if (previous.isSynthetic) {
+ previous = previous.previous;
+ }
+ Token next = token.next;
+ if (next.isSynthetic) {
+ next = next.next;
+ }
+ if (previous.lexeme == ')' && next.lexeme == '{') {
+ _addSuggestion2(ASYNC);
+ }
+ }
+ }
_addStatementKeywords(node);
}
@@ -151,7 +168,9 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
@override
visitFunctionExpression(FunctionExpression node) {
if (entity == node.body) {
- _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH);
+ if (!node.body.isAsynchronous) {
+ _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH);
+ }
if (node.body is EmptyFunctionBody &&
node.parent is FunctionDeclaration &&
node.parent.parent is CompilationUnit) {
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/keyword_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698