| 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/protocol2.dart' show SourceEdit; |
| 7 import 'package:analysis_server/src/services/correction/assist.dart'; | 8 import 'package:analysis_server/src/services/correction/assist.dart'; |
| 8 import 'package:analysis_server/src/services/correction/change.dart'; | 9 import 'package:analysis_server/src/services/correction/change.dart'; |
| 9 import 'package:analysis_server/src/services/index/index.dart'; | 10 import 'package:analysis_server/src/services/index/index.dart'; |
| 10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 11 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 11 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; | 12 import 'package:analysis_server/src/services/search/search_engine_internal.dart'
; |
| 12 import 'package:analysis_testing/abstract_single_unit.dart'; | 13 import 'package:analysis_testing/abstract_single_unit.dart'; |
| 13 import 'package:analysis_testing/reflective_tests.dart'; | 14 import 'package:analysis_testing/reflective_tests.dart'; |
| 14 import 'package:unittest/unittest.dart'; | 15 import 'package:unittest/unittest.dart'; |
| 15 | 16 |
| 16 | 17 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 36 /** | 37 /** |
| 37 * Asserts that there is an [Assist] of the given [kind] at [offset] which | 38 * Asserts that there is an [Assist] of the given [kind] at [offset] which |
| 38 * produces the [expected] code when applied to [testCode]. | 39 * produces the [expected] code when applied to [testCode]. |
| 39 */ | 40 */ |
| 40 void assertHasAssist(AssistKind kind, String expected) { | 41 void assertHasAssist(AssistKind kind, String expected) { |
| 41 assist = _assertHasAssist(kind); | 42 assist = _assertHasAssist(kind); |
| 42 change = assist.change; | 43 change = assist.change; |
| 43 // apply to "file" | 44 // apply to "file" |
| 44 List<FileEdit> fileEdits = change.fileEdits; | 45 List<FileEdit> fileEdits = change.fileEdits; |
| 45 expect(fileEdits, hasLength(1)); | 46 expect(fileEdits, hasLength(1)); |
| 46 resultCode = applySequence(testCode, change.fileEdits[0].edits); | 47 resultCode = SourceEdit.applySequence(testCode, change.fileEdits[0].edits); |
| 47 // verify | 48 // verify |
| 48 expect(resultCode, expected); | 49 expect(resultCode, expected); |
| 49 } | 50 } |
| 50 | 51 |
| 51 /** | 52 /** |
| 52 * Calls [assertHasAssist] at the offset of [offsetSearch] in [testCode]. | 53 * Calls [assertHasAssist] at the offset of [offsetSearch] in [testCode]. |
| 53 */ | 54 */ |
| 54 void assertHasAssistAt(String offsetSearch, AssistKind kind, | 55 void assertHasAssistAt(String offsetSearch, AssistKind kind, |
| 55 String expected) { | 56 String expected) { |
| 56 offset = findOffset(offsetSearch); | 57 offset = findOffset(offsetSearch); |
| (...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 void _indexTestUnit(String code) { | 2209 void _indexTestUnit(String code) { |
| 2209 resolveTestUnit(code); | 2210 resolveTestUnit(code); |
| 2210 index.indexUnit(context, testUnit); | 2211 index.indexUnit(context, testUnit); |
| 2211 } | 2212 } |
| 2212 | 2213 |
| 2213 void _setStartEndSelection() { | 2214 void _setStartEndSelection() { |
| 2214 offset = findOffset('// start\n') + '// start\n'.length; | 2215 offset = findOffset('// start\n') + '// start\n'.length; |
| 2215 length = findOffset('// end') - offset; | 2216 length = findOffset('// end') - offset; |
| 2216 } | 2217 } |
| 2217 } | 2218 } |
| OLD | NEW |