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

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

Issue 1375043004: Issue 24459. Fix for 'Create Method' QF in different unit. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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 393c2f37b0d34688afd5fa82db7ea5014f94de0a..e501b42f5b67763806c300eac88ed3d603139ab9 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -4173,6 +4173,84 @@ main() {
''');
}
+ void test_undefinedMethod_parameterType_differentPrefixInTargetUnit() {
+ String code2 = r'''
+library test2;
+import 'test3.dart' as bbb;
+export 'test3.dart';
+class D {
+}
+''';
+ addSource('/test2.dart', code2);
+ addSource(
+ '/test3.dart',
+ r'''
+library test3;
+class E {}
+''');
+ resolveTestUnit('''
+library test;
+import 'test2.dart' as aaa;
+main(aaa.D d, aaa.E e) {
+ d.foo(e);
+}
+''');
+ AnalysisError error = _findErrorToFix();
+ fix = _assertHasFix(DartFixKind.CREATE_METHOD, error);
+ change = fix.change;
+ // apply to "test2.dart"
+ List<SourceFileEdit> fileEdits = change.edits;
+ expect(fileEdits, hasLength(1));
+ SourceFileEdit fileEdit = change.edits[0];
+ expect(fileEdit.file, '/test2.dart');
+ expect(
+ SourceEdit.applySequence(code2, fileEdit.edits),
+ r'''
+library test2;
+import 'test3.dart' as bbb;
+export 'test3.dart';
+class D {
+ void foo(bbb.E e) {
+ }
+}
+''');
+ }
+
+ void test_undefinedMethod_parameterType_inTargetUnit() {
+ String code2 = r'''
+library test2;
+class D {
+}
+class E {}
+''';
+ addSource('/test2.dart', code2);
+ resolveTestUnit('''
+library test;
+import 'test2.dart' as test2;
+main(test2.D d, test2.E e) {
+ d.foo(e);
+}
+''');
+ AnalysisError error = _findErrorToFix();
+ fix = _assertHasFix(DartFixKind.CREATE_METHOD, error);
+ change = fix.change;
+ // apply to "test2.dart"
+ List<SourceFileEdit> fileEdits = change.edits;
+ expect(fileEdits, hasLength(1));
+ SourceFileEdit fileEdit = change.edits[0];
+ expect(fileEdit.file, '/test2.dart');
+ expect(
+ SourceEdit.applySequence(code2, fileEdit.edits),
+ r'''
+library test2;
+class D {
+ void foo(E e) {
+ }
+}
+class E {}
+''');
+ }
+
void test_undefinedMethod_useSimilar_ignoreOperators() {
resolveTestUnit('''
main(Object object) {

Powered by Google App Engine
This is Rietveld 408576698