mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 22:01:19 +00:00
bulk fix for sort_child_properties_last
Change-Id: If340bb29892eded3801801bf5e97794b45eae321 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161624 Commit-Queue: Phil Quitslund <pquitslund@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
8ccdb9ae79
commit
910d1d7e05
|
@ -44,6 +44,7 @@ import 'package:analysis_server/src/services/correction/dart/replace_with_condit
|
|||
import 'package:analysis_server/src/services/correction/dart/replace_with_is_empty.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/replace_with_tear_off.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/replace_with_var.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/sort_child_property_last.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/use_curly_braces.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/use_is_not_empty.dart';
|
||||
import 'package:analysis_server/src/services/correction/dart/use_rethrow.dart';
|
||||
|
@ -103,6 +104,7 @@ class BulkFixProcessor {
|
|||
LintNames.prefer_single_quotes: ConvertToSingleQuotes.newInstance,
|
||||
LintNames.prefer_spread_collections: ConvertAddAllToSpread.newInstance,
|
||||
LintNames.slash_for_doc_comments: ConvertDocumentationIntoLine.newInstance,
|
||||
LintNames.sort_child_properties_last: SortChildPropertyLast.newInstance,
|
||||
LintNames.type_init_formals: RemoveTypeAnnotation.newInstance,
|
||||
LintNames.unawaited_futures: AddAwait.newInstance,
|
||||
LintNames.unnecessary_brace_in_string_interps:
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
// 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(SortChildPropertyLastTest);
|
||||
});
|
||||
}
|
||||
|
||||
@reflectiveTest
|
||||
class SortChildPropertyLastTest extends BulkFixProcessorTest {
|
||||
@override
|
||||
String get lintCode => LintNames.sort_child_properties_last;
|
||||
|
||||
Future<void> test_singleFile() async {
|
||||
addFlutterPackage();
|
||||
await resolveTestUnit('''
|
||||
import 'package:flutter/material.dart';
|
||||
main() {
|
||||
Column(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Text('a'),
|
||||
],
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
),
|
||||
Text('b'),
|
||||
Text('c'),
|
||||
Text('d'),
|
||||
],
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
);
|
||||
}
|
||||
''');
|
||||
// todo (pq): two diagnostics are produced but only the first is fixed.
|
||||
// see: linter/test/rules/sort_child_properties_last.dart:nestedChildren()
|
||||
await assertHasFix('''
|
||||
import 'package:flutter/material.dart';
|
||||
main() {
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Text('a'),
|
||||
],
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
),
|
||||
Text('b'),
|
||||
Text('c'),
|
||||
Text('d'),
|
||||
],
|
||||
);
|
||||
}
|
||||
''');
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@ import 'replace_with_conditional_assignment_test.dart'
|
|||
import 'replace_with_is_empty_test.dart' as replace_with_is_empty;
|
||||
import 'replace_with_tear_off_test.dart' as replace_with_tear_off;
|
||||
import 'replace_with_var_test.dart' as replace_with_var;
|
||||
import 'sort_child_properties_last.dart' as sort_child_properties_last;
|
||||
import 'use_curly_braces_test.dart' as use_curly_braces;
|
||||
import 'use_is_not_empty_test.dart' as use_is_not_empty;
|
||||
import 'use_rethrow_test.dart' as use_rethrow;
|
||||
|
@ -88,6 +89,7 @@ void main() {
|
|||
replace_with_is_empty.main();
|
||||
replace_with_tear_off.main();
|
||||
replace_with_var.main();
|
||||
sort_child_properties_last.main();
|
||||
use_curly_braces.main();
|
||||
use_is_not_empty.main();
|
||||
use_rethrow.main();
|
||||
|
|
Loading…
Reference in a new issue