| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library dart2js.js_emitter.sorter; | 5 library dart2js.js_emitter.sorter; |
| 6 | 6 |
| 7 import '../elements/elements.dart'; | 7 import '../elements/elements.dart'; |
| 8 import '../elements/entities.dart'; | 8 import '../elements/entities.dart'; |
| 9 | 9 |
| 10 /// Sorting strategy for libraries, classes and members. | 10 /// Sorting strategy for libraries, classes and members. |
| 11 abstract class Sorter { | 11 abstract class Sorter { |
| 12 /// Returns a sorted list of [libraries]. | 12 /// Returns a sorted list of [libraries]. |
| 13 Iterable<LibraryEntity> sortLibraries(Iterable<LibraryEntity> libraries); | 13 Iterable<LibraryEntity> sortLibraries(Iterable<LibraryEntity> libraries); |
| 14 | 14 |
| 15 /// Returns a sorted list of [classes]. | 15 /// Returns a sorted list of [classes]. |
| 16 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes); | 16 Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes); |
| 17 | 17 |
| 18 /// Returns a sorted list of [typedefs]. |
| 19 Iterable<TypedefEntity> sortTypedefs(Iterable<TypedefEntity> typedefs); |
| 20 |
| 18 /// Returns a sorted list of [members]. | 21 /// Returns a sorted list of [members]. |
| 19 Iterable<MemberEntity> sortMembers(Iterable<MemberEntity> members); | 22 Iterable<MemberEntity> sortMembers(Iterable<MemberEntity> members); |
| 20 } | 23 } |
| 21 | 24 |
| 22 class ElementSorter implements Sorter { | 25 class ElementSorter implements Sorter { |
| 23 const ElementSorter(); | 26 const ElementSorter(); |
| 24 | 27 |
| 25 @override | 28 @override |
| 26 List<LibraryEntity> sortLibraries(Iterable<LibraryEntity> libraries) { | 29 List<LibraryEntity> sortLibraries(Iterable<LibraryEntity> libraries) { |
| 27 return Elements.sortedByPosition(new List.from(libraries, growable: false)); | 30 return Elements.sortedByPosition(new List.from(libraries, growable: false)); |
| 28 } | 31 } |
| 29 | 32 |
| 30 @override | 33 @override |
| 31 List<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { | 34 List<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { |
| 32 return Elements.sortedByPosition(new List.from(classes, growable: false)); | 35 return Elements.sortedByPosition(new List.from(classes, growable: false)); |
| 33 } | 36 } |
| 34 | 37 |
| 35 @override | 38 @override |
| 39 Iterable<TypedefEntity> sortTypedefs(Iterable<TypedefEntity> typedefs) { |
| 40 return Elements.sortedByPosition(new List.from(typedefs, growable: false)); |
| 41 } |
| 42 |
| 43 @override |
| 36 List<MemberEntity> sortMembers(Iterable<MemberEntity> members) { | 44 List<MemberEntity> sortMembers(Iterable<MemberEntity> members) { |
| 37 return Elements.sortedByPosition(new List.from(members, growable: false)); | 45 return Elements.sortedByPosition(new List.from(members, growable: false)); |
| 38 } | 46 } |
| 39 } | 47 } |
| OLD | NEW |