mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 01:45:06 +00:00
bulk fix for unnecessary_this
Change-Id: I61c0173c8fb1fd02d6119412bf925d08126a7a0b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157822 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
09ddcece30
commit
06cce87374
|
@ -26,6 +26,7 @@ import 'package:analysis_server/src/services/correction/dart/remove_empty_statem
|
|||
import 'package:analysis_server/src/services/correction/dart/remove_initializer.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/remove_method_declaration.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/remove_operator.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/remove_this_expression.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/remove_type_annotation.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/remove_unnecessary_new.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/replace_cascade_with_dot.dart';
|
||||
|
@ -88,6 +89,7 @@ class BulkFixProcessor {
|
|||
LintNames.unnecessary_lambdas: ReplaceWithTearOff.newInstance,
|
||||
LintNames.unnecessary_new: RemoveUnnecessaryNew.newInstance,
|
||||
LintNames.unnecessary_overrides: RemoveMethodDeclaration.newInstance,
|
||||
LintNames.unnecessary_this: RemoveThisExpression.newInstance,
|
||||
};
|
||||
|
||||
/// A map from an error code to a generator used to create the correction
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analysis_server/src/services/linter/lint_names.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
import 'bulk_fix_processor.dart';
|
||||
|
||||
void main() {
|
||||
defineReflectiveSuite(() {
|
||||
defineReflectiveTests(RemoveThisExpressionTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class RemoveThisExpressionTest extends BulkFixProcessorTest {
|
||||
@override
|
||||
String get lintCode => LintNames.unnecessary_this;
|
||||
|
||||
Future<void> test_singleFile() async {
|
||||
await resolveTestUnit('''
|
||||
class A {
|
||||
int x;
|
||||
A(int x) : this.x = x;
|
||||
void foo() {
|
||||
this.foo();
|
||||
}
|
||||
}
|
||||
''');
|
||||
await assertHasFix('''
|
||||
class A {
|
||||
int x;
|
||||
A(int x) : x = x;
|
||||
void foo() {
|
||||
foo();
|
||||
}
|
||||
}
|
||||
''');
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ import 'remove_empty_statement_test.dart' as remove_empty_statement;
|
|||
import 'remove_initializer_test.dart' as remove_initializer;
|
||||
import 'remove_method_declaration_test.dart' as remove_method_declaration;
|
||||
import 'remove_operator_test.dart' as remove_operator;
|
||||
import 'remove_this_expression_test.dart' as remove_this_expression;
|
||||
import 'remove_type_annotation_test.dart' as remove_type_annotation;
|
||||
import 'remove_unnecessary_const_test.dart' as remove_unnecessary_const;
|
||||
import 'remove_unnecessary_new_test.dart' as remove_unnecessary_new;
|
||||
|
@ -56,6 +57,7 @@ void main() {
|
|||
remove_empty_statement.main();
|
||||
remove_method_declaration.main();
|
||||
remove_operator.main();
|
||||
remove_this_expression.main();
|
||||
remove_type_annotation.main();
|
||||
remove_unnecessary_const.main();
|
||||
remove_unnecessary_new.main();
|
||||
|
|
Loading…
Reference in a new issue