procss/transformers/
filter_refs.rs

1// ┌───────────────────────────────────────────────────────────────────────────┐
2// │                                                                           │
3// │  ██████╗ ██████╗  ██████╗   Copyright (C) 2022, The Prospective Company   │
4// │  ██╔══██╗██╔══██╗██╔═══██╗                                                │
5// │  ██████╔╝██████╔╝██║   ██║  This file is part of the Procss library,      │
6// │  ██╔═══╝ ██╔══██╗██║   ██║  distributed under the terms of the            │
7// │  ██║     ██║  ██║╚██████╔╝  Apache License 2.0.  The full license can     │
8// │  ╚═╝     ╚═╝  ╚═╝ ╚═════╝   be found in the LICENSE file.                 │
9// │                                                                           │
10// └───────────────────────────────────────────────────────────────────────────┘
11
12use crate::ast::Ruleset::{self};
13use crate::ast::*;
14
15pub fn filter_refs(tree: &mut Tree) {
16    *tree = Tree(
17        tree.iter().filter(|&y| match y {
18                Ruleset::SelectorRuleset(_) => false,
19                Ruleset::QualRule(_) => true,
20                Ruleset::QualRuleset(_) => true,
21                Ruleset::QualNestedRuleset(_) => true,
22            }).cloned()
23            .collect(),
24    )
25}