getSortedMethods method
Gets the public methods of the class
This method will retrieve the methods of the
super classes when the includeInherited
parameter is true.
It will retrieve non-static methods.
Implementation
Iterable<MethodElement> getSortedMethods({bool includeInherited = true}) {
// Get all of the fields that need to be assigned
final elementInstanceMethods = Map.fromEntries(
this.methods.where((e) => !e.isStatic).map((e) => MapEntry(e.name, e)));
final inheritedMethods = <String, MethodElement>{};
final manager = InheritanceManager3();
if (includeInherited) {
for (final v in manager.getInheritedMap2(this).values) {
assert(v is! FieldElement);
if (_dartCoreObjectChecker.isExactly(v.enclosingElement)) {
continue;
}
if (v is MethodElement && !v.isStatic && !v.isPrivate) {
// assert(v.variable is MethodElement);
// final variable = v.variable as MethodElement;
// assert(!inheritedMethods.containsKey(variable.name));
inheritedMethods[v.name] = v;
}
}
}
// Get the list of all fields for `element`
final allMethods = elementInstanceMethods.keys
.toSet()
.union(inheritedMethods.keys.toSet());
final methods = allMethods
.map((e) => _MethodSet(elementInstanceMethods[e], inheritedMethods[e]))
.toList()
..sort();
return methods.map((fs) => fs.method).toList();
}