diff --git a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart index 8ca05963303..27e41147110 100644 --- a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart +++ b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart @@ -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: diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last.dart new file mode 100644 index 00000000000..80c02dd938f --- /dev/null +++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last.dart @@ -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 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'), + ], + ); +} +'''); + } +} diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart index 009ee476478..36033cfcaa3 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart @@ -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();