Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1914)

Unified Diff: pkg/analysis_server/test/services/correction/fix_test.dart

Issue 1135073004: Fix for 'Create part' Quick Fix. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/services/correction/fix_test.dart
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart
index f09f8c6f74229f3025449a126dcdcf2369c80e6c..efb89746defa688a896464c7a71373ccc647a84b 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -1078,6 +1078,35 @@ part 'my_part.dart';
expect(fileEdit.edits[0].replacement, contains('part of my.lib;'));
}
+ void test_createFile_forPart_inPackageLib() {
+ provider.newFile('/my/pubspec.yaml', r'''
+name: my_test
+''');
+ testFile = '/my/lib/test.dart';
+ addTestSource('''
+library my.lib;
+part 'my_part.dart';
+''', Uri.parse('package:my/test.dart'));
+ // configure SourceFactory
+ UriResolver pkgResolver = new PackageMapUriResolver(
+ provider, {'my': [provider.getResource('/my/lib')],});
+ context.sourceFactory = new SourceFactory(
+ [AbstractContextTest.SDK_RESOLVER, pkgResolver, resourceResolver]);
+ // prepare fix
+ testUnit = resolveLibraryUnit(testSource);
+ AnalysisError error = _findErrorToFix();
+ fix = _assertHasFix(DartFixKind.CREATE_FILE, error);
+ change = fix.change;
+ // validate change
+ List<SourceFileEdit> fileEdits = change.edits;
+ expect(fileEdits, hasLength(1));
+ SourceFileEdit fileEdit = change.edits[0];
+ expect(fileEdit.file, '/my/lib/my_part.dart');
+ expect(fileEdit.fileStamp, -1);
+ expect(fileEdit.edits, hasLength(1));
+ expect(fileEdit.edits[0].replacement, contains('part of my.lib;'));
+ }
+
void test_createGetter_BAD_inSDK() {
resolveTestUnit('''
main(List p) {

Powered by Google App Engine
This is Rietveld 408576698