From 836ee48c8d6a758408666298306187db1bfff594 Mon Sep 17 00:00:00 2001 From: he1pa <18012015693@163.com> Date: Wed, 3 Apr 2024 15:49:41 +0800 Subject: [PATCH] restore resolver cache Signed-off-by: he1pa <18012015693@163.com> --- kclvm/tools/src/LSP/src/request.rs | 35 +----------------------------- kclvm/tools/src/LSP/src/state.rs | 2 +- 2 files changed, 2 insertions(+), 35 deletions(-) diff --git a/kclvm/tools/src/LSP/src/request.rs b/kclvm/tools/src/LSP/src/request.rs index 7dca0e19b..61dcf6f8d 100644 --- a/kclvm/tools/src/LSP/src/request.rs +++ b/kclvm/tools/src/LSP/src/request.rs @@ -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 { @@ -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); diff --git a/kclvm/tools/src/LSP/src/state.rs b/kclvm/tools/src/LSP/src/state.rs index 04a491c06..7b87633d4 100644 --- a/kclvm/tools/src/LSP/src/state.rs +++ b/kclvm/tools/src/LSP/src/state.rs @@ -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), }) {