diff --git a/kclvm/tools/src/LSP/src/completion.rs b/kclvm/tools/src/LSP/src/completion.rs index 078d59dd6..5e2d90464 100644 --- a/kclvm/tools/src/LSP/src/completion.rs +++ b/kclvm/tools/src/LSP/src/completion.rs @@ -142,7 +142,7 @@ pub(crate) fn completion( label: name, detail: Some(ty.ty_str()), documentation: sema_info.doc.clone(), - kind: type_to_item_kind(&ty), + kind: type_to_item_kind(ty), insert_text: None, }); } @@ -248,9 +248,9 @@ fn completion_dot( kclvm_sema::ty::TypeKind::Schema(_) => { Some(KCLCompletionItemKind::SchemaAttr) } - _ => type_to_item_kind(&attr_ty), + _ => type_to_item_kind(attr_ty), }, - None => type_to_item_kind(&attr_ty), + None => type_to_item_kind(attr_ty), }; let documentation = match &sema_info.doc { Some(doc) => { @@ -615,12 +615,10 @@ fn ty_complete_label(ty: &Type, module: Option<&ModuleInfo>) -> Vec { "{}{}{}", if schema.pkgpath.is_empty() || schema.pkgpath == MAIN_PKG { "".to_string() + } else if let Some(m) = module { + format!("{}.", pkg_real_name(&schema.pkgpath, m)) } else { - if let Some(m) = module { - format!("{}.", pkg_real_name(&schema.pkgpath, m)) - } else { - format!("{}.", schema.pkgpath.split('.').last().unwrap()) - } + format!("{}.", schema.pkgpath.split('.').last().unwrap()) }, schema.name, "{}" diff --git a/kclvm/tools/src/LSP/src/document_symbol.rs b/kclvm/tools/src/LSP/src/document_symbol.rs index d96362d5b..51a59330e 100644 --- a/kclvm/tools/src/LSP/src/document_symbol.rs +++ b/kclvm/tools/src/LSP/src/document_symbol.rs @@ -105,6 +105,7 @@ fn symbol_to_document_symbol(symbol: &KCLSymbol) -> Option { let kind = symbol_kind_to_document_symbol_kind(kind); let detail = sema_info.ty.clone().map(|ty| ty.ty_str()); + #[allow(deprecated)] Some(DocumentSymbol { name, kind, diff --git a/kclvm/tools/src/LSP/src/find_refs.rs b/kclvm/tools/src/LSP/src/find_refs.rs index 670a6dc99..055eca46c 100644 --- a/kclvm/tools/src/LSP/src/find_refs.rs +++ b/kclvm/tools/src/LSP/src/find_refs.rs @@ -67,9 +67,7 @@ pub(crate) fn find_refs_from_def Result<(), anyhow::Error>>( for (_, word_index) in &mut *word_index_map.write() { if let Some(mut locs) = word_index.get(name.as_str()).cloned() { if locs.len() >= 20 { - let _ = logger(format!( - "Found more than 20 matched symbols, only the first 20 will be processed" - )); + let _ = logger("Found more than 20 matched symbols, only the first 20 will be processed".to_string()); locs = locs[0..20].to_vec(); } @@ -109,14 +107,14 @@ pub(crate) fn find_refs_from_def Result<(), anyhow::Error>>( Err(err) => { let _ = logger(format!( "{file_path} compilation failed: {}", - err.to_string() + err )); false } } } Err(err) => { - let _ = logger(format!("compilation failed: {}", err.to_string())); + let _ = logger(format!("compilation failed: {}", err)); false } } diff --git a/kclvm/tools/src/LSP/src/rename.rs b/kclvm/tools/src/LSP/src/rename.rs index 7f27ed228..5d95e8c13 100644 --- a/kclvm/tools/src/LSP/src/rename.rs +++ b/kclvm/tools/src/LSP/src/rename.rs @@ -367,7 +367,7 @@ where if let Some(symbol_ref) = find_def_with_gs(&kcl_pos, &gs, true) { if let Some(symbol_def) = gs.get_symbols().get_symbol(symbol_ref) { if symbol_def.get_range() == range { - refs.push(loc.clone()) + refs.push(loc) } } } @@ -400,7 +400,7 @@ where mod tests { use kclvm_ast::ast; use kclvm_error::diagnostic; - use lsp_types::{Location, Position, Range, TextEdit, Url}; + use lsp_types::{Position, Range, TextEdit}; use maplit::hashmap; use parking_lot::RwLock; use std::fs; @@ -509,7 +509,7 @@ e = a["abc"] #[test] fn test_select_symbol() { - let (root, _, person_path, server_path, config_path, vfs) = prepare_vfs(); + let (root, _, person_path, server_path, _config_path, vfs) = prepare_vfs(); let pkg_root = root.as_path().to_str().unwrap().to_string(); if let Some((name, range)) = select_symbol( @@ -689,7 +689,7 @@ e = a["abc"] let vfs: Arc> = Arc::new(RwLock::new(Default::default())); for path in vec![base_path, main_path] { - let content = fs::read_to_string(path.clone()).unwrap(); + let content = fs::read_to_string(path).unwrap(); vfs.write().set_file_contents( VfsPath::new_virtual_path(path.to_string()), Some(content.into_bytes()), @@ -884,8 +884,8 @@ a = base.Person { root.to_str().unwrap(), "base:Person", hashmap! { - base_path_string.clone() => base_source_code.clone().to_string(), - main_path_string.clone() => main_source_code.clone().to_string(), + base_path_string.clone() => base_source_code.to_string(), + main_path_string.clone() => main_source_code.to_string(), }, "NewPerson".to_string(), ) diff --git a/kclvm/tools/src/LSP/src/request.rs b/kclvm/tools/src/LSP/src/request.rs index 5c4d76cc2..e8af99251 100644 --- a/kclvm/tools/src/LSP/src/request.rs +++ b/kclvm/tools/src/LSP/src/request.rs @@ -310,7 +310,7 @@ pub(crate) fn handle_document_symbol( } Ok(res) } - Err(_) => return Ok(None), + Err(_) => Ok(None), } } diff --git a/kclvm/tools/src/LSP/src/semantic_token.rs b/kclvm/tools/src/LSP/src/semantic_token.rs index 02906e6be..6e5fa4552 100644 --- a/kclvm/tools/src/LSP/src/semantic_token.rs +++ b/kclvm/tools/src/LSP/src/semantic_token.rs @@ -141,10 +141,10 @@ mod tests { .iter() .map(|token| { ( - token.delta_line as u32, - token.delta_start as u32, - token.length as u32, - token.token_type as u32, + token.delta_line, + token.delta_start, + token.length, + token.token_type, ) }) .collect(); diff --git a/kclvm/tools/src/LSP/src/util.rs b/kclvm/tools/src/LSP/src/util.rs index 512b2d7db..968041435 100644 --- a/kclvm/tools/src/LSP/src/util.rs +++ b/kclvm/tools/src/LSP/src/util.rs @@ -748,6 +748,7 @@ pub(crate) fn get_real_path_from_external( real_path } +#[allow(unused)] pub(crate) fn build_word_index_for_source_codes( source_codes: HashMap, prune: bool, @@ -792,9 +793,10 @@ pub(crate) fn build_word_index( build_word_index_for_file_paths(&files, prune) } -pub struct VirtualLocation { - pub filepath: String, - pub range: Range, +#[allow(unused)] +pub(crate) struct VirtualLocation { + pub(crate) filepath: String, + pub(crate) range: Range, } pub(crate) fn build_word_index_for_file_content_with_vfs(