| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 310 } |
| 311 | 311 |
| 312 @override | 312 @override |
| 313 bool visitStringLiteral(StringLiteral node) { | 313 bool visitStringLiteral(StringLiteral node) { |
| 314 // ignore | 314 // ignore |
| 315 return finished; | 315 return finished; |
| 316 } | 316 } |
| 317 | 317 |
| 318 @override | 318 @override |
| 319 visitTypeName(TypeName node) { | 319 visitTypeName(TypeName node) { |
| 320 // TODO (danrubel) refactor this and imported_computer |
| 321 // to reduce duplicate code |
| 320 // If suggesting completions within a TypeName node | 322 // If suggesting completions within a TypeName node |
| 321 // then limit suggestions to only types | 323 // then limit suggestions to only types in specific situations |
| 322 typesOnly = true; | 324 AstNode p = node.parent; |
| 325 if (p is IsExpression || p is ConstructorName || p is AsExpression) { |
| 326 typesOnly = true; |
| 327 } else if (p is VariableDeclarationList) { |
| 328 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS |
| 329 // the user may be either (1) entering a type for the assignment |
| 330 // or (2) starting a new statement. |
| 331 // Consider suggesting only types |
| 332 // if only spaces separates the 1st and 2nd identifiers. |
| 333 } |
| 323 return visitNode(node); | 334 return visitNode(node); |
| 324 } | 335 } |
| 325 | 336 |
| 326 @override | 337 @override |
| 327 bool visitVariableDeclaration(VariableDeclaration node) { | 338 bool visitVariableDeclaration(VariableDeclaration node) { |
| 328 // Do not add suggestions if editing the name in a var declaration | 339 // Do not add suggestions if editing the name in a var declaration |
| 329 SimpleIdentifier name = node.name; | 340 SimpleIdentifier name = node.name; |
| 330 if (name == null || name.offset < offset || offset > name.end) { | 341 if (name == null || name.offset < offset || offset > name.end) { |
| 331 return visitNode(node); | 342 return visitNode(node); |
| 332 } else { | 343 } else { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 if (name == null || name.length <= 0) { | 456 if (name == null || name.length <= 0) { |
| 446 return DYNAMIC; | 457 return DYNAMIC; |
| 447 } | 458 } |
| 448 TypeArgumentList typeArgs = type.typeArguments; | 459 TypeArgumentList typeArgs = type.typeArguments; |
| 449 if (typeArgs != null) { | 460 if (typeArgs != null) { |
| 450 //TODO (danrubel) include type arguments | 461 //TODO (danrubel) include type arguments |
| 451 } | 462 } |
| 452 return name; | 463 return name; |
| 453 } | 464 } |
| 454 } | 465 } |
| OLD | NEW |