修复 Rope 后,自增自减导致 lsp 行为异常的错误
This commit is contained in:
parent
23816af899
commit
9f50823429
@ -123,11 +123,8 @@ fn goto_instantiation<'a>(
|
|||||||
if token_name == param.name {
|
if token_name == param.name {
|
||||||
let def_path = server.srcs.hdl_param.find_module_definition_path(&module.name).unwrap();
|
let def_path = server.srcs.hdl_param.find_module_definition_path(&module.name).unwrap();
|
||||||
let target_uri = Url::from_file_path(def_path).unwrap();
|
let target_uri = Url::from_file_path(def_path).unwrap();
|
||||||
let mut target_range = param.range.to_lsp_range();
|
let target_range = param.range.clone();
|
||||||
target_range.start.line -= 1;
|
let target_range = target_range.to_lsp_range();
|
||||||
target_range.start.character -= 1;
|
|
||||||
target_range.end.line -= 1;
|
|
||||||
target_range.end.character -= 1;
|
|
||||||
|
|
||||||
let link = vec![LocationLink {
|
let link = vec![LocationLink {
|
||||||
target_uri,
|
target_uri,
|
||||||
@ -155,8 +152,8 @@ fn goto_instantiation<'a>(
|
|||||||
if token_name == port.name {
|
if token_name == port.name {
|
||||||
let def_path = server.srcs.hdl_param.find_module_definition_path(&module.name).unwrap();
|
let def_path = server.srcs.hdl_param.find_module_definition_path(&module.name).unwrap();
|
||||||
let target_uri = Url::from_file_path(def_path).unwrap();
|
let target_uri = Url::from_file_path(def_path).unwrap();
|
||||||
let mut target_range = port.range.clone();
|
let target_range = port.range.clone();
|
||||||
let target_range = target_range.affine(-1, -1).to_lsp_range();
|
let target_range = target_range.to_lsp_range();
|
||||||
|
|
||||||
let link = vec![LocationLink {
|
let link = vec![LocationLink {
|
||||||
target_uri,
|
target_uri,
|
||||||
@ -213,8 +210,8 @@ pub fn goto_module_declaration_definition(
|
|||||||
let def_path = server.srcs.hdl_param.find_module_definition_path(&module.name).unwrap();
|
let def_path = server.srcs.hdl_param.find_module_definition_path(&module.name).unwrap();
|
||||||
let target_uri = Url::from_file_path(PathBuf::from_str(&def_path).unwrap()).unwrap();
|
let target_uri = Url::from_file_path(PathBuf::from_str(&def_path).unwrap()).unwrap();
|
||||||
|
|
||||||
let mut target_range = module.range.clone();
|
let target_range = module.range.clone();
|
||||||
let target_range = target_range.affine(-1, -1).to_lsp_range();
|
let target_range = target_range.to_lsp_range();
|
||||||
|
|
||||||
let link = vec![LocationLink {
|
let link = vec![LocationLink {
|
||||||
target_uri,
|
target_uri,
|
||||||
|
@ -30,7 +30,6 @@ pub fn goto_definition(server: &LSPServer, params: &GotoDefinitionParams) -> Opt
|
|||||||
}
|
}
|
||||||
|
|
||||||
// match instance
|
// match instance
|
||||||
|
|
||||||
let scope_tree = server.srcs.scope_tree.read().ok()?;
|
let scope_tree = server.srcs.scope_tree.read().ok()?;
|
||||||
|
|
||||||
// match position port & param
|
// match position port & param
|
||||||
|
@ -223,8 +223,8 @@ fn goto_instantiation<'a>(
|
|||||||
None => return None
|
None => return None
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("current pos: {pos:#?}");
|
// info!("current pos: {pos:#?}");
|
||||||
info!("param_range: {param_range:#?}");
|
// info!("param_range: {param_range:#?}");
|
||||||
// info!("position param find belong module: {:?}", module);
|
// info!("position param find belong module: {:?}", module);
|
||||||
|
|
||||||
for param in &module.params {
|
for param in &module.params {
|
||||||
@ -244,8 +244,8 @@ fn goto_instantiation<'a>(
|
|||||||
None => return None
|
None => return None
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("current pos: {pos:#?}");
|
// info!("current pos: {pos:#?}");
|
||||||
info!("port_range: {port_range:#?}");
|
// info!("port_range: {port_range:#?}");
|
||||||
// info!("position port find belong module: {:?}", module);
|
// info!("position port find belong module: {:?}", module);
|
||||||
|
|
||||||
for port in &module.ports {
|
for port in &module.ports {
|
||||||
|
@ -33,20 +33,18 @@ pub fn hover(server: &LSPServer, params: &HoverParams) -> Option<Hover> {
|
|||||||
return Some(hover);
|
return Some(hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
// info!("enter hover_position_port_param");
|
info!("enter hover_position_port_param");
|
||||||
// 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) {
|
||||||
return Some(hover);
|
return Some(hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
// info!("enter hover_module_declaration");
|
info!("enter hover_module_declaration");
|
||||||
|
|
||||||
// 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, &language_id) {
|
||||||
// info!("[LSPServer] in hover: get module hover");
|
info!("[LSPServer] in hover: get module hover");
|
||||||
|
|
||||||
if hover_for_module(server, pos, doc) {
|
if hover_for_module(server, pos, doc) {
|
||||||
// info!("[LSPServer] in hover: it is instance");
|
info!("[LSPServer] in hover: it is instance");
|
||||||
return Some(hover);
|
return Some(hover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -302,14 +300,15 @@ fn hover_for_module(server: &LSPServer, pos: Position, doc: &Url) -> bool {
|
|||||||
let pathbuf = to_escape_path(&pathbuf);
|
let pathbuf = to_escape_path(&pathbuf);
|
||||||
let path_string = pathbuf.to_str().unwrap().replace("\\", "/");
|
let path_string = pathbuf.to_str().unwrap().replace("\\", "/");
|
||||||
let hdlparam = server.srcs.hdl_param.clone();
|
let hdlparam = server.srcs.hdl_param.clone();
|
||||||
// info!("current pos: {pos:#?}");
|
|
||||||
let find_instance_range = |_: &Module, instance: &Instance| {
|
let find_instance_range = |_: &Module, instance: &Instance| {
|
||||||
// info!("instance start pos: {:#?}", instance.range.start);
|
// info!("instance start pos: {:#?}", instance.range.start);
|
||||||
pos.line + 1 == instance.range.start.line
|
pos.line == instance.range.start.line
|
||||||
};
|
};
|
||||||
let find_module_range = |module: &Module| {
|
let find_module_range = |module: &Module| {
|
||||||
pos.line + 1 == module.range.start.line
|
pos.line == module.range.start.line
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(_) = hdlparam.walk_module(&path_string, find_module_range) {
|
if let Some(_) = hdlparam.walk_module(&path_string, find_module_range) {
|
||||||
// info!("[LSPServer] in hover: it is module");
|
// info!("[LSPServer] in hover: it is module");
|
||||||
true
|
true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user