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