| 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'; |
| 11 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 11 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 12 import 'package:unittest/unittest.dart'; |
| 13 |
| 12 import '../../abstract_single_unit.dart'; | 14 import '../../abstract_single_unit.dart'; |
| 13 import '../../reflective_tests.dart'; | 15 import '../../reflective_tests.dart'; |
| 14 import 'package:unittest/unittest.dart'; | |
| 15 | 16 |
| 16 | 17 |
| 17 main() { | 18 main() { |
| 18 groupSep = ' | '; | 19 groupSep = ' | '; |
| 19 runReflectiveTests(AssistProcessorTest); | 20 runReflectiveTests(AssistProcessorTest); |
| 20 } | 21 } |
| 21 | 22 |
| 22 | 23 |
| 23 @ReflectiveTestCase() | 24 @ReflectiveTestCase() |
| 24 class AssistProcessorTest extends AbstractSingleUnitTest { | 25 class AssistProcessorTest extends AbstractSingleUnitTest { |
| (...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 '''); | 1707 '''); |
| 1707 } | 1708 } |
| 1708 | 1709 |
| 1709 void test_replaceConditionalWithIfElse_wrong_noEnclosingStatement() { | 1710 void test_replaceConditionalWithIfElse_wrong_noEnclosingStatement() { |
| 1710 _indexTestUnit(''' | 1711 _indexTestUnit(''' |
| 1711 var v = true ? 111 : 222; | 1712 var v = true ? 111 : 222; |
| 1712 '''); | 1713 '''); |
| 1713 assertNoAssistAt('? 111', AssistKind.REPLACE_CONDITIONAL_WITH_IF_ELSE); | 1714 assertNoAssistAt('? 111', AssistKind.REPLACE_CONDITIONAL_WITH_IF_ELSE); |
| 1714 } | 1715 } |
| 1715 | 1716 |
| 1717 void test_replaceConditionalWithIfElse_wrong_notConditional() { |
| 1718 _indexTestUnit(''' |
| 1719 main() { |
| 1720 var v = 42; |
| 1721 } |
| 1722 '''); |
| 1723 assertNoAssistAt('v = 42', AssistKind.REPLACE_CONDITIONAL_WITH_IF_ELSE); |
| 1724 } |
| 1725 |
| 1716 void test_replaceIfElseWithConditional_OK_assignment() { | 1726 void test_replaceIfElseWithConditional_OK_assignment() { |
| 1717 _indexTestUnit(''' | 1727 _indexTestUnit(''' |
| 1718 main() { | 1728 main() { |
| 1719 int vvv; | 1729 int vvv; |
| 1720 if (true) { | 1730 if (true) { |
| 1721 vvv = 111; | 1731 vvv = 111; |
| 1722 } else { | 1732 } else { |
| 1723 vvv = 222; | 1733 vvv = 222; |
| 1724 } | 1734 } |
| 1725 } | 1735 } |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 void _indexTestUnit(String code) { | 2218 void _indexTestUnit(String code) { |
| 2209 resolveTestUnit(code); | 2219 resolveTestUnit(code); |
| 2210 index.indexUnit(context, testUnit); | 2220 index.indexUnit(context, testUnit); |
| 2211 } | 2221 } |
| 2212 | 2222 |
| 2213 void _setStartEndSelection() { | 2223 void _setStartEndSelection() { |
| 2214 offset = findOffset('// start\n') + '// start\n'.length; | 2224 offset = findOffset('// start\n') + '// start\n'.length; |
| 2215 length = findOffset('// end') - offset; | 2225 length = findOffset('// end') - offset; |
| 2216 } | 2226 } |
| 2217 } | 2227 } |
| OLD | NEW |