fn visit_selections(
    trees: &mut FnvHashMap<StringKey, Node>,
    selections: &[Selection],
    parent_name: StringKey,
    children: &mut Vec<StringKey>,
) {
    for selection in selections {
        match selection {
            Selection::FragmentSpread(node) => {
                let key = node.fragment.item;
                match trees.get_mut(&key) {
                    None => {
                        trees.insert(
                            key,
                            Node {
                                ir: None,
                                parents: vec![parent_name],
                                children: vec![],
                            },
                        );
                    }
                    Some(node) => {
                        node.parents.push(parent_name);
                    }
                }
                children.push(key);
            }
            Selection::LinkedField(node) => {
                visit_selections(trees, &node.selections, parent_name, children);
            }
            Selection::InlineFragment(node) => {
                visit_selections(trees, &node.selections, parent_name, children);
            }
            Selection::ScalarField(_) => {}
            Selection::Condition(node) => {
                visit_selections(trees, &node.selections, parent_name, children);
            }
        }
    }
}
// Visit the selections of current IR, set the `children` for the node representing the IR,
// and the `parents` for nodes representing the children IR
Visit the selections of current IR, set the `children` for the node representing the IR,
and the `parents` for nodes representing the children IR
Visit the selections of current IR set the ` children ` for the node representing the IR and the ` parents ` for nodes representing the children IR
fn visit_selections(
    trees: &mut FnvHashMap<StringKey, Node>,
    selections: &[Selection],
    parent_name: StringKey,
    children: &mut Vec<StringKey>,
) {
    for selection in selections {
        match selection {
            Selection::FragmentSpread(node) => {
                let key = node.fragment.item;
                match trees.get_mut(&key) {
                    None => {
                        trees.insert(
                            key,
                            Node {
                                ir: None,
                                parents: vec![parent_name],
                                children: vec![],
                            },
                        );
                    }
                    Some(node) => {
                        node.parents.push(parent_name);
                    }
                }
                children.push(key);
            }
            Selection::LinkedField(node) => {
                visit_selections(trees, &node.selections, parent_name, children);
            }
            Selection::InlineFragment(node) => {
                visit_selections(trees, &node.selections, parent_name, children);
            }
            Selection::ScalarField(_) => {}
            Selection::Condition(node) => {
                visit_selections(trees, &node.selections, parent_name, children);
            }
        }
    }
}
fn visit_selections ( trees : & mut FnvHashMap < StringKey , Node > , selections : & [ Selection ] , parent_name : StringKey , children : & mut Vec < StringKey > , ) { for selection in selections { match selection { Selection :: FragmentSpread ( node ) => { let key = node . fragment . item ; match trees . get_mut ( & key ) { None => { trees . insert ( key , Node { ir : None , parents : vec ! [ parent_name ] , children : vec ! [ ] , } , ) ; } Some ( node ) => { node . parents . push ( parent_name ) ; } } children . push ( key ) ; } Selection :: LinkedField ( node ) => { visit_selections ( trees , & node . selections , parent_name , children ) ; } Selection :: InlineFragment ( node ) => { visit_selections ( trees , & node . selections , parent_name , children ) ; } Selection :: ScalarField ( _ ) => { } Selection :: Condition ( node ) => { visit_selections ( trees , & node . selections , parent_name , children ) ; } } } }
Visit the selections of current IR, set the `children` for the node representing the IR,
and the `parents` for nodes representing the children IR
Visit the selections of current IR set the ` children ` for the node representing the IR and the ` parents ` for nodes representing the children IR
trees
&mut FnvHashMap<StringKey, Node>
selections
&[Selection]
parent_name
StringKey
children
&mut Vec<StringKey>
trees
&mut FnvHashMap<StringKey, Node>
selections
&[Selection]
parent_name
StringKey
children
&mut Vec<StringKey>