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 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library services.completion.dart.local.declaration.visitor; | 5 library services.completion.dart.local.declaration.visitor; |
6 | 6 |
7 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; | 7 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; |
8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
9 import 'package:analyzer/src/generated/scanner.dart'; | 9 import 'package:analyzer/src/generated/scanner.dart'; |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 SimpleIdentifier id; | 153 SimpleIdentifier id; |
154 TypeName type; | 154 TypeName type; |
155 DeclaredIdentifier loopVar = node.loopVariable; | 155 DeclaredIdentifier loopVar = node.loopVariable; |
156 if (loopVar != null) { | 156 if (loopVar != null) { |
157 id = loopVar.identifier; | 157 id = loopVar.identifier; |
158 type = loopVar.type; | 158 type = loopVar.type; |
159 } else { | 159 } else { |
160 id = node.identifier; | 160 id = node.identifier; |
161 type = null; | 161 type = null; |
162 } | 162 } |
163 declaredLocalVar(id, type); | 163 if (id != null) { |
| 164 // If there is no loop variable, don't declare it. |
| 165 declaredLocalVar(id, type); |
| 166 } |
164 visitNode(node); | 167 visitNode(node); |
165 } | 168 } |
166 | 169 |
167 @override | 170 @override |
168 void visitForStatement(ForStatement node) { | 171 void visitForStatement(ForStatement node) { |
169 VariableDeclarationList varList = node.variables; | 172 VariableDeclarationList varList = node.variables; |
170 if (varList != null) { | 173 if (varList != null) { |
171 varList.variables.forEach((VariableDeclaration varDecl) { | 174 varList.variables.forEach((VariableDeclaration varDecl) { |
172 declaredLocalVar(varDecl.name, varList.type); | 175 declaredLocalVar(varDecl.name, varList.type); |
173 }); | 176 }); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 }); | 263 }); |
261 } | 264 } |
262 } | 265 } |
263 } | 266 } |
264 | 267 |
265 /** | 268 /** |
266 * Internal exception used to indicate that [LocalDeclarationVisitor] | 269 * Internal exception used to indicate that [LocalDeclarationVisitor] |
267 * should stop visiting. | 270 * should stop visiting. |
268 */ | 271 */ |
269 class _LocalDeclarationVisitorFinished {} | 272 class _LocalDeclarationVisitorFinished {} |
OLD | NEW |