@@ -11,54 +11,38 @@ class PreferMatchFileNameVisitor extends RecursiveAstVisitor<void> {
1111
1212 /// Iterable that contains the name of entity (or entities) that should
1313 /// be ignored
14- final ExcludedEntitiesListParameters excludedEntities;
14+ final ExcludedEntitiesListParameter excludedEntities;
1515
1616 /// Constructor of [PreferMatchFileNameVisitor] class
1717 PreferMatchFileNameVisitor ({
1818 required this .excludedEntities,
1919 });
2020
2121 /// List of all declarations
22- Iterable <DeclarationTokenInfo > get declarations => _declarations
23- ..sort (
24- // partition into public and private
25- // put public ones first
26- // each partition sorted by declaration order
27- (a, b) => _publicDeclarationsFirst (a, b) ?? _byDeclarationOrder (a, b),
28- );
29-
30- // bool _shouldIgnore(Declaration node) {
31- // if (excludedEntities.isEmpty) return false;
32- //
33- // if (node is ClassDeclaration && excludedEntities.contains('class')) {
34- // return true;
35- // } else if (node is MixinDeclaration && excludedEntities.contains('mixin')) {
36- // return true;
37- // } else if (node is EnumDeclaration && excludedEntities.contains('enum')) {
38- // return true;
39- // } else if (node is ExtensionDeclaration &&
40- // excludedEntities.contains('extension')) {
41- // return true;
42- // }
43- //
44- // return false;
45- // }
22+ Iterable <DeclarationTokenInfo > get declarations => _declarations.where (
23+ (declaration) {
24+ if (declaration.parent is Declaration ) {
25+ return ! excludedEntities
26+ .shouldIgnoreEntity (declaration.parent as Declaration );
27+ }
28+ return true ;
29+ },
30+ ).toList ()
31+ ..sort (
32+ (a, b) => _publicDeclarationsFirst (a, b) ?? _byDeclarationOrder (a, b),
33+ );
4634
4735 @override
4836 void visitClassDeclaration (ClassDeclaration node) {
4937 super .visitClassDeclaration (node);
5038
51- if (excludedEntities.shouldIgnoreEntity (node)) return ;
52-
5339 _declarations.add ((token: node.name, parent: node));
5440 }
5541
5642 @override
5743 void visitExtensionDeclaration (ExtensionDeclaration node) {
5844 super .visitExtensionDeclaration (node);
5945
60- if (excludedEntities.shouldIgnoreEntity (node)) return ;
61-
6246 final name = node.name;
6347 if (name != null ) {
6448 _declarations.add ((token: name, parent: node));
@@ -69,17 +53,13 @@ class PreferMatchFileNameVisitor extends RecursiveAstVisitor<void> {
6953 void visitMixinDeclaration (MixinDeclaration node) {
7054 super .visitMixinDeclaration (node);
7155
72- if (excludedEntities.shouldIgnoreEntity (node)) return ;
73-
7456 _declarations.add ((token: node.name, parent: node));
7557 }
7658
7759 @override
7860 void visitEnumDeclaration (EnumDeclaration node) {
7961 super .visitEnumDeclaration (node);
8062
81- if (excludedEntities.shouldIgnoreEntity (node)) return ;
82-
8363 _declarations.add ((token: node.name, parent: node));
8464 }
8565
0 commit comments