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

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

Issue 1751163002: Fix @override quick-fix to respect doc comments. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 f1bc9986d0cd44e7aba0a359f5b51374c7404959..da08e995a2520b063da670f0ae74b20c2a4e1555 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -5117,6 +5117,116 @@ class Sub extends Test {
''');
}
+ test_lint_addMissingOverride_method_with_doc_comment() async {
+ String src = '''
+class Test {
+ void t() { }
+}
+class Sub extends Test {
+ /// Doc comment.
+ void /*LINT*/t() { }
+}
+''';
+ findLint(src, LintNames.annotate_overrides);
+
+ await applyFix(DartFixKind.LINT_ADD_OVERRIDE);
+
+ verifyResult('''
+class Test {
+ void t() { }
+}
+class Sub extends Test {
+ /// Doc comment.
+ @override
+ void t() { }
+}
+''');
+ }
+
+ test_lint_addMissingOverride_method_with_doc_comment_2() async {
+ String src = '''
+class Test {
+ void t() { }
+}
+class Sub extends Test {
+ /**
+ * Doc comment.
+ */
+ void /*LINT*/t() { }
+}
+''';
+ findLint(src, LintNames.annotate_overrides);
+
+ await applyFix(DartFixKind.LINT_ADD_OVERRIDE);
+
+ verifyResult('''
+class Test {
+ void t() { }
+}
+class Sub extends Test {
+ /**
+ * Doc comment.
+ */
+ @override
+ void t() { }
+}
+''');
+ }
+
+ test_lint_addMissingOverride_method_with_doc_comment_and_metadata() async {
+ String src = '''
+class Test {
+ void t() { }
+}
+class Sub extends Test {
+ /// Doc comment.
+ @foo
+ void /*LINT*/t() { }
+}
+''';
+ findLint(src, LintNames.annotate_overrides);
+
+ await applyFix(DartFixKind.LINT_ADD_OVERRIDE);
+
+ verifyResult('''
+class Test {
+ void t() { }
+}
+class Sub extends Test {
+ /// Doc comment.
+ @override
+ @foo
+ void t() { }
+}
+''');
+ }
+
+ test_lint_addMissingOverride_method_with_non_doc_comment() async {
+ String src = '''
+class Test {
+ void t() { }
+}
+class Sub extends Test {
+ // Non-doc comment.
+ void /*LINT*/t() { }
+}
+''';
+ findLint(src, LintNames.annotate_overrides);
+
+ await applyFix(DartFixKind.LINT_ADD_OVERRIDE);
+
+ verifyResult('''
+class Test {
+ void t() { }
+}
+class Sub extends Test {
+ // Non-doc comment.
+ @override
+ void t() { }
+}
+''');
+ }
+
void verifyResult(String expectedResult) {
expect(resultCode, expectedResult);
}
« 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