| 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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 void test_addTypeAnnotation_local_wrong_unknown() { | 524 void test_addTypeAnnotation_local_wrong_unknown() { |
| 525 verifyNoTestUnitErrors = false; | 525 verifyNoTestUnitErrors = false; |
| 526 _indexTestUnit(''' | 526 _indexTestUnit(''' |
| 527 main() { | 527 main() { |
| 528 var v = unknownVar; | 528 var v = unknownVar; |
| 529 } | 529 } |
| 530 '''); | 530 '''); |
| 531 assertNoAssistAt('var ', AssistKind.ADD_TYPE_ANNOTATION); | 531 assertNoAssistAt('var ', AssistKind.ADD_TYPE_ANNOTATION); |
| 532 } | 532 } |
| 533 | 533 |
| 534 void test_addTypeAnnotation_parameter_BAD_hasExplicitType() { |
| 535 _indexTestUnit(''' |
| 536 foo(f(int p)) {} |
| 537 main() { |
| 538 foo((num test) {}); |
| 539 } |
| 540 '''); |
| 541 assertNoAssistAt('test', AssistKind.ADD_TYPE_ANNOTATION); |
| 542 } |
| 543 |
| 544 void test_addTypeAnnotation_parameter_BAD_noPropagatedType() { |
| 545 _indexTestUnit(''' |
| 546 foo(f(p)) {} |
| 547 main() { |
| 548 foo((test) {}); |
| 549 } |
| 550 '''); |
| 551 assertNoAssistAt('test', AssistKind.ADD_TYPE_ANNOTATION); |
| 552 } |
| 553 |
| 554 void test_addTypeAnnotation_parameter_OK() { |
| 555 _indexTestUnit(''' |
| 556 foo(f(int p)) {} |
| 557 main() { |
| 558 foo((test) {}); |
| 559 } |
| 560 '''); |
| 561 assertHasAssistAt('test', AssistKind.ADD_TYPE_ANNOTATION, ''' |
| 562 foo(f(int p)) {} |
| 563 main() { |
| 564 foo((int test) {}); |
| 565 } |
| 566 '''); |
| 567 } |
| 568 |
| 534 void test_addTypeAnnotation_topLevelField_OK_int() { | 569 void test_addTypeAnnotation_topLevelField_OK_int() { |
| 535 _indexTestUnit(''' | 570 _indexTestUnit(''' |
| 536 var V = 0; | 571 var V = 0; |
| 537 '''); | 572 '''); |
| 538 assertHasAssistAt('var ', AssistKind.ADD_TYPE_ANNOTATION, ''' | 573 assertHasAssistAt('var ', AssistKind.ADD_TYPE_ANNOTATION, ''' |
| 539 int V = 0; | 574 int V = 0; |
| 540 '''); | 575 '''); |
| 541 } | 576 } |
| 542 | 577 |
| 543 void test_addTypeAnnotation_topLevelField_wrong_multiple() { | 578 void test_addTypeAnnotation_topLevelField_wrong_multiple() { |
| (...skipping 2083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2627 void _indexTestUnit(String code) { | 2662 void _indexTestUnit(String code) { |
| 2628 resolveTestUnit(code); | 2663 resolveTestUnit(code); |
| 2629 index.indexUnit(context, testUnit); | 2664 index.indexUnit(context, testUnit); |
| 2630 } | 2665 } |
| 2631 | 2666 |
| 2632 void _setStartEndSelection() { | 2667 void _setStartEndSelection() { |
| 2633 offset = findOffset('// start\n') + '// start\n'.length; | 2668 offset = findOffset('// start\n') + '// start\n'.length; |
| 2634 length = findOffset('// end') - offset; | 2669 length = findOffset('// end') - offset; |
| 2635 } | 2670 } |
| 2636 } | 2671 } |
| OLD | NEW |