Skip to content

Commit

Permalink
fix: fix lsp panic caused by advanced resolver compile err (#1361)
Browse files Browse the repository at this point in the history
* fix lsp panic caused by advanced resolver compile err

Signed-off-by: he1pa <18012015693@163.com>

* fmt code

Signed-off-by: he1pa <18012015693@163.com>

---------

Signed-off-by: he1pa <18012015693@163.com>
  • Loading branch information
He1pa authored May 27, 2024
1 parent 16d0d10 commit 6d94d6a
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions kclvm/tools/src/LSP/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ pub(crate) fn handle_goto_definition(
if !snapshot.verify_request_path(&path.clone().into(), &sender) {
return Ok(None);
}
let db = snapshot.get_db(&path.clone().into())?;
let db = match snapshot.get_db(&path.clone().into()) {
Ok(db) => db,
Err(_) => return Ok(None),
};
let kcl_pos = kcl_pos(&file, params.text_document_position_params.position);
let res = goto_def(&kcl_pos, &db.gs);
if res.is_none() {
Expand All @@ -261,7 +264,10 @@ pub(crate) fn handle_reference(
if !snapshot.verify_request_path(&path.clone().into(), &sender) {
return Ok(None);
}
let db = snapshot.get_db(&path.clone().into())?;
let db = match snapshot.get_db(&path.clone().into()) {
Ok(db) => db,
Err(_) => return Ok(None),
};
let pos = kcl_pos(&file, params.text_document_position.position);
let log = |msg: String| log_message(msg, &sender);
let module_cache = snapshot.module_cache.clone();
Expand Down Expand Up @@ -304,7 +310,10 @@ pub(crate) fn handle_completion(
.and_then(|ctx| ctx.trigger_character)
.and_then(|s| s.chars().next());

let db = snapshot.get_db(&path.clone().into())?;
let db = match snapshot.get_db(&path.clone().into()) {
Ok(db) => db,
Err(_) => return Ok(None),
};

let res = completion(
completion_trigger_character,
Expand All @@ -331,7 +340,10 @@ pub(crate) fn handle_hover(
if !snapshot.verify_request_path(&path.clone().into(), &sender) {
return Ok(None);
}
let db = snapshot.get_db(&path.clone().into())?;
let db = match snapshot.get_db(&path.clone().into()) {
Ok(db) => db,
Err(_) => return Ok(None),
};
let kcl_pos = kcl_pos(&file, params.text_document_position_params.position);
let res = hover::hover(&kcl_pos, &db.gs);
if res.is_none() {
Expand Down Expand Up @@ -379,7 +391,10 @@ pub(crate) fn handle_rename(
if !snapshot.verify_request_path(&path.clone().into(), &sender) {
return Ok(None);
}
let db = snapshot.get_db(&path.clone().into())?;
let db = match snapshot.get_db(&path.clone().into()) {
Ok(db) => db,
Err(_) => return Ok(None),
};
let kcl_pos = kcl_pos(&file, params.text_document_position.position);
let log = |msg: String| log_message(msg, &sender);
let references = find_refs(
Expand Down

0 comments on commit 6d94d6a

Please sign in to comment.