Chromium Code Reviews| 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.computer.dart.local; | 5 library services.completion.computer.dart.local; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 | 301 |
| 302 @override | 302 @override |
| 303 bool visitStringLiteral(StringLiteral node) { | 303 bool visitStringLiteral(StringLiteral node) { |
| 304 // ignore | 304 // ignore |
| 305 return finished; | 305 return finished; |
| 306 } | 306 } |
| 307 | 307 |
| 308 @override | 308 @override |
| 309 visitTypeName(TypeName node) { | 309 visitTypeName(TypeName node) { |
| 310 // If suggesting completions within a TypeName node | 310 // If suggesting completions within a TypeName node |
| 311 // then limit suggestions to only types | 311 // then limit suggestions to only types in specific situations |
|
Paul Berry
2014/12/15 16:32:19
The logic here looks exactly the same as the corre
danrubel
2014/12/16 08:04:59
Per discussion, I added a TODO here and will addre
| |
| 312 typesOnly = true; | 312 AstNode p = node.parent; |
| 313 if (p is IsExpression || p is ConstructorName || p is AsExpression) { | |
| 314 typesOnly = true; | |
| 315 } else if (p is VariableDeclarationList) { | |
| 316 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS | |
| 317 // the user may be either (1) entering a type for the assignment | |
| 318 // or (2) starting a new statement. | |
| 319 // Consider suggesting only types | |
| 320 // if only spaces separates the 1st and 2nd identifiers. | |
| 321 } | |
| 313 return visitNode(node); | 322 return visitNode(node); |
| 314 } | 323 } |
| 315 | 324 |
| 316 @override | 325 @override |
| 317 bool visitVariableDeclaration(VariableDeclaration node) { | 326 bool visitVariableDeclaration(VariableDeclaration node) { |
| 318 // Do not add suggestions if editing the name in a var declaration | 327 // Do not add suggestions if editing the name in a var declaration |
| 319 SimpleIdentifier name = node.name; | 328 SimpleIdentifier name = node.name; |
| 320 if (name == null || name.offset < offset || offset > name.end) { | 329 if (name == null || name.offset < offset || offset > name.end) { |
| 321 return visitNode(node); | 330 return visitNode(node); |
| 322 } else { | 331 } else { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 if (name == null || name.length <= 0) { | 444 if (name == null || name.length <= 0) { |
| 436 return DYNAMIC; | 445 return DYNAMIC; |
| 437 } | 446 } |
| 438 TypeArgumentList typeArgs = type.typeArguments; | 447 TypeArgumentList typeArgs = type.typeArguments; |
| 439 if (typeArgs != null) { | 448 if (typeArgs != null) { |
| 440 //TODO (danrubel) include type arguments | 449 //TODO (danrubel) include type arguments |
| 441 } | 450 } |
| 442 return name; | 451 return name; |
| 443 } | 452 } |
| 444 } | 453 } |
| OLD | NEW |