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 1060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1071 // validate change | 1071 // validate change |
1072 List<SourceFileEdit> fileEdits = change.edits; | 1072 List<SourceFileEdit> fileEdits = change.edits; |
1073 expect(fileEdits, hasLength(1)); | 1073 expect(fileEdits, hasLength(1)); |
1074 SourceFileEdit fileEdit = change.edits[0]; | 1074 SourceFileEdit fileEdit = change.edits[0]; |
1075 expect(fileEdit.file, '/my/project/bin/my_part.dart'); | 1075 expect(fileEdit.file, '/my/project/bin/my_part.dart'); |
1076 expect(fileEdit.fileStamp, -1); | 1076 expect(fileEdit.fileStamp, -1); |
1077 expect(fileEdit.edits, hasLength(1)); | 1077 expect(fileEdit.edits, hasLength(1)); |
1078 expect(fileEdit.edits[0].replacement, contains('part of my.lib;')); | 1078 expect(fileEdit.edits[0].replacement, contains('part of my.lib;')); |
1079 } | 1079 } |
1080 | 1080 |
| 1081 void test_createFile_forPart_inPackageLib() { |
| 1082 provider.newFile('/my/pubspec.yaml', r''' |
| 1083 name: my_test |
| 1084 '''); |
| 1085 testFile = '/my/lib/test.dart'; |
| 1086 addTestSource(''' |
| 1087 library my.lib; |
| 1088 part 'my_part.dart'; |
| 1089 ''', Uri.parse('package:my/test.dart')); |
| 1090 // configure SourceFactory |
| 1091 UriResolver pkgResolver = new PackageMapUriResolver( |
| 1092 provider, {'my': [provider.getResource('/my/lib')],}); |
| 1093 context.sourceFactory = new SourceFactory( |
| 1094 [AbstractContextTest.SDK_RESOLVER, pkgResolver, resourceResolver]); |
| 1095 // prepare fix |
| 1096 testUnit = resolveLibraryUnit(testSource); |
| 1097 AnalysisError error = _findErrorToFix(); |
| 1098 fix = _assertHasFix(DartFixKind.CREATE_FILE, error); |
| 1099 change = fix.change; |
| 1100 // validate change |
| 1101 List<SourceFileEdit> fileEdits = change.edits; |
| 1102 expect(fileEdits, hasLength(1)); |
| 1103 SourceFileEdit fileEdit = change.edits[0]; |
| 1104 expect(fileEdit.file, '/my/lib/my_part.dart'); |
| 1105 expect(fileEdit.fileStamp, -1); |
| 1106 expect(fileEdit.edits, hasLength(1)); |
| 1107 expect(fileEdit.edits[0].replacement, contains('part of my.lib;')); |
| 1108 } |
| 1109 |
1081 void test_createGetter_BAD_inSDK() { | 1110 void test_createGetter_BAD_inSDK() { |
1082 resolveTestUnit(''' | 1111 resolveTestUnit(''' |
1083 main(List p) { | 1112 main(List p) { |
1084 int v = p.foo; | 1113 int v = p.foo; |
1085 } | 1114 } |
1086 '''); | 1115 '''); |
1087 assertNoFix(DartFixKind.CREATE_GETTER); | 1116 assertNoFix(DartFixKind.CREATE_GETTER); |
1088 } | 1117 } |
1089 | 1118 |
1090 void test_createGetter_hint_getter() { | 1119 void test_createGetter_hint_getter() { |
(...skipping 2554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3645 | 3674 |
3646 List<Position> _findResultPositions(List<String> searchStrings) { | 3675 List<Position> _findResultPositions(List<String> searchStrings) { |
3647 List<Position> positions = <Position>[]; | 3676 List<Position> positions = <Position>[]; |
3648 for (String search in searchStrings) { | 3677 for (String search in searchStrings) { |
3649 int offset = resultCode.indexOf(search); | 3678 int offset = resultCode.indexOf(search); |
3650 positions.add(new Position(testFile, offset)); | 3679 positions.add(new Position(testFile, offset)); |
3651 } | 3680 } |
3652 return positions; | 3681 return positions; |
3653 } | 3682 } |
3654 } | 3683 } |
OLD | NEW |