diff --git a/kclvm/sema/src/resolver/import.rs b/kclvm/sema/src/resolver/import.rs index 35966194f..1927d64b4 100644 --- a/kclvm/sema/src/resolver/import.rs +++ b/kclvm/sema/src/resolver/import.rs @@ -147,10 +147,15 @@ impl<'ctx> Resolver<'ctx> { kind.clone(), ); let (start, end) = stmt.get_span_pos(); + + let name = match &import_stmt.asname { + Some(name) => name.clone(), + None => import_stmt.name.clone(), + }; scope.elems.insert( - import_stmt.path.to_string(), + name.clone(), Rc::new(RefCell::new(ScopeObject { - name: import_stmt.path.to_string(), + name, start: start.clone(), end: end.clone(), ty: Rc::new(ty.clone()), @@ -160,18 +165,14 @@ impl<'ctx> Resolver<'ctx> { name: import_stmt.name.clone(), asname: import_stmt.asname.clone(), }), - used: false, + used: true, doc: None, })), ); - let name = match &import_stmt.asname { - Some(name) => name.clone(), - None => import_stmt.name.clone(), - }; scope.elems.insert( - name.clone(), + import_stmt.path.to_string(), Rc::new(RefCell::new(ScopeObject { - name, + name: import_stmt.path.to_string(), start, end, ty: Rc::new(ty), diff --git a/kclvm/tools/src/LSP/src/completion.rs b/kclvm/tools/src/LSP/src/completion.rs index 33aaaf30f..c727062c2 100644 --- a/kclvm/tools/src/LSP/src/completion.rs +++ b/kclvm/tools/src/LSP/src/completion.rs @@ -18,9 +18,7 @@ use kclvm_compiler::pkgpath_without_prefix; use kclvm_config::modfile::KCL_FILE_EXTENSION; use kclvm_error::Position as KCLPos; -use kclvm_sema::builtin::{ - get_system_module_members, STANDARD_SYSTEM_MODULES, STRING_MEMBER_FUNCTIONS, -}; +use kclvm_sema::builtin::{get_system_module_members, STRING_MEMBER_FUNCTIONS}; use kclvm_sema::resolver::scope::{ProgramScope, ScopeObjectKind}; use lsp_types::CompletionItem;