fn new(node: &Node, source: &str, node_id: usize) -> Self {
        let mut fqname = vec![format!("{}[{}]", node.utf8_text(source.as_bytes()).unwrap(), node_id)];

        // first node will always have a parent
        let mut prev = *node;
        let mut node = node.parent().unwrap();

        loop {
            match (node.kind(), prev.kind()) {
                ("function_definition", "compound_statement") => {
                    let func_ident = node.child_by_field_name("declarator").unwrap().child(0).unwrap();
                    fqname.push(format!("{}[{}]", func_ident.utf8_text(source.as_bytes()).unwrap(), func_ident.id()));
                }
                ("struct_specifier", "field_declaration_list") => {
                    let struct_ident = node.child_by_field_name("name").unwrap();
                    fqname.push(format!(
                        "{}[{}]",
                        struct_ident.utf8_text(source.as_bytes()).unwrap(),
                        struct_ident.id()
                    ));
                }
                _ => (),
            }

            prev = node;
            node = match node.parent() {
                Some(n) => n,
                None => break,
            };
        }

        fqname.reverse();
        SymbolName(fqname.join("/"))
    }
// construct a new SymbolName from a node and its node ID for overload disambiguating.
construct a new SymbolName from a node and its node ID for overload disambiguating.
construct a new SymbolName from a node and its node ID for overload disambiguating .
fn new(node: &Node, source: &str, node_id: usize) -> Self {
        let mut fqname = vec![format!("{}[{}]", node.utf8_text(source.as_bytes()).unwrap(), node_id)];
        // first node will always have a parent
        let mut prev = *node;
        let mut node = node.parent().unwrap();
        loop {
            match (node.kind(), prev.kind()) {
                ("function_definition", "compound_statement") => {
                    let func_ident = node.child_by_field_name("declarator").unwrap().child(0).unwrap();
                    fqname.push(format!("{}[{}]", func_ident.utf8_text(source.as_bytes()).unwrap(), func_ident.id()));
                }
                ("struct_specifier", "field_declaration_list") => {
                    let struct_ident = node.child_by_field_name("name").unwrap();
                    fqname.push(format!(
                        "{}[{}]",
                        struct_ident.utf8_text(source.as_bytes()).unwrap(),
                        struct_ident.id()
                    ));
                }
                _ => (),
            }
            prev = node;
            node = match node.parent() {
                Some(n) => n,
                None => break,
            };
        }
        fqname.reverse();
        SymbolName(fqname.join("/"))
    }
fn new ( node : & Node , source : & str , node_id : usize ) -> Self { let mut fqname = vec ! [ format ( " " node utf8_text ( source as_bytes ( ) ) unwrap ( ) node_id ) ] ; // first node will always have a parent let mut prev = * node ; let mut node = node . parent ( ) . unwrap ( ) ; loop { match ( node . kind ( ) , prev . kind ( ) ) { ( " " , " " ) => { let func_ident = node . child_by_field_name ( " " ) . unwrap ( ) . child ( 0 ) . unwrap ( ) ; fqname . push ( format ! ( " " func_ident utf8_text ( source as_bytes ( ) ) unwrap ( ) func_ident id ( ) ) ) ; } ( " " , " " ) => { let struct_ident = node . child_by_field_name ( " " ) . unwrap ( ) ; fqname . push ( format ! ( " " struct_ident utf8_text ( source as_bytes ( ) ) unwrap ( ) struct_ident id ( ) ) ) ; } _ => ( ) , } prev = node ; node = match node . parent ( ) { Some ( n ) => n , None => break , } ; } fqname . reverse ( ) ; SymbolName ( fqname . join ( " " ) ) }
construct a new SymbolName from a node and its node ID for overload disambiguating.
construct a new SymbolName from a node and its node ID for overload disambiguating .
node
&Node
source
&str
node_id
usize
node
&Node
source
&str
node_id
usize