#[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 path_to_hdl_file = self.srcs.hdl_param.path_to_hdl_file.read().unwrap();
        for (path, hdl_file) in path_to_hdl_file.iter() {
            for define in &hdl_file.fast.fast_macro.defines {
                if define.name == macro_name {
                    return Some((define.clone(), path.to_string()));
                }
            }
        }
        None
    }
}