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

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

Issue 2998703002: Handle creation of class members in files other than the file containing the error (issue 30327) (Closed)
Patch Set: Created 3 years, 4 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 8f3d30effc84565a00271d856921811798fcc27f..28b95c4033dff7630dc5fe77336d77b16917d4a0 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -85,11 +85,13 @@ bool test() {
List<SourceFileEdit> fileEdits = change.edits;
expect(fileEdits, hasLength(1));
+ String fileContent = testCode;
if (target != null) {
expect(target, fileEdits.first.file);
+ fileContent = provider.getFile(target).readAsStringSync();
}
- resultCode = SourceEdit.applySequence(testCode, change.edits[0].edits);
+ resultCode = SourceEdit.applySequence(fileContent, change.edits[0].edits);
// verify
expect(resultCode, expected);
}
@@ -1630,6 +1632,39 @@ main(A a) {
''');
}
+ test_createField_getter_qualified_instance_differentLibrary() async {
scheglov 2017/08/09 15:52:07 There were two changes - for fields and for getter
Brian Wilkerson 2017/08/09 15:56:33 Not the way the code is currently written, but I'v
+ addSource('/other.dart', '''
+/**
+ * A comment to push the offset of the braces for the following class
+ * declaration past the end of the content of the test file. Used to catch an
+ * index out of bounds exception that occurs when using the test source instead
+ * of the target source to compute the location at which to insert the field.
+ */
+class A {
+}
+''');
+ await resolveTestUnit('''
+import 'other.dart';
+main(A a) {
+ int v = a.test;
+}
+''');
+ await assertHasFix(
+ DartFixKind.CREATE_FIELD,
+ '''
+/**
+ * A comment to push the offset of the braces for the following class
+ * declaration past the end of the content of the test file. Used to catch an
+ * index out of bounds exception that occurs when using the test source instead
+ * of the target source to compute the location at which to insert the field.
+ */
+class A {
+ int test;
+}
+''',
+ target: '/other.dart');
+ }
+
test_createField_getter_qualified_instance_dynamicType() async {
await resolveTestUnit('''
class A {
« 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