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

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: 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
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..8da4aa5247043ba96fe5f866b7b820d00c7c4fc8 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,13 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
}
@override
+ visitForEachStatement(ForEachStatement node) {
+ if (entity == node.inKeyword) {
+ _addSuggestion(Keyword.IN, DART_RELEVANCE_HIGH);
+ }
+ }
+
+ @override
visitFormalParameterList(FormalParameterList node) {
AstNode constructorDecl =
node.getAncestor((p) => p is ConstructorDeclaration);
@@ -166,6 +166,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 +268,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);

Powered by Google App Engine
This is Rietveld 408576698