-
Notifications
You must be signed in to change notification settings - Fork 347
/
recursive_selector.dart
41 lines (35 loc) · 1.35 KB
/
recursive_selector.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2022 Google Inc. Use of this source code is governed by an
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
import '../ast/selector.dart';
import '../util/nullable.dart';
import 'interface/selector.dart';
/// A visitor that recursively traverses each component of a Selector AST.
///
/// {@category Visitor}
mixin RecursiveSelectorVisitor implements SelectorVisitor<void> {
void visitAttributeSelector(AttributeSelector attribute) {}
void visitClassSelector(ClassSelector klass) {}
void visitIDSelector(IDSelector id) {}
void visitParentSelector(ParentSelector placeholder) {}
void visitPlaceholderSelector(PlaceholderSelector placeholder) {}
void visitTypeSelector(TypeSelector type) {}
void visitUniversalSelector(UniversalSelector universal) {}
void visitComplexSelector(ComplexSelector complex) {
for (var component in complex.components) {
visitCompoundSelector(component.selector);
}
}
void visitCompoundSelector(CompoundSelector compound) {
for (var simple in compound.components) {
simple.accept(this);
}
}
void visitPseudoSelector(PseudoSelector pseudo) =>
pseudo.selector.andThen(visitSelectorList);
void visitSelectorList(SelectorList list) {
for (var complex in list.components) {
visitComplexSelector(complex);
}
}
}