42 lines
1.3 KiB
Rust
42 lines
1.3 KiB
Rust
use std::{path::PathBuf, str::FromStr};
|
|
|
|
use crate::{core, server::LSPServer};
|
|
#[allow(unused)]
|
|
use log::info;
|
|
use tower_lsp::lsp_types::*;
|
|
|
|
use super::to_escape_path;
|
|
|
|
pub fn inlay_hint(server: &LSPServer, params: &InlayHintParams) -> Option<Vec<InlayHint>> {
|
|
let uri = ¶ms.text_document.uri;
|
|
let path = PathBuf::from_str(uri.path()).unwrap();
|
|
let path = to_escape_path(&path);
|
|
let path_string = path.to_str().unwrap();
|
|
let visible_range = core::hdlparam::Range::from_lsp_range(¶ms.range);
|
|
|
|
let fast_map = server.srcs.hdl_param.path_to_hdl_file.read().unwrap();
|
|
// 先找到 当前 所在的 hdlfile
|
|
if let Some(hdl_file) = &fast_map.get(path_string) {
|
|
let fast = &hdl_file.fast;
|
|
let mut hints = Vec::<InlayHint>::new();
|
|
// 制作例化模块的 hint
|
|
for module in &fast.content {
|
|
for instance in &module.instances {
|
|
if let Some(instport_range) = &instance.instports {
|
|
// 根据在可见视图外面的 range 就不管了
|
|
if instport_range.before(&visible_range) || instport_range.after(&visible_range) {
|
|
continue;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
None
|
|
}
|
|
|
|
fn make_instport_hint(params: &InlayHintParams) {
|
|
|
|
} |