diff --git a/kclvm/api/src/service/service_impl.rs b/kclvm/api/src/service/service_impl.rs index 18a01a42d..6be18b2e6 100644 --- a/kclvm/api/src/service/service_impl.rs +++ b/kclvm/api/src/service/service_impl.rs @@ -359,7 +359,7 @@ impl KclvmServiceImpl { /// assert_eq!(result.variables.get("a").unwrap().value, "1"); /// ``` pub fn list_variables(&self, args: &ListVariablesArgs) -> anyhow::Result { - let k_files = args.files.iter().map(|s| s.as_str()).collect(); + let k_files = args.files.clone(); let specs = args.specs.clone(); let select_res = list_variables(k_files, specs)?; diff --git a/kclvm/query/src/selector.rs b/kclvm/query/src/selector.rs index f6998471a..0096d61cb 100644 --- a/kclvm/query/src/selector.rs +++ b/kclvm/query/src/selector.rs @@ -462,10 +462,14 @@ impl Variable { /// list_options provides users with the ability to parse kcl program and get all option /// calling information. -pub fn list_variables(files: Vec<&str>, specs: Vec) -> Result { +pub fn list_variables(files: Vec, specs: Vec) -> Result { let mut selector = Selector::new(specs)?; - // let parse_result = parse_file(&file, None)?; - let mut load_result = load_program(Arc::new(ParseSession::default()), &files, None, None)?; + let mut load_result = load_program( + Arc::new(ParseSession::default()), + &files.iter().map(AsRef::as_ref).collect::>(), + None, + None, + )?; let mut opts = Options::default(); opts.merge_program = true;