| 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 test.services.correction.assist; | 5 library test.services.correction.assist; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
| 8 import 'package:analysis_server/src/services/correction/assist.dart'; | 8 import 'package:analysis_server/src/services/correction/assist.dart'; |
| 9 import 'package:analysis_server/src/services/index/index.dart'; | 9 import 'package:analysis_server/src/services/index/index.dart'; |
| 10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 var v = <String>[]; | 355 var v = <String>[]; |
| 356 } | 356 } |
| 357 '''); | 357 '''); |
| 358 assertHasAssistAt('v =', AssistKind.ADD_TYPE_ANNOTATION, ''' | 358 assertHasAssistAt('v =', AssistKind.ADD_TYPE_ANNOTATION, ''' |
| 359 main() { | 359 main() { |
| 360 List<String> v = <String>[]; | 360 List<String> v = <String>[]; |
| 361 } | 361 } |
| 362 '''); | 362 '''); |
| 363 } | 363 } |
| 364 | 364 |
| 365 void test_addTypeAnnotation_local_OK_localType() { |
| 366 _indexTestUnit(''' |
| 367 class C {} |
| 368 C f() => null; |
| 369 main() { |
| 370 var x = f(); |
| 371 } |
| 372 '''); |
| 373 assertHasAssistAt('x =', AssistKind.ADD_TYPE_ANNOTATION, ''' |
| 374 class C {} |
| 375 C f() => null; |
| 376 main() { |
| 377 C x = f(); |
| 378 } |
| 379 '''); |
| 380 } |
| 381 |
| 365 void test_addTypeAnnotation_local_OK_onInitializer() { | 382 void test_addTypeAnnotation_local_OK_onInitializer() { |
| 366 _indexTestUnit(''' | 383 _indexTestUnit(''' |
| 367 main() { | 384 main() { |
| 368 var v = 123; | 385 var v = 123; |
| 369 } | 386 } |
| 370 '''); | 387 '''); |
| 371 assertHasAssistAt('23', AssistKind.ADD_TYPE_ANNOTATION, ''' | 388 assertHasAssistAt('23', AssistKind.ADD_TYPE_ANNOTATION, ''' |
| 372 main() { | 389 main() { |
| 373 int v = 123; | 390 int v = 123; |
| 374 } | 391 } |
| (...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2566 void _indexTestUnit(String code) { | 2583 void _indexTestUnit(String code) { |
| 2567 resolveTestUnit(code); | 2584 resolveTestUnit(code); |
| 2568 index.indexUnit(context, testUnit); | 2585 index.indexUnit(context, testUnit); |
| 2569 } | 2586 } |
| 2570 | 2587 |
| 2571 void _setStartEndSelection() { | 2588 void _setStartEndSelection() { |
| 2572 offset = findOffset('// start\n') + '// start\n'.length; | 2589 offset = findOffset('// start\n') + '// start\n'.length; |
| 2573 length = findOffset('// end') - offset; | 2590 length = findOffset('// end') - offset; |
| 2574 } | 2591 } |
| 2575 } | 2592 } |
| OLD | NEW |