OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 | 2 |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 library services.completion.contributor.dart.keyword; | 6 library services.completion.contributor.dart.keyword; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 | 9 |
10 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 10 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 visitFormalParameterList(FormalParameterList node) { | 180 visitFormalParameterList(FormalParameterList node) { |
181 AstNode constructorDeclaration = | 181 AstNode constructorDeclaration = |
182 node.getAncestor((p) => p is ConstructorDeclaration); | 182 node.getAncestor((p) => p is ConstructorDeclaration); |
183 if (constructorDeclaration != null) { | 183 if (constructorDeclaration != null) { |
184 _addSuggestions([Keyword.THIS]); | 184 _addSuggestions([Keyword.THIS]); |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 @override | 188 @override |
189 visitForStatement(ForStatement node) { | 189 visitForStatement(ForStatement node) { |
190 if (entity == node.rightSeparator && entity.toString() != ';') { | 190 // Handle the degenerate case while typing - for (int x i^) |
191 // Handle the degenerate case while typing - for (int x i^) | 191 if (node.condition == entity && entity is SimpleIdentifier) { |
192 _addSuggestion(Keyword.IN, DART_RELEVANCE_HIGH); | 192 Token entityToken = (entity as SimpleIdentifier).beginToken; |
| 193 if (entityToken.previous.isSynthetic && |
| 194 entityToken.previous.type == TokenType.SEMICOLON) { |
| 195 _addSuggestion(Keyword.IN, DART_RELEVANCE_HIGH); |
| 196 } |
193 } | 197 } |
194 } | 198 } |
195 | 199 |
196 @override | 200 @override |
197 visitFunctionExpression(FunctionExpression node) { | 201 visitFunctionExpression(FunctionExpression node) { |
198 if (entity == node.body) { | 202 if (entity == node.body) { |
199 if (!node.body.isAsynchronous) { | 203 if (!node.body.isAsynchronous) { |
200 _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH); | 204 _addSuggestion2(ASYNC, relevance: DART_RELEVANCE_HIGH); |
201 } | 205 } |
202 if (node.body is EmptyFunctionBody && | 206 if (node.body is EmptyFunctionBody && |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 | 516 |
513 bool _inLoop(AstNode node) => | 517 bool _inLoop(AstNode node) => |
514 _inDoLoop(node) || _inForLoop(node) || _inWhileLoop(node); | 518 _inDoLoop(node) || _inForLoop(node) || _inWhileLoop(node); |
515 | 519 |
516 bool _inSwitch(AstNode node) => | 520 bool _inSwitch(AstNode node) => |
517 node.getAncestor((p) => p is SwitchStatement) != null; | 521 node.getAncestor((p) => p is SwitchStatement) != null; |
518 | 522 |
519 bool _inWhileLoop(AstNode node) => | 523 bool _inWhileLoop(AstNode node) => |
520 node.getAncestor((p) => p is WhileStatement) != null; | 524 node.getAncestor((p) => p is WhileStatement) != null; |
521 } | 525 } |
OLD | NEW |