| 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/services/correction/assist.dart'; | 7 import 'package:analysis_server/src/services/correction/assist.dart'; |
| 8 import 'package:analysis_server/src/services/correction/change.dart'; | 8 import 'package:analysis_server/src/services/correction/change.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 25 matching lines...) Expand all Loading... |
| 36 /** | 36 /** |
| 37 * Asserts that there is an [Assist] of the given [kind] at [offset] which | 37 * Asserts that there is an [Assist] of the given [kind] at [offset] which |
| 38 * produces the [expected] code when applied to [testCode]. | 38 * produces the [expected] code when applied to [testCode]. |
| 39 */ | 39 */ |
| 40 void assertHasAssist(AssistKind kind, String expected) { | 40 void assertHasAssist(AssistKind kind, String expected) { |
| 41 assist = _assertHasAssist(kind); | 41 assist = _assertHasAssist(kind); |
| 42 change = assist.change; | 42 change = assist.change; |
| 43 // apply to "file" | 43 // apply to "file" |
| 44 List<FileEdit> fileEdits = change.fileEdits; | 44 List<FileEdit> fileEdits = change.fileEdits; |
| 45 expect(fileEdits, hasLength(1)); | 45 expect(fileEdits, hasLength(1)); |
| 46 resultCode = Edit.applySequence(testCode, change.fileEdits[0].edits); | 46 resultCode = applySequence(testCode, change.fileEdits[0].edits); |
| 47 // verify | 47 // verify |
| 48 expect(resultCode, expected); | 48 expect(resultCode, expected); |
| 49 } | 49 } |
| 50 | 50 |
| 51 /** | 51 /** |
| 52 * Calls [assertHasAssist] at the offset of [offsetSearch] in [testCode]. | 52 * Calls [assertHasAssist] at the offset of [offsetSearch] in [testCode]. |
| 53 */ | 53 */ |
| 54 void assertHasAssistAt(String offsetSearch, AssistKind kind, | 54 void assertHasAssistAt(String offsetSearch, AssistKind kind, |
| 55 String expected) { | 55 String expected) { |
| 56 offset = findOffset(offsetSearch); | 56 offset = findOffset(offsetSearch); |
| (...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 void _indexTestUnit(String code) { | 2238 void _indexTestUnit(String code) { |
| 2239 resolveTestUnit(code); | 2239 resolveTestUnit(code); |
| 2240 index.indexUnit(context, testUnit); | 2240 index.indexUnit(context, testUnit); |
| 2241 } | 2241 } |
| 2242 | 2242 |
| 2243 void _setStartEndSelection() { | 2243 void _setStartEndSelection() { |
| 2244 offset = findOffset('// start\n') + '// start\n'.length; | 2244 offset = findOffset('// start\n') + '// start\n'.length; |
| 2245 length = findOffset('// end') - offset; | 2245 length = findOffset('// end') - offset; |
| 2246 } | 2246 } |
| 2247 } | 2247 } |
| OLD | NEW |