Skip to content

Commit

Permalink
restore resolver cache
Browse files Browse the repository at this point in the history
Signed-off-by: he1pa <18012015693@163.com>
  • Loading branch information
He1pa committed Apr 7, 2024
1 parent 55e8db4 commit 836ee48
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 35 deletions.
35 changes: 1 addition & 34 deletions kclvm/tools/src/LSP/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use crate::{
hover, quick_fix,
semantic_token::semantic_tokens_full,
state::{log_message, LanguageServerSnapshot, LanguageServerState, Task},
util::{compile_with_params, Params},
};

impl LanguageServerState {
Expand Down Expand Up @@ -307,39 +306,7 @@ pub(crate) fn handle_completion(
.and_then(|ctx| ctx.trigger_character)
.and_then(|s| s.chars().next());

let db =
match completion_trigger_character {
// Some trigger characters need to re-compile
Some(ch) => match ch {
'=' | ':' => {
let file_id = snapshot.vfs.read().file_id(&path.clone().into()).ok_or(
anyhow::anyhow!(LSPError::FileIdNotFound(path.clone().into())),
)?;
let version = *snapshot.opened_files.read().get(&file_id).ok_or_else(|| {
anyhow::anyhow!(LSPError::DocumentVersionNotFound(path.clone().into()))
})?;

match compile_with_params(Params {
file: file.clone(),
module_cache: Some(Arc::clone(&snapshot.module_cache)),
scope_cache: None,
vfs: Some(snapshot.vfs.clone()),
compile_unit_cache: Some(Arc::clone(&snapshot.compile_unit_cache)),
}) {
Ok((prog, diags, gs)) => Arc::new(AnalysisDatabase {
prog,
diags,
gs,
version,
}),
Err(_) => return Ok(None),
}
}
_ => snapshot.get_db(&path.clone().into())?,
},

None => snapshot.get_db(&path.clone().into())?,
};
let db = snapshot.get_db(&path.clone().into())?;

let res = completion(completion_trigger_character, &db.prog, &kcl_pos, &db.gs);

Expand Down
2 changes: 1 addition & 1 deletion kclvm/tools/src/LSP/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl LanguageServerState {
match compile_with_params(Params {
file: filename.clone(),
module_cache: Some(module_cache),
scope_cache: None,
scope_cache: Some(scope_cache),
vfs: Some(snapshot.vfs),
compile_unit_cache: Some(compile_unit_cache),
}) {
Expand Down

0 comments on commit 836ee48

Please sign in to comment.