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

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

Issue 2749373002: Correct target of ADD_MISSING_REQUIRED_ARGUMENT fixes (flutter-intellij#788) (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ecbd8803191473ccc177c3bb7f5e759350f43c3f..6c414641ad23e70cca3c70d701048969199727ca 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -77,13 +77,19 @@ bool test() {
''');
}
- assertHasFix(FixKind kind, String expected) async {
+ assertHasFix(FixKind kind, String expected, {String target}) async {
AnalysisError error = await _findErrorToFix();
fix = await _assertHasFix(kind, error);
change = fix.change;
+
// apply to "file"
List<SourceFileEdit> fileEdits = change.edits;
expect(fileEdits, hasLength(1));
+
+ if (target != null) {
+ expect(target, fileEdits.first.file);
+ }
+
resultCode = SourceEdit.applySequence(testCode, change.edits[0].edits);
// verify
expect(resultCode, expected);
@@ -429,13 +435,20 @@ class A {
test_addMissingRequiredArg_cons_single() async {
_addMetaPackageSource();
-
- await resolveTestUnit('''
+ addSource(
+ '/libA.dart',
+ r'''
+library libA;
import 'package:meta/meta.dart';
class A {
A({@required int a}) {}
}
+''');
+
+ await resolveTestUnit('''
+import 'libA.dart';
+
main() {
A a = new A();
}
@@ -443,15 +456,13 @@ main() {
await assertHasFix(
DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT,
'''
-import 'package:meta/meta.dart';
+import 'libA.dart';
-class A {
- A({@required int a}) {}
-}
main() {
A a = new A(a: null);
}
-''');
+''',
+ target: '/test.dart');
}
test_addMissingRequiredArg_multiple() async {
« no previous file with comments | « pkg/analysis_server/lib/src/services/correction/fix_internal.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698