Add fix-all in file fixes for the 2 additional dart analysis server fix types: USE_NOT_EQ_NULL and USE_EQ_EQ_NULL
Change-Id: Ic8da1d1737145dbd3ddbf5939c327f882a74be24
Reviewed-on: https://dart-review.googlesource.com/57680
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index 0ac9e66..769d2ca 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -250,12 +250,16 @@
'USE_EFFECTIVE_INTEGER_DIVISION',
50,
"Use effective integer division ~/");
- static const USE_EQ_EQ_NULL =
- const FixKind('USE_EQ_EQ_NULL', 50, "Use == null instead of 'is Null'");
+ static const USE_EQ_EQ_NULL = const FixKind(
+ 'USE_EQ_EQ_NULL', 50, "Use == null instead of 'is Null'",
+ appliedTogetherMessage:
+ "Use == null instead of 'is Null' everywhere in file");
static const USE_IS_NOT_EMPTY = const FixKind(
'USE_NOT_EMPTY', 50, "Use x.isNotEmpty instead of '!x.isEmpty'");
- static const USE_NOT_EQ_NULL =
- const FixKind('USE_NOT_EQ_NULL', 50, "Use != null instead of 'is! Null'");
+ static const USE_NOT_EQ_NULL = const FixKind(
+ 'USE_NOT_EQ_NULL', 50, "Use != null instead of 'is! Null'",
+ appliedTogetherMessage:
+ "Use != null instead of 'is! Null' everywhere in file");
}
/**
diff --git a/pkg/analysis_server/test/services/correction/fix_test.dart b/pkg/analysis_server/test/services/correction/fix_test.dart
index 81190c0..2a4974a 100644
--- a/pkg/analysis_server/test/services/correction/fix_test.dart
+++ b/pkg/analysis_server/test/services/correction/fix_test.dart
@@ -5136,6 +5136,22 @@
''');
}
+ test_isNotNull_all() async {
+ await resolveTestUnit('''
+main(p, q) {
+ p is! Null;
+ q is! Null;
+}
+''');
+ await assertHasFixAllFix(
+ HintCode.TYPE_CHECK_IS_NOT_NULL, DartFixKind.USE_NOT_EQ_NULL, '''
+main(p, q) {
+ p != null;
+ q != null;
+}
+''');
+ }
+
test_isNull() async {
await resolveTestUnit('''
main(p) {
@@ -5149,6 +5165,22 @@
''');
}
+ test_isNull_all() async {
+ await resolveTestUnit('''
+main(p, q) {
+ p is Null;
+ q is Null;
+}
+''');
+ await assertHasFixAllFix(
+ HintCode.TYPE_CHECK_IS_NULL, DartFixKind.USE_EQ_EQ_NULL, '''
+main(p, q) {
+ p == null;
+ q == null;
+}
+''');
+ }
+
test_makeEnclosingClassAbstract_declaresAbstractMethod() async {
await resolveTestUnit('''
class A {