Skip to content

Commit 8d8dbfc

Browse files
committed
Add @OverRide bulk-fix
Change-Id: I45da6351fc705ca2d7d6e20b5ef43a6ca9173289 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155828 Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 6fc6c47 commit 8d8dbfc

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'dart:core';
88
import 'package:analysis_server/plugin/edit/fix/fix_dart.dart';
99
import 'package:analysis_server/src/services/correction/change_workspace.dart';
1010
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
11+
import 'package:analysis_server/src/services/correction/dart/add_override.dart';
1112
import 'package:analysis_server/src/services/correction/dart/convert_documentation_into_line.dart';
1213
import 'package:analysis_server/src/services/correction/dart/remove_const.dart';
1314
import 'package:analysis_server/src/services/correction/dart/remove_unnecessary_new.dart';
@@ -27,6 +28,7 @@ class BulkFixProcessor {
2728
/// correction producer used to build a fix for that diagnostic. The
2829
/// generators used for non-lint diagnostics are in the [nonLintProducerMap].
2930
static const Map<String, ProducerGenerator> lintProducerMap = {
31+
LintNames.annotate_overrides: AddOverride.newInstance,
3032
LintNames.avoid_single_cascade_in_expression_statements:
3133
ReplaceCascadeWithDot.newInstance,
3234
LintNames.prefer_equal_for_default_values:
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:analysis_server/src/services/linter/lint_names.dart';
6+
import 'package:test_reflective_loader/test_reflective_loader.dart';
7+
8+
import 'bulk_fix_processor.dart';
9+
10+
void main() {
11+
defineReflectiveSuite(() {
12+
defineReflectiveTests(AddOverrideTest);
13+
});
14+
}
15+
16+
@reflectiveTest
17+
class AddOverrideTest extends BulkFixProcessorTest {
18+
@override
19+
String get lintCode => LintNames.annotate_overrides;
20+
21+
Future<void> test_singleFile() async {
22+
await resolveTestUnit('''
23+
class A {
24+
void a() {}
25+
void aa() {}
26+
}
27+
28+
class B extends A {
29+
void a() {}
30+
void aa() {}
31+
}
32+
''');
33+
await assertHasFix('''
34+
class A {
35+
void a() {}
36+
void aa() {}
37+
}
38+
39+
class B extends A {
40+
@override
41+
void a() {}
42+
@override
43+
void aa() {}
44+
}
45+
''');
46+
}
47+
}

pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:test_reflective_loader/test_reflective_loader.dart';
66

7+
import 'add_override_test.dart' as add_override;
78
import 'convert_documentation_into_line_test.dart'
89
as convert_documentation_into_line;
910
import 'remove_unnecessary_const_test.dart' as remove_unnecessary_const;
@@ -12,6 +13,7 @@ import 'replace_colon_with_equals_test.dart' as replace_colon_with_equals;
1213

1314
void main() {
1415
defineReflectiveSuite(() {
16+
add_override.main();
1517
convert_documentation_into_line.main();
1618
remove_unnecessary_const.main();
1719
remove_unnecessary_new.main();

0 commit comments

Comments
 (0)