@@ -17,18 +17,19 @@ class MemberSorter {
1717
1818 final CompilationUnit unit;
1919
20- final CodeStyleOptions codeStyle;
21-
2220 final LineInfo lineInfo;
2321
24- String code ;
22+ final String endOfLine ;
2523
26- String endOfLine = ' \n ' ;
24+ final List < _PriorityItem > _priorityItems ;
2725
28- MemberSorter (this .initialCode, this .unit, this .codeStyle, this .lineInfo)
29- : code = initialCode {
30- endOfLine = getEOL (code);
31- }
26+ String code;
27+
28+ MemberSorter (
29+ this .initialCode, this .unit, CodeStyleOptions codeStyle, this .lineInfo)
30+ : endOfLine = getEOL (initialCode),
31+ code = initialCode,
32+ _priorityItems = _getPriorityItems (codeStyle);
3233
3334 /// Return the [SourceEdit] s that sort [unit] .
3435 List <SourceEdit > sort () {
@@ -48,13 +49,12 @@ class MemberSorter {
4849 }
4950
5051 int _getPriority (_PriorityItem item) {
51- var priorityItems = _getPriorityItems (codeStyle);
52- var priority = priorityItems.indexOf (item);
52+ var priority = _priorityItems.indexOf (item);
5353 return priority != - 1 ? priority : 0 ;
5454 }
5555
5656 List <_MemberInfo > _getSortedMembers (List <_MemberInfo > members) {
57- var membersSorted = List < _MemberInfo >. from (members);
57+ var membersSorted = List . of (members);
5858 membersSorted.sort ((_MemberInfo o1, _MemberInfo o2) {
5959 var priority1 = _getPriority (o1.item);
6060 var priority2 = _getPriority (o2.item);
@@ -302,28 +302,21 @@ class _MemberInfo {
302302 }
303303}
304304
305- class _MemberKind {
306- static const CLASS_ACCESSOR = _MemberKind ('CLASS_ACCESSOR' );
307- static const CLASS_CONSTRUCTOR = _MemberKind ('CLASS_CONSTRUCTOR' );
308- static const CLASS_FIELD = _MemberKind ('CLASS_FIELD' );
309- static const CLASS_METHOD = _MemberKind ('CLASS_METHOD' );
310- static const UNIT_ACCESSOR = _MemberKind ('UNIT_ACCESSOR' );
311- static const UNIT_CLASS = _MemberKind ('UNIT_CLASS' );
312- static const UNIT_EXTENSION = _MemberKind ('UNIT_EXTENSION' );
313- static const UNIT_EXTENSION_TYPE = _MemberKind ('UNIT_EXTENSION_TYPE' );
314- static const UNIT_FUNCTION = _MemberKind ('UNIT_FUNCTION' );
315- static const UNIT_FUNCTION_MAIN = _MemberKind ('UNIT_FUNCTION_MAIN' );
316- static const UNIT_FUNCTION_TYPE = _MemberKind ('UNIT_FUNCTION_TYPE' );
317- static const UNIT_GENERIC_TYPE_ALIAS = _MemberKind ('UNIT_GENERIC_TYPE_ALIAS' );
318- static const UNIT_VARIABLE = _MemberKind ('UNIT_VARIABLE' );
319- static const UNIT_VARIABLE_CONST = _MemberKind ('UNIT_VARIABLE_CONST' );
320-
321- final String name;
322-
323- const _MemberKind (this .name);
324-
325- @override
326- String toString () => name;
305+ enum _MemberKind {
306+ CLASS_ACCESSOR ,
307+ CLASS_CONSTRUCTOR ,
308+ CLASS_FIELD ,
309+ CLASS_METHOD ,
310+ UNIT_ACCESSOR ,
311+ UNIT_CLASS ,
312+ UNIT_EXTENSION ,
313+ UNIT_EXTENSION_TYPE ,
314+ UNIT_FUNCTION ,
315+ UNIT_FUNCTION_MAIN ,
316+ UNIT_FUNCTION_TYPE ,
317+ UNIT_GENERIC_TYPE_ALIAS ,
318+ UNIT_VARIABLE ,
319+ UNIT_VARIABLE_CONST ,
327320}
328321
329322class _PriorityItem {
0 commit comments