| 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.fix; | 5 library test.services.correction.fix; |
| 6 | 6 |
| 7 import 'package:analysis_server/edit/fix/fix_core.dart'; | 7 import 'package:analysis_server/edit/fix/fix_core.dart'; |
| 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; | 8 import 'package:analysis_server/src/protocol.dart' hide AnalysisError; |
| 9 import 'package:analysis_server/src/services/correction/fix.dart'; | 9 import 'package:analysis_server/src/services/correction/fix.dart'; |
| 10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; | 10 import 'package:analysis_server/src/services/correction/fix_internal.dart'; |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 assertHasFix(DartFixKind.ADD_FIELD_FORMAL_PARAMETERS, ''' | 155 assertHasFix(DartFixKind.ADD_FIELD_FORMAL_PARAMETERS, ''' |
| 156 class Test { | 156 class Test { |
| 157 final int a; | 157 final int a; |
| 158 final int b; | 158 final int b; |
| 159 final int c; | 159 final int c; |
| 160 Test(this.a, this.b, [this.c]); | 160 Test(this.a, this.b, [this.c]); |
| 161 } | 161 } |
| 162 '''); | 162 '''); |
| 163 } | 163 } |
| 164 | 164 |
| 165 void test_addPartOfDirective() { |
| 166 String partCode = r''' |
| 167 // Comment first. |
| 168 // Comment second. |
| 169 |
| 170 class A {} |
| 171 '''; |
| 172 addSource('/part.dart', partCode); |
| 173 resolveTestUnit(''' |
| 174 library my.lib; |
| 175 part 'part.dart'; |
| 176 '''); |
| 177 AnalysisError error = _findErrorToFix(); |
| 178 fix = _assertHasFix(DartFixKind.ADD_PART_OF, error); |
| 179 change = fix.change; |
| 180 // apply to "file" |
| 181 List<SourceFileEdit> fileEdits = change.edits; |
| 182 expect(fileEdits, hasLength(1)); |
| 183 SourceFileEdit fileEdit = change.edits[0]; |
| 184 expect(fileEdit.file, '/part.dart'); |
| 185 expect(SourceEdit.applySequence(partCode, fileEdit.edits), r''' |
| 186 // Comment first. |
| 187 // Comment second. |
| 188 |
| 189 part of my.lib; |
| 190 |
| 191 class A {} |
| 192 '''); |
| 193 } |
| 194 |
| 165 void test_addSync_BAD_nullFunctionBody() { | 195 void test_addSync_BAD_nullFunctionBody() { |
| 166 resolveTestUnit(''' | 196 resolveTestUnit(''' |
| 167 var F = await; | 197 var F = await; |
| 168 '''); | 198 '''); |
| 169 assertNoFix(DartFixKind.ADD_ASYNC); | 199 assertNoFix(DartFixKind.ADD_ASYNC); |
| 170 } | 200 } |
| 171 | 201 |
| 172 void test_addSync_blockFunctionBody() { | 202 void test_addSync_blockFunctionBody() { |
| 173 resolveTestUnit(''' | 203 resolveTestUnit(''' |
| 174 foo() {} | 204 foo() {} |
| (...skipping 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3674 | 3704 |
| 3675 List<Position> _findResultPositions(List<String> searchStrings) { | 3705 List<Position> _findResultPositions(List<String> searchStrings) { |
| 3676 List<Position> positions = <Position>[]; | 3706 List<Position> positions = <Position>[]; |
| 3677 for (String search in searchStrings) { | 3707 for (String search in searchStrings) { |
| 3678 int offset = resultCode.indexOf(search); | 3708 int offset = resultCode.indexOf(search); |
| 3679 positions.add(new Position(testFile, offset)); | 3709 positions.add(new Position(testFile, offset)); |
| 3680 } | 3710 } |
| 3681 return positions; | 3711 return positions; |
| 3682 } | 3712 } |
| 3683 } | 3713 } |
| OLD | NEW |