save
This commit is contained in:
parent
089d6ab161
commit
cf73bf7ac9
@ -27,6 +27,8 @@ pub fn sv_parser(path: &str) -> Option<FastHdlparam> {
|
|||||||
let doc = Rope::from_str(&text);
|
let doc = Rope::from_str(&text);
|
||||||
let uri = Url::from_file_path(&path).unwrap();
|
let uri = Url::from_file_path(&path).unwrap();
|
||||||
let result = recovery_sv_parse(&doc, &uri, &None, &includes);
|
let result = recovery_sv_parse(&doc, &uri, &None, &includes);
|
||||||
|
|
||||||
|
println!("result: {result:?}");
|
||||||
|
|
||||||
if let Some(syntax_tree) = result {
|
if let Some(syntax_tree) = result {
|
||||||
if let Ok(hdlparam) = make_fast_from_syntaxtree(&syntax_tree, &path) {
|
if let Ok(hdlparam) = make_fast_from_syntaxtree(&syntax_tree, &path) {
|
||||||
|
@ -5,7 +5,7 @@ use regex::Regex;
|
|||||||
use ropey::RopeSlice;
|
use ropey::RopeSlice;
|
||||||
use tower_lsp::lsp_types::{Hover, HoverContents, LanguageString, MarkedString, Position, Range, Url};
|
use tower_lsp::lsp_types::{Hover, HoverContents, LanguageString, MarkedString, Position, Range, Url};
|
||||||
|
|
||||||
use crate::{core::hdlparam::{Define, FastHdlparam}, server::LSPServer};
|
use crate::{core::hdlparam::{Define, FastHdlparam, Module}, definition::{DefinitionType, GenericDec}, server::LSPServer};
|
||||||
|
|
||||||
use super::{get_word_range_at_position, resolve_path, to_escape_path};
|
use super::{get_word_range_at_position, resolve_path, to_escape_path};
|
||||||
|
|
||||||
@ -340,8 +340,27 @@ fn make_param_desc_hover(param: &crate::core::hdlparam::Parameter, range: &Range
|
|||||||
pub fn hover_module_declaration(
|
pub fn hover_module_declaration(
|
||||||
server: &LSPServer,
|
server: &LSPServer,
|
||||||
token_name: &str,
|
token_name: &str,
|
||||||
|
definition: &GenericDec,
|
||||||
language_id: &str
|
language_id: &str
|
||||||
) -> Option<Hover> {
|
) -> Option<Hover> {
|
||||||
|
// let module_info = match definition.def_type {
|
||||||
|
// DefinitionType::GenericScope => {
|
||||||
|
// let pathbuf = PathBuf::from_str(definition.url.path()).unwrap();
|
||||||
|
// let path_string = to_escape_path(&pathbuf).to_str().unwrap();
|
||||||
|
// let hdlparam = &server.srcs.hdl_param;
|
||||||
|
// let mut result: Option<(Module, String)> = None;
|
||||||
|
|
||||||
|
// if let Some(hdl_file) = hdlparam.path_to_hdl_file.read().unwrap().get(path_string) {
|
||||||
|
// for module in &hdl_file.fast.content {
|
||||||
|
// if module.name == definition.ident {
|
||||||
|
// return Some((module.clone(), path_string.to_string()))
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// None
|
||||||
|
// }
|
||||||
|
// _ => None
|
||||||
|
// };
|
||||||
if let Some(module) = server.srcs.hdl_param.find_module_by_name(token_name) {
|
if let Some(module) = server.srcs.hdl_param.find_module_by_name(token_name) {
|
||||||
let port_num = module.ports.len();
|
let port_num = module.ports.len();
|
||||||
let param_num = module.params.len();
|
let param_num = module.params.len();
|
||||||
@ -374,7 +393,6 @@ pub fn hover_module_declaration(
|
|||||||
markdowns.push(MarkedString::String(define_info));
|
markdowns.push(MarkedString::String(define_info));
|
||||||
markdowns.push(MarkedString::String("---".to_string()));
|
markdowns.push(MarkedString::String("---".to_string()));
|
||||||
|
|
||||||
info!("module range: {:?}", module.range);
|
|
||||||
let module_profile = make_module_profile_code(&module);
|
let module_profile = make_module_profile_code(&module);
|
||||||
let profile_markdown = LanguageString {
|
let profile_markdown = LanguageString {
|
||||||
language: language_id.to_string(),
|
language: language_id.to_string(),
|
||||||
|
@ -33,7 +33,10 @@ pub fn hover(server: &LSPServer, params: &HoverParams) -> Option<Hover> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let scope_tree = server.srcs.scope_tree.read().ok()?;
|
let scope_tree = server.srcs.scope_tree.read().ok()?;
|
||||||
let global_scope = scope_tree.as_ref();
|
let global_scope = scope_tree.as_ref().unwrap();
|
||||||
|
|
||||||
|
let symbol_definition: GenericDec = global_scope
|
||||||
|
.get_definition(&token, file.text.pos_to_byte(&pos), doc)?;
|
||||||
|
|
||||||
// match positional port param
|
// match positional port param
|
||||||
if let Some(hover) = hover_position_port_param(server, &line_text, doc, pos, &language_id) {
|
if let Some(hover) = hover_position_port_param(server, &line_text, doc, pos, &language_id) {
|
||||||
@ -41,16 +44,13 @@ pub fn hover(server: &LSPServer, params: &HoverParams) -> Option<Hover> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// match module name
|
// match module name
|
||||||
if let Some(hover) = hover_module_declaration(server, &token, &language_id) {
|
if let Some(hover) = hover_module_declaration(server, &token, &symbol_definition, &language_id) {
|
||||||
return Some(hover);
|
return Some(hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(global_scope) = global_scope {
|
// match 正常 symbol
|
||||||
|
if let Some(hover) = hover_common_symbol(server, &token, &symbol_definition, &file, doc, pos, &language_id) {
|
||||||
// match 正常 symbol
|
return Some(hover);
|
||||||
if let Some(hover) = hover_common_symbol(server, global_scope, &token, &file, doc, pos, &language_id) {
|
|
||||||
return Some(hover);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// match digit 5'b00110
|
// match digit 5'b00110
|
||||||
@ -219,17 +219,15 @@ fn make_hover_with_comment(doc: &Rope, line: usize, language_id: &str, exclude_c
|
|||||||
fn hover_common_symbol(
|
fn hover_common_symbol(
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
server: &LSPServer,
|
server: &LSPServer,
|
||||||
scope_tree: &GenericScope,
|
#[allow(unused)]
|
||||||
token: &String,
|
token: &String,
|
||||||
|
symbol_definition: &GenericDec,
|
||||||
file: &RwLockReadGuard<'_, crate::sources::Source>,
|
file: &RwLockReadGuard<'_, crate::sources::Source>,
|
||||||
doc: &Url,
|
doc: &Url,
|
||||||
|
#[allow(unused)]
|
||||||
pos: Position,
|
pos: Position,
|
||||||
language_id: &String
|
language_id: &String
|
||||||
) -> Option<Hover> {
|
) -> Option<Hover> {
|
||||||
|
|
||||||
let symbol_definition: GenericDec = scope_tree
|
|
||||||
.get_definition(token, file.text.pos_to_byte(&pos), doc)?;
|
|
||||||
|
|
||||||
// 根据 symbol 的类别进行额外的判断
|
// 根据 symbol 的类别进行额外的判断
|
||||||
match symbol_definition.def_type {
|
match symbol_definition.def_type {
|
||||||
DefinitionType::ModuleInstantiation => {
|
DefinitionType::ModuleInstantiation => {
|
||||||
|
@ -561,8 +561,6 @@ pub fn sv_parser_pipeline(
|
|||||||
None => None,
|
None => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("finish parse {:?}", uri.to_string());
|
|
||||||
|
|
||||||
let mut file = source_handle.write().unwrap();
|
let mut file = source_handle.write().unwrap();
|
||||||
|
|
||||||
// 加入语法树 & 更新 fast
|
// 加入语法树 & 更新 fast
|
||||||
@ -578,6 +576,8 @@ pub fn sv_parser_pipeline(
|
|||||||
// file.syntax_tree = syntax_tree;
|
// file.syntax_tree = syntax_tree;
|
||||||
drop(file);
|
drop(file);
|
||||||
|
|
||||||
|
info!("finish parse {:?}", uri.to_string());
|
||||||
|
|
||||||
// 更新 global_scope,用于 sv 的解析
|
// 更新 global_scope,用于 sv 的解析
|
||||||
// global_scope 为全局最大的那个 scope,它的 scopes 和 defs 下的元素和每一个文件一一对应
|
// global_scope 为全局最大的那个 scope,它的 scopes 和 defs 下的元素和每一个文件一一对应
|
||||||
let mut global_scope = scope_handle.write().unwrap();
|
let mut global_scope = scope_handle.write().unwrap();
|
||||||
|
@ -54,7 +54,7 @@ mod test_fast {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parent() {
|
fn test_parent() {
|
||||||
let fast = sv_parser("/home/dide/project/digital-lsp-server/testfiles/parent.v");
|
let fast = sv_parser("/home/dide/project/Digital-Test/Digital-IDE-temp/user/src/vlog/bigfile/axil_crossbar.v");
|
||||||
let fast = fast.unwrap();
|
let fast = fast.unwrap();
|
||||||
println!("{:#?}", fast.content);
|
println!("{:#?}", fast.content);
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 3002b3970b64903ec98a3274d7254fefa82f0435
|
Subproject commit 1e390e0f4429b5004e63327b64d5095775ef27b5
|
Loading…
x
Reference in New Issue
Block a user