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

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

Issue 1146573003: Quick Fix for missing 'part of' directive. (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 efb89746defa688a896464c7a71373ccc647a84b..5a6c3c0967501d0ca89f7de77f49c23a39a0b290 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -162,6 +162,36 @@ class Test {
''');
}
+ void test_addPartOfDirective() {
+ String partCode = r'''
+// Comment first.
+// Comment second.
+
+class A {}
+''';
+ addSource('/part.dart', partCode);
+ resolveTestUnit('''
+library my.lib;
+part 'part.dart';
+''');
+ AnalysisError error = _findErrorToFix();
+ fix = _assertHasFix(DartFixKind.ADD_PART_OF, error);
+ change = fix.change;
+ // apply to "file"
+ List<SourceFileEdit> fileEdits = change.edits;
+ expect(fileEdits, hasLength(1));
+ SourceFileEdit fileEdit = change.edits[0];
+ expect(fileEdit.file, '/part.dart');
+ expect(SourceEdit.applySequence(partCode, fileEdit.edits), r'''
+// Comment first.
+// Comment second.
+
+part of my.lib;
+
+class A {}
+''');
+ }
+
void test_addSync_BAD_nullFunctionBody() {
resolveTestUnit('''
var F = await;

Powered by Google App Engine
This is Rietveld 408576698