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

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

Issue 1285573003: suggest "in" in for statement (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years, 4 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/completion_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 94598dbe051e8e6ff49ddfdbe160a188c28a9bab..9c32f9f14b0dad568c2906e07a38e514b123e95b 100644
--- a/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/keyword_contributor.dart
@@ -124,7 +124,8 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
!node.directives.any((d) => d is LibraryDirective)) {
_addSuggestions([Keyword.LIBRARY], DART_RELEVANCE_HIGH);
}
- _addSuggestions([Keyword.IMPORT, Keyword.EXPORT, Keyword.PART], DART_RELEVANCE_HIGH);
+ _addSuggestions(
+ [Keyword.IMPORT, Keyword.EXPORT, Keyword.PART], DART_RELEVANCE_HIGH);
}
if (entity == null || entity is Declaration) {
if (previousMember is FunctionDeclaration &&
@@ -137,14 +138,6 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
@override
- visitPropertyAccess(PropertyAccess node) {
- // suggestions before '.' but not after
- if (entity != node.propertyName) {
- super.visitPropertyAccess(node);
- }
- }
-
- @override
visitExpression(Expression node) {
_addExpressionKeywords(node);
}
@@ -157,6 +150,22 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
@override
+ visitForEachStatement(ForEachStatement node) {
+ if (entity == node.inKeyword) {
+ Token previous = node.inKeyword.previous;
+ if (previous is SyntheticStringToken && previous.lexeme == 'in') {
+ previous = previous.previous;
+ }
+ if (previous != null && previous.type == TokenType.EQ) {
+ _addSuggestions(
+ [Keyword.FALSE, Keyword.NEW, Keyword.NULL, Keyword.TRUE]);
+ } else {
+ _addSuggestion(Keyword.IN, DART_RELEVANCE_HIGH);
+ }
+ }
+ }
+
+ @override
visitFormalParameterList(FormalParameterList node) {
AstNode constructorDecl =
node.getAncestor((p) => p is ConstructorDeclaration);
@@ -166,6 +175,14 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
@override
+ visitForStatement(ForStatement node) {
+ if (entity == node.rightSeparator && entity.toString() != ';') {
+ // Handle the degenerate case while typing - for (int x i^)
+ _addSuggestion(Keyword.IN, DART_RELEVANCE_HIGH);
+ }
+ }
+
+ @override
visitFunctionExpression(FunctionExpression node) {
if (entity == node.body) {
if (!node.body.isAsynchronous) {
@@ -260,6 +277,14 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
@override
+ visitPropertyAccess(PropertyAccess node) {
+ // suggestions before '.' but not after
+ if (entity != node.propertyName) {
+ super.visitPropertyAccess(node);
+ }
+ }
+
+ @override
visitReturnStatement(ReturnStatement node) {
if (entity == node.expression) {
_addExpressionKeywords(node);
« no previous file with comments | « no previous file | pkg/analysis_server/test/completion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698