fn get_func_space_name Option()

in src/getter.rs [433:478]


    fn get_func_space_name<'a>(node: &Node, code: &'a [u8]) -> Option<&'a str> {
        match node.kind_id().into() {
            Cpp::FunctionDefinition | Cpp::FunctionDefinition2 | Cpp::FunctionDefinition3 => {
                if let Some(op_cast) = node.first_child(|id| Cpp::OperatorCast == id) {
                    let code = &code[op_cast.start_byte()..op_cast.end_byte()];
                    return std::str::from_utf8(code).ok();
                }
                // we're in a function_definition so need to get the declarator
                if let Some(declarator) = node.child_by_field_name("declarator") {
                    let declarator_node = declarator;
                    if let Some(fd) = declarator_node.first_occurrence(|id| {
                        Cpp::FunctionDeclarator == id
                            || Cpp::FunctionDeclarator2 == id
                            || Cpp::FunctionDeclarator3 == id
                    }) {
                        if let Some(first) = fd.child(0) {
                            match first.kind_id().into() {
                                Cpp::TypeIdentifier
                                | Cpp::Identifier
                                | Cpp::FieldIdentifier
                                | Cpp::DestructorName
                                | Cpp::OperatorName
                                | Cpp::QualifiedIdentifier
                                | Cpp::QualifiedIdentifier2
                                | Cpp::QualifiedIdentifier3
                                | Cpp::QualifiedIdentifier4
                                | Cpp::TemplateFunction
                                | Cpp::TemplateMethod => {
                                    let code = &code[first.start_byte()..first.end_byte()];
                                    return std::str::from_utf8(code).ok();
                                }
                                _ => {}
                            }
                        }
                    }
                }
            }
            _ => {
                if let Some(name) = node.child_by_field_name("name") {
                    let code = &code[name.start_byte()..name.end_byte()];
                    return std::str::from_utf8(code).ok();
                }
            }
        }
        None
    }