#[allow(unused)]
use log::info;

use crate::{core::hdlparam::Define, server::LSPServer};

impl LSPServer {
    /// 根据输入的 macro 名字，寻找 fast 中存在的第一个 macro
    /// macro 可以以 ` 开头
    pub fn find_macros(&self, macro_name: &str) -> Option<(Define, String)> {
        let macro_name = macro_name.replace("`", "");        
        let fast_map = self.srcs.hdl_param.path_to_hdl_file.read().unwrap();
        for path in fast_map.keys() {
            if let Some(hdl_file) = fast_map.get(path) {
                for define in &hdl_file.fast.fast_macro.defines {
                    if define.name == macro_name {
                        return Some((define.clone(), path.to_string()));
                    }
                }
            }
        }
        None
    }
}