diff --git a/kclvm/tools/src/LSP/src/goto_def.rs b/kclvm/tools/src/LSP/src/goto_def.rs index bcb2dd7fe..11120ab5c 100644 --- a/kclvm/tools/src/LSP/src/goto_def.rs +++ b/kclvm/tools/src/LSP/src/goto_def.rs @@ -98,603 +98,10 @@ fn positions_to_goto_def_resp( #[cfg(test)] mod tests { use super::goto_def; - use crate::{ - from_lsp::file_path_from_url, - tests::{compare_goto_res, compile_test_file}, - }; - use indexmap::IndexSet; + use crate::{from_lsp::file_path_from_url, tests::compile_test_file}; use kclvm_error::Position as KCLPos; - use proc_macro_crate::bench_test; use std::path::{Path, PathBuf}; - #[test] - #[bench_test] - fn goto_import_pkg_test() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - let pos = KCLPos { - filename: file, - line: 1, - column: Some(10), - }; - - let res = goto_def(&pos, &gs); - - let mut expected_files = IndexSet::new(); - let path_str = path.to_str().unwrap(); - let test_files = [ - "src/test_data/goto_def_test/pkg/schema_def1.k", - "src/test_data/goto_def_test/pkg/schema_def.k", - ]; - expected_files.insert(format!("{}/{}", path_str, test_files[0])); - expected_files.insert(format!("{}/{}", path_str, test_files[1])); - - match res.unwrap() { - lsp_types::GotoDefinitionResponse::Array(arr) => { - assert_eq!(expected_files.len(), arr.len()); - for loc in arr { - let got_path = file_path_from_url(&loc.uri).unwrap(); - assert!(expected_files.contains(&got_path)); - } - } - _ => { - unreachable!("test error") - } - } - } - - #[test] - #[bench_test] - fn goto_import_file_test() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - // test goto import file: import .pkg.schema_def - let pos = KCLPos { - filename: file, - line: 2, - column: Some(10), - }; - let res = goto_def(&pos, &gs); - match res.unwrap() { - lsp_types::GotoDefinitionResponse::Scalar(loc) => { - let got_path = file_path_from_url(&loc.uri).unwrap(); - assert_eq!(got_path, expected_path.to_str().unwrap()) - } - _ => { - unreachable!("test error") - } - } - } - - #[test] - #[bench_test] - fn goto_pkg_prefix_def_test() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - // test goto pkg prefix def: p = pkg.Person { <- pkg - let pos = KCLPos { - filename: file, - line: 4, - column: Some(7), - }; - let res = goto_def(&pos, &gs); - let mut expected_files = IndexSet::new(); - let path_str = path.to_str().unwrap(); - let test_files = [ - "src/test_data/goto_def_test/pkg/schema_def1.k", - "src/test_data/goto_def_test/pkg/schema_def.k", - ]; - expected_files.insert(format!("{}/{}", path_str, test_files[0])); - expected_files.insert(format!("{}/{}", path_str, test_files[1])); - - match res.unwrap() { - lsp_types::GotoDefinitionResponse::Array(arr) => { - assert_eq!(expected_files.len(), arr.len()); - for loc in arr { - let got_path = file_path_from_url(&loc.uri).unwrap(); - assert!(expected_files.contains(&got_path)); - } - } - _ => { - unreachable!("test error") - } - } - } - - #[test] - #[bench_test] - fn goto_schema_def_test() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - // test goto schema definition: p = pkg.Person <- Person - let pos = KCLPos { - filename: file, - line: 4, - column: Some(11), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 0, 7, 0, 13), - ); - } - - #[test] - #[bench_test] - fn goto_var_def_in_config_and_config_if_test() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - let pos = KCLPos { - filename: file.clone(), - line: 67, - column: Some(36), - }; - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 65, 11, 65, 14)); - - let pos = KCLPos { - filename: file.clone(), - line: 67, - column: Some(44), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 65, 16, 65, 21)); - let pos = KCLPos { - filename: file.clone(), - line: 64, - column: Some(11), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 69, 6, 69, 10)); - let pos = KCLPos { - filename: file.clone(), - line: 67, - column: Some(10), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 69, 6, 69, 10)); - } - - #[test] - #[bench_test] - fn goto_var_def_in_dict_comp_test() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - let pos = KCLPos { - filename: file.clone(), - line: 77, - column: Some(68), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 76, 143, 76, 145)); - - let pos = KCLPos { - filename: file.clone(), - line: 77, - column: Some(61), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 76, 143, 76, 145)); - } - - #[test] - #[bench_test] - fn goto_schema_attr_def_test() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - // test goto schema attr definition: name: "alice" - let pos = KCLPos { - filename: file, - line: 5, - column: Some(7), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 4, 4, 4, 8), - ); - } - - #[test] - #[bench_test] - fn goto_schema_attr_def_test1() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/goto_def.k"); - - // test goto schema attr definition, goto name in: s = p2.n.name - let pos = KCLPos { - filename: file, - line: 30, - column: Some(12), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 18, 4, 18, 8), - ); - } - - #[test] - #[bench_test] - fn test_goto_identifier_names() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/goto_def.k"); - - // test goto p2 in: s = p2.n.name - let pos = KCLPos { - filename: file.clone(), - line: 30, - column: Some(5), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 23, 0, 23, 2), - ); - - // test goto n in: s = p2.n.name - let pos = KCLPos { - filename: file.clone(), - line: 30, - column: Some(8), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 21, 1, 21, 2), - ); - - // test goto name in: s = p2.n.name - let pos = KCLPos { - filename: file, - line: 30, - column: Some(12), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 18, 4, 18, 8), - ); - } - - #[test] - #[bench_test] - fn goto_identifier_def_test() { - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - // test goto identifier definition: p1 = p - let pos = KCLPos { - filename: file.to_string(), - line: 9, - column: Some(6), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 3, 0, 3, 1)); - } - - #[test] - #[bench_test] - fn goto_assign_type_test() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - // test goto schema attr definition: name: "alice" - let pos = KCLPos { - filename: file.clone(), - line: 38, - column: Some(17), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 33, 7, 33, 15)); - } - - #[test] - #[bench_test] - fn goto_schema_attr_ty_def_test() { - // test goto schema attr type definition: p1: pkg.Person - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - let pos = KCLPos { - filename: file, - line: 12, - column: Some(15), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 0, 7, 0, 13), - ); - } - - #[test] - #[bench_test] - fn goto_schema_attr_ty_def_test1() { - // test goto schema attr type definition: p2: [pkg.Person] - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - let pos = KCLPos { - filename: file, - line: 13, - column: Some(15), - }; - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 0, 7, 0, 13), - ); - } - - #[test] - #[bench_test] - fn goto_schema_attr_ty_def_test3() { - // test goto schema attr type definition: p3: {str: pkg.Person} - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - let pos = KCLPos { - filename: file, - line: 14, - column: Some(22), - }; - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 0, 7, 0, 13), - ); - } - - #[test] - #[bench_test] - fn goto_schema_attr_ty_def_test4() { - // test goto schema attr type definition(Person): p4: pkg.Person | pkg.Person1 - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - let pos = KCLPos { - filename: file, - line: 15, - column: Some(17), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 0, 7, 0, 13), - ); - } - - #[test] - #[bench_test] - fn goto_schema_attr_ty_def_test5() { - // test goto schema attr type definition(Person1): p4: pkg.Person | pkg.Person1 - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def1.k"); - - let pos = KCLPos { - filename: file, - line: 15, - column: Some(28), - }; - let res = goto_def(&pos, &gs); - compare_goto_res( - res, - (&expected_path.to_str().unwrap().to_string(), 0, 7, 0, 14), - ); - } - - #[test] - #[bench_test] - fn goto_local_var_def_test() { - let path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); - - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let mut expected_path = path; - expected_path.push("src/test_data/goto_def_test/pkg/schema_def.k"); - - // test goto local var def - let pos = KCLPos { - filename: file.clone(), - line: 47, - column: Some(11), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 43, 4, 43, 9)); - - let pos = KCLPos { - filename: file.clone(), - line: 49, - column: Some(11), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 43, 4, 43, 9)); - - let pos = KCLPos { - filename: file.clone(), - line: 51, - column: Some(11), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 43, 4, 43, 9)); - } - - #[test] - #[bench_test] - fn complex_select_goto_def() { - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let pos = KCLPos { - filename: file.clone(), - line: 52, - column: Some(22), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 43, 4, 43, 9)); - } - - #[test] - #[bench_test] - fn schema_attribute_def_goto_def() { - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let pos = KCLPos { - filename: file.clone(), - line: 19, - column: Some(5), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 18, 4, 18, 8)); - } - - #[test] - #[bench_test] - fn config_desuger_def_goto_def() { - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let pos = KCLPos { - filename: file.clone(), - line: 82, - column: Some(9), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 18, 4, 18, 8)); - } - - #[test] - #[bench_test] - fn lambda_param_goto_def() { - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let pos = KCLPos { - filename: file.clone(), - line: 86, - column: Some(4), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 84, 14, 84, 15)); - - let pos = KCLPos { - filename: file.clone(), - line: 86, - column: Some(8), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 84, 22, 84, 23)); - } - - #[test] - #[bench_test] - fn list_if_expr_test() { - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let pos = KCLPos { - filename: file.clone(), - line: 91, - column: Some(8), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 88, 0, 88, 1)); - } - - #[test] - #[bench_test] - fn lambda_local_var_test() { - let (file, _program, _, gs) = compile_test_file("src/test_data/goto_def_test/goto_def.k"); - - let pos = KCLPos { - filename: file.clone(), - line: 96, - column: Some(9), - }; - - let res = goto_def(&pos, &gs); - compare_goto_res(res, (&file, 94, 11, 94, 12)); - } - #[macro_export] macro_rules! goto_def_test_snapshot { ($name:ident, $file:expr, $line:expr, $column: expr) => { @@ -725,19 +132,164 @@ mod tests { let relative_path = got_path.strip_prefix(root_path).unwrap(); format!("path: {:?}, range: {:?}", relative_path, loc.range) } - _ => todo!(), + lsp_types::GotoDefinitionResponse::Array(vec_location) => { + let mut res = String::new(); + for loc in vec_location { + let url = file_path_from_url(&loc.uri).unwrap(); + let got_path = Path::new(&url); + let relative_path = got_path.strip_prefix(root_path.clone()).unwrap(); + res.push_str(&format!( + "path: {:?}, range: {:?}\n", + relative_path, loc.range + )); + } + res + } + lsp_types::GotoDefinitionResponse::Link(vec_location_link) => { + let mut res = String::new(); + for loc in vec_location_link { + let url = file_path_from_url(&loc.target_uri).unwrap(); + let got_path = Path::new(&url); + let relative_path = got_path.strip_prefix(root_path.clone()).unwrap(); + res.push_str(&format!( + "path: {:?}, range: {:?}\n", + relative_path, loc.target_selection_range + )); + } + res + } }, None => "None".to_string(), } } goto_def_test_snapshot!( - goto_system_pkg_test, - "src/test_data/goto_def_test/goto_def.k", + goto_import_pkg_test, + "src/test_data/goto_def_test/goto_import_pkg_test/goto_import_pkg_test.k", + 1, + 11 + ); + + goto_def_test_snapshot!( + goto_pkg_prefix_def_test, + "src/test_data/goto_def_test/goto_pkg_prefix_def_test/goto_pkg_prefix_def_test.k", 3, + 7 + ); + + goto_def_test_snapshot!( + goto_var_def_in_config_and_config_if_test1, + "src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k", + 7, + 36 + ); + + goto_def_test_snapshot!( + goto_var_def_in_config_and_config_if_test2, + "src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k", + 7, + 44 + ); + + goto_def_test_snapshot!( + goto_var_def_in_config_and_config_if_test3, + "src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k", + 4, + 11 + ); + + goto_def_test_snapshot!( + goto_var_def_in_config_and_config_if_test4, + "src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k", + 7, + 10 + ); + + goto_def_test_snapshot!( + goto_var_def_in_dict_comp_test1, + "src/test_data/goto_def_test/goto_var_def_in_dict_comp_test/goto_var_def_in_dict_comp_test.k", + 5, + 68 + ); + + goto_def_test_snapshot!( + goto_var_def_in_dict_comp_test2, + "src/test_data/goto_def_test/goto_var_def_in_dict_comp_test/goto_var_def_in_dict_comp_test.k", + 5, + 61 + ); + + goto_def_test_snapshot!( + test_goto_identifier_names1, + "src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k", + 13, + 5 + ); + + goto_def_test_snapshot!( + test_goto_identifier_names2, + "src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k", + 13, + 8 + ); + + goto_def_test_snapshot!( + test_goto_identifier_names3, + "src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k", + 13, + 12 + ); + + goto_def_test_snapshot!( + goto_local_var_def_test1, + "src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k", + 7, + 11 + ); + + goto_def_test_snapshot!( + goto_local_var_def_test2, + "src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k", + 9, + 11 + ); + + goto_def_test_snapshot!( + goto_local_var_def_test3, + "src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k", + 11, + 11 + ); + + goto_def_test_snapshot!( + goto_lambda_param_goto_def1, + "src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k", + 2, + 5 + ); + + goto_def_test_snapshot!( + goto_lambda_param_goto_def2, + "src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k", + 2, + 9 + ); + + // To implement + goto_def_test_snapshot!( + goto_system_pkg_test, + "src/test_data/goto_def_test/goto_system_pkg_test/goto_system_pkg_test.k", + 1, 1 ); + goto_def_test_snapshot!( + lambda_local_var_test, + "src/test_data/goto_def_test/lambda_local_var_test/lambda_local_var_test.k", + 2, + 9 + ); + goto_def_test_snapshot!( goto_dict_to_schema_attr_test1, "src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k", @@ -772,4 +324,102 @@ mod tests { 33, 11 ); + + goto_def_test_snapshot!( + list_if_expr_test, + "src/test_data/goto_def_test/list_if_expr_test/list_if_expr_test.k", + 3, + 8 + ); + + goto_def_test_snapshot!( + goto_identifier_def_test, + "src/test_data/goto_def_test/goto_identifier_def_test/goto_identifier_def_test.k", + 8, + 6 + ); + + goto_def_test_snapshot!( + complex_select_goto_def, + "src/test_data/goto_def_test/complex_select_goto_def/complex_select_goto_def.k", + 13, + 22 + ); + + goto_def_test_snapshot!( + schema_attribute_def_goto_def, + "src/test_data/goto_def_test/schema_attribute_def_goto_def/schema_attribute_def_goto_def.k", + 2, + 5 + ); + + goto_def_test_snapshot!( + config_desuger_def_goto_def, + "src/test_data/goto_def_test/config_desuger_def_goto_def/config_desuger_def_goto_def.k", + 7, + 9 + ); + + goto_def_test_snapshot!( + goto_schema_attr_ty_def_test5, + "src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k", + 7, + 28 + ); + + goto_def_test_snapshot!( + goto_schema_attr_ty_def_test4, + "src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k", + 7, + 17 + ); + + goto_def_test_snapshot!( + goto_schema_attr_ty_def_test3, + "src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k", + 6, + 22 + ); + + goto_def_test_snapshot!( + goto_schema_attr_ty_def_test2, + "src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k", + 5, + 15 + ); + + goto_def_test_snapshot!( + goto_schema_attr_ty_def_test1, + "src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k", + 4, + 15 + ); + + goto_def_test_snapshot!( + goto_assign_type_test, + "src/test_data/goto_def_test/goto_assign_type_test/goto_assign_type_test.k", + 5, + 17 + ); + + goto_def_test_snapshot!( + goto_schema_def_test, + "src/test_data/goto_def_test/goto_schema_def_test/goto_schema_def_test.k", + 3, + 11 + ); + + goto_def_test_snapshot!( + goto_schema_attr_def_test1, + "src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k", + 4, + 7 + ); + + goto_def_test_snapshot!( + goto_schema_attr_def_test2, + "src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k", + 18, + 12 + ); } diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__complex_select_goto_def.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__complex_select_goto_def.snap new file mode 100644 index 000000000..5ea864a56 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__complex_select_goto_def.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/complex_select_goto_def/complex_select_goto_def.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(22), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/complex_select_goto_def/complex_select_goto_def.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 9 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__config_desuger_def_goto_def.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__config_desuger_def_goto_def.snap new file mode 100644 index 000000000..37b9346a4 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__config_desuger_def_goto_def.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/config_desuger_def_goto_def/config_desuger_def_goto_def.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(9), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/config_desuger_def_goto_def/config_desuger_def_goto_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_assign_type_test.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_assign_type_test.snap new file mode 100644 index 000000000..e92020b19 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_assign_type_test.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_assign_type_test/goto_assign_type_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 5, column : Some(17), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_assign_type_test/goto_assign_type_test.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 15 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test1.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test1.snap index 24ace7572..e8407d4a1 100644 --- a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test1.snap +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test1.snap @@ -1,5 +1,5 @@ --- source: tools/src/LSP/src/goto_def.rs -expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(15), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })" +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(15), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" --- "path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 1, character: 4 }, end: Position { line: 1, character: 8 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test2.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test2.snap index 31e11326f..23726a60c 100644 --- a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test2.snap +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test2.snap @@ -1,5 +1,5 @@ --- source: tools/src/LSP/src/goto_def.rs -expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 15, column : Some(7), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })" +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 15, column : Some(7), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" --- "path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 8 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test3.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test3.snap index c16327319..ef93168c0 100644 --- a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test3.snap +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test3.snap @@ -1,5 +1,5 @@ --- source: tools/src/LSP/src/goto_def.rs -expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 19, column : Some(7), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })" +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 19, column : Some(7), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" --- "path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 9, character: 4 }, end: Position { line: 9, character: 8 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test4.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test4.snap index 8ba371b50..52ed0ea4d 100644 --- a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test4.snap +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test4.snap @@ -1,5 +1,5 @@ --- source: tools/src/LSP/src/goto_def.rs -expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 26, column : Some(11), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })" +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 26, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" --- "path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 8 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test5.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test5.snap index 0c8a57a2f..a4736ebef 100644 --- a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test5.snap +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_dict_to_schema_attr_test5.snap @@ -1,5 +1,5 @@ --- source: tools/src/LSP/src/goto_def.rs -expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\")\n ; let pos = KCLPos\n { filename : file.clone(), line : 33, column : Some(11), } ; let res =\n goto_def(& pos, & gs) ; fmt_resp(& res)\n })" +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 33, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" --- "path: \"src/test_data/goto_def_test/dict_to_schema/dict_to_schema.k\", range: Range { start: Position { line: 9, character: 4 }, end: Position { line: 9, character: 8 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_def_test.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_def_test.snap new file mode 100644 index 000000000..eef18153a --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_def_test.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_identifier_def_test/goto_identifier_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 8, column : Some(6), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_identifier_def_test/goto_identifier_def_test.k\", range: Range { start: Position { line: 2, character: 0 }, end: Position { line: 2, character: 1 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_names1.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_names1.snap new file mode 100644 index 000000000..d8297444c --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_names1.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(5), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\", range: Range { start: Position { line: 8, character: 0 }, end: Position { line: 8, character: 2 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_names2.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_names2.snap new file mode 100644 index 000000000..eb955623b --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_names2.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(8), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\", range: Range { start: Position { line: 6, character: 4 }, end: Position { line: 6, character: 5 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_names3.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_names3.snap new file mode 100644 index 000000000..3cee1f4a6 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_identifier_names3.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 13, column : Some(12), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k\", range: Range { start: Position { line: 3, character: 4 }, end: Position { line: 3, character: 8 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_import_pkg_test.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_import_pkg_test.snap new file mode 100644 index 000000000..cc4b3b84b --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_import_pkg_test.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_import_pkg_test/goto_import_pkg_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 1, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 0 }, end: Position { line: 0, character: 0 } }\npath: \"src/test_data/goto_def_test/pkg/schema_def1.k\", range: Range { start: Position { line: 0, character: 0 }, end: Position { line: 0, character: 0 } }\n" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_lambda_param_goto_def1.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_lambda_param_goto_def1.snap new file mode 100644 index 000000000..a5c3e9f36 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_lambda_param_goto_def1.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 2, column : Some(5), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k\", range: Range { start: Position { line: 0, character: 14 }, end: Position { line: 0, character: 15 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_lambda_param_goto_def2.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_lambda_param_goto_def2.snap new file mode 100644 index 000000000..a00655f0a --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_lambda_param_goto_def2.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 2, column : Some(9), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k\", range: Range { start: Position { line: 0, character: 22 }, end: Position { line: 0, character: 23 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_local_var_def_test1.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_local_var_def_test1.snap new file mode 100644 index 000000000..0b5930b7e --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_local_var_def_test1.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 9 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_local_var_def_test2.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_local_var_def_test2.snap new file mode 100644 index 000000000..99fe6b949 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_local_var_def_test2.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 9, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 9 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_local_var_def_test3.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_local_var_def_test3.snap new file mode 100644 index 000000000..752c4ef3e --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_local_var_def_test3.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 11, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 9 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_pkg_prefix_def_test.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_pkg_prefix_def_test.snap new file mode 100644 index 000000000..eb7d3146f --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_pkg_prefix_def_test.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_pkg_prefix_def_test/goto_pkg_prefix_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 3, column : Some(7), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 0 }, end: Position { line: 0, character: 0 } }\npath: \"src/test_data/goto_def_test/pkg/schema_def1.k\", range: Range { start: Position { line: 0, character: 0 }, end: Position { line: 0, character: 0 } }\n" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_def_test1.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_def_test1.snap new file mode 100644 index 000000000..b9775a94e --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_def_test1.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 4, column : Some(7), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 4, character: 4 }, end: Position { line: 4, character: 8 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_def_test2.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_def_test2.snap new file mode 100644 index 000000000..113c0f3a4 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_def_test2.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 18, column : Some(12), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k\", range: Range { start: Position { line: 8, character: 4 }, end: Position { line: 8, character: 8 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test1.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test1.snap new file mode 100644 index 000000000..ddc029b22 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test1.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 4, column : Some(15), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test2.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test2.snap new file mode 100644 index 000000000..e3787f24f --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test2.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 5, column : Some(15), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test3.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test3.snap new file mode 100644 index 000000000..a4951e1bb --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test3.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 6, column : Some(22), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test4.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test4.snap new file mode 100644 index 000000000..0b1969f76 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test4.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(17), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test5.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test5.snap new file mode 100644 index 000000000..c40e21636 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_attr_ty_def_test5.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(28), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/pkg/schema_def1.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 14 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_def_test.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_def_test.snap new file mode 100644 index 000000000..08656bbf6 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_schema_def_test.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_schema_def_test/goto_schema_def_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 3, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/pkg/schema_def.k\", range: Range { start: Position { line: 0, character: 7 }, end: Position { line: 0, character: 13 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_system_pkg_test.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_system_pkg_test.snap index 1cd5643cd..11cd85e48 100644 --- a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_system_pkg_test.snap +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_system_pkg_test.snap @@ -1,5 +1,5 @@ --- source: tools/src/LSP/src/goto_def.rs -expression: "format!(\"{:?}\",\n {\n let(file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_def.k\") ; let pos\n = KCLPos { filename : file.clone(), line : 3, column : Some(1), } ;\n let res = goto_def(& pos, & gs) ; fmt_resp(& res)\n })" +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_system_pkg_test/goto_system_pkg_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 1, column : Some(1), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" --- "None" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test1.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test1.snap new file mode 100644 index 000000000..b18dd490e --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test1.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(36), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\", range: Range { start: Position { line: 5, character: 11 }, end: Position { line: 5, character: 14 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test2.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test2.snap new file mode 100644 index 000000000..1270eda3b --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test2.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(44), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\", range: Range { start: Position { line: 5, character: 16 }, end: Position { line: 5, character: 21 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test3.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test3.snap new file mode 100644 index 000000000..0ab0496d3 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test3.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 4, column : Some(11), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\", range: Range { start: Position { line: 10, character: 6 }, end: Position { line: 10, character: 10 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test4.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test4.snap new file mode 100644 index 000000000..a21dbcdb8 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_config_and_config_if_test4.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 7, column : Some(10), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k\", range: Range { start: Position { line: 10, character: 6 }, end: Position { line: 10, character: 10 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_dict_comp_test1.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_dict_comp_test1.snap new file mode 100644 index 000000000..70df4e272 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_dict_comp_test1.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_var_def_in_dict_comp_test/goto_var_def_in_dict_comp_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 5, column : Some(68), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_var_def_in_dict_comp_test/goto_var_def_in_dict_comp_test.k\", range: Range { start: Position { line: 4, character: 143 }, end: Position { line: 4, character: 145 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_dict_comp_test2.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_dict_comp_test2.snap new file mode 100644 index 000000000..76986da90 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__goto_var_def_in_dict_comp_test2.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/goto_var_def_in_dict_comp_test/goto_var_def_in_dict_comp_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 5, column : Some(61), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/goto_var_def_in_dict_comp_test/goto_var_def_in_dict_comp_test.k\", range: Range { start: Position { line: 4, character: 143 }, end: Position { line: 4, character: 145 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__lambda_local_var_test.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__lambda_local_var_test.snap new file mode 100644 index 000000000..297eac823 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__lambda_local_var_test.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/lambda_local_var_test/lambda_local_var_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 2, column : Some(9), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/lambda_local_var_test/lambda_local_var_test.k\", range: Range { start: Position { line: 0, character: 11 }, end: Position { line: 0, character: 12 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__list_if_expr_test.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__list_if_expr_test.snap new file mode 100644 index 000000000..06c2bba9d --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__list_if_expr_test.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/list_if_expr_test/list_if_expr_test.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 3, column : Some(8), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/list_if_expr_test/list_if_expr_test.k\", range: Range { start: Position { line: 0, character: 0 }, end: Position { line: 0, character: 1 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__schema_attribute_def_goto_def.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__schema_attribute_def_goto_def.snap new file mode 100644 index 000000000..759784e72 --- /dev/null +++ b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__goto_def__tests__schema_attribute_def_goto_def.snap @@ -0,0 +1,5 @@ +--- +source: tools/src/LSP/src/goto_def.rs +expression: "format!(\"{:?}\",\n {\n let (file, _program, _, gs) =\n compile_test_file(\"src/test_data/goto_def_test/schema_attribute_def_goto_def/schema_attribute_def_goto_def.k\");\n let pos = KCLPos\n { filename : file.clone(), line : 2, column : Some(5), }; let res =\n goto_def(& pos, & gs); fmt_resp(& res)\n })" +--- +"path: \"src/test_data/goto_def_test/schema_attribute_def_goto_def/schema_attribute_def_goto_def.k\", range: Range { start: Position { line: 1, character: 4 }, end: Position { line: 1, character: 8 } }" diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__hover__tests__dict_key_in_schema-2.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__hover__tests__dict_key_in_schema-2.snap deleted file mode 100644 index 1f95f47a9..000000000 --- a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__hover__tests__dict_key_in_schema-2.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: tools/src/LSP/src/hover.rs -expression: "format!(\"{:?}\", got)" ---- -Hover { contents: Scalar(LanguageString(LanguageString { language: "kcl", value: "name: int" })), range: None } diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__hover__tests__dict_key_in_schema-3.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__hover__tests__dict_key_in_schema-3.snap deleted file mode 100644 index 1f95f47a9..000000000 --- a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__hover__tests__dict_key_in_schema-3.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: tools/src/LSP/src/hover.rs -expression: "format!(\"{:?}\", got)" ---- -Hover { contents: Scalar(LanguageString(LanguageString { language: "kcl", value: "name: int" })), range: None } diff --git a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__hover__tests__dict_key_in_schema.snap b/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__hover__tests__dict_key_in_schema.snap deleted file mode 100644 index 1f95f47a9..000000000 --- a/kclvm/tools/src/LSP/src/snapshots/kcl_language_server__hover__tests__dict_key_in_schema.snap +++ /dev/null @@ -1,5 +0,0 @@ ---- -source: tools/src/LSP/src/hover.rs -expression: "format!(\"{:?}\", got)" ---- -Hover { contents: Scalar(LanguageString(LanguageString { language: "kcl", value: "name: int" })), range: None } diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/complex_select_goto_def/complex_select_goto_def.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/complex_select_goto_def/complex_select_goto_def.k new file mode 100644 index 000000000..a1abceb60 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/complex_select_goto_def/complex_select_goto_def.k @@ -0,0 +1,13 @@ +schema Fib: + n1 = n - 1 + n2 = n1 - 1 + n: int + value: int + if n <= 1: + value = 1 + elif n == 2: + value = 1 + else: + value = Fib {n = n1}.value + Fib {n = n2}.value + +fib8 = Fib {n = 8}.value diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/config_desuger_def_goto_def/config_desuger_def_goto_def.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/config_desuger_def_goto_def/config_desuger_def_goto_def.k new file mode 100644 index 000000000..1c3175ad8 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/config_desuger_def_goto_def/config_desuger_def_goto_def.k @@ -0,0 +1,8 @@ +schema Person: + n: Name + +schema Name: + name: str + +p4 = Person {n.name: "a"} + diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_assign_type_test/goto_assign_type_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_assign_type_test/goto_assign_type_test.k new file mode 100644 index 000000000..6b2d9f4f0 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_assign_type_test/goto_assign_type_test.k @@ -0,0 +1,5 @@ +schema Reviewer: + teams?: [int] + users?: [int] + +reviewers: [Reviewer] = [Reviewer {teams: [1]}] diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_identifier_def_test/goto_identifier_def_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_identifier_def_test/goto_identifier_def_test.k new file mode 100644 index 000000000..195f64d20 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_identifier_def_test/goto_identifier_def_test.k @@ -0,0 +1,8 @@ +import ..pkg + +p = pkg.Person { + name: "alice" + age: 1 +} + +p1 = p diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_import_file_test/goto_import_file_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_import_file_test/goto_import_file_test.k new file mode 100644 index 000000000..e63f728c7 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_import_file_test/goto_import_file_test.k @@ -0,0 +1 @@ +import ..pkg.schema_def diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_import_pkg_test/goto_import_pkg_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_import_pkg_test/goto_import_pkg_test.k new file mode 100644 index 000000000..f175c17db --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_import_pkg_test/goto_import_pkg_test.k @@ -0,0 +1 @@ +import ..pkg diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k new file mode 100644 index 000000000..2fa2a623a --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_lambda_param_goto_def/goto_lambda_param_goto_def.k @@ -0,0 +1,3 @@ +func = lambda x: int, y: int -> int { + x + y +} diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k new file mode 100644 index 000000000..8dd5c96e0 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_local_var_def_test/goto_local_var_def_test.k @@ -0,0 +1,12 @@ +schema Fib: + n1 = n - 1 + n2 = n1 - 1 + n: int + value: int + if n <= 1: + value = 1 + elif n == 2: + value = 1 + else: + value = Fib {n = n1}.value + Fib {n = n2}.value + diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_pkg_prefix_def_test/goto_pkg_prefix_def_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_pkg_prefix_def_test/goto_pkg_prefix_def_test.k new file mode 100644 index 000000000..7ca8eae50 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_pkg_prefix_def_test/goto_pkg_prefix_def_test.k @@ -0,0 +1,7 @@ +import ..pkg + +p = pkg.Person { + name: "alice" + age: 1 +} + diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k new file mode 100644 index 000000000..f106cc0b8 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_schema_attr_def_test/goto_schema_attr_def_test.k @@ -0,0 +1,18 @@ +import ..pkg + +p = pkg.Person { + name: "alice" + age: 1 +} + +schema Name: + name: str + +schema Person: + n: Name + +p2 = Person { + n: Name {name: pkg.m.name} +} + +s = p2.n.name diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k new file mode 100644 index 000000000..ed3910720 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_schema_attr_ty_def_test/goto_schema_attr_ty_def_test.k @@ -0,0 +1,8 @@ +import ..pkg + +schema Person3: + p1: pkg.Person + p2: [pkg.Person] + p3: {str:pkg.Person} + p4: pkg.Person | pkg.Person1 + diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_schema_def_test/goto_schema_def_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_schema_def_test/goto_schema_def_test.k new file mode 100644 index 000000000..7ca8eae50 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_schema_def_test/goto_schema_def_test.k @@ -0,0 +1,7 @@ +import ..pkg + +p = pkg.Person { + name: "alice" + age: 1 +} + diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_system_pkg_test/goto_system_pkg_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_system_pkg_test/goto_system_pkg_test.k new file mode 100644 index 000000000..e69de29bb diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k new file mode 100644 index 000000000..9a0a70022 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_var_def_in_config_and_config_if_test/goto_var_def_in_config_and_config_if_test.k @@ -0,0 +1,11 @@ +params = option("params") +toMatch = params.toMatch +toAdd = params.toAdd +items = [item | { + # If all annotations are matched, patch more annotations + if all key, value in toMatch { + item.metadata.annotations[key] == value + }: + metadata.annotations: toAdd + +} for item in option("items")] diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_var_def_in_dict_comp_test/goto_var_def_in_dict_comp_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_var_def_in_dict_comp_test/goto_var_def_in_dict_comp_test.k new file mode 100644 index 000000000..16d866cb5 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/goto_var_def_in_dict_comp_test/goto_var_def_in_dict_comp_test.k @@ -0,0 +1,8 @@ +capabilities = option("params").capabilities or ["SETUID", "SETFCAP"] +items1 = [item | { + if item.kind == "Pod": + spec.containers: [{ + "securityContext": {"capabilities": {"add" += [cc] if cc not in (container?.securityContext?.capabilities?.drop or []) else [] for cc in capabilities}} + } for container in item.spec.containers] + +} for item in option("items")] diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/lambda_local_var_test/lambda_local_var_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/lambda_local_var_test/lambda_local_var_test.k new file mode 100644 index 000000000..a2c975096 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/lambda_local_var_test/lambda_local_var_test.k @@ -0,0 +1,3 @@ +f = lambda a: [str], b: [str], c: [str] -> [str] { + c + a + b +} diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/list_if_expr_test/list_if_expr_test.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/list_if_expr_test/list_if_expr_test.k new file mode 100644 index 000000000..c0896bc06 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/list_if_expr_test/list_if_expr_test.k @@ -0,0 +1,6 @@ +b = True +command: [str] = [ + if b: + "a" + +] diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/schema_attribute_def_goto_def/schema_attribute_def_goto_def.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/schema_attribute_def_goto_def/schema_attribute_def_goto_def.k new file mode 100644 index 000000000..c0287b6c1 --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/schema_attribute_def_goto_def/schema_attribute_def_goto_def.k @@ -0,0 +1,3 @@ +schema Name: + name: str + diff --git a/kclvm/tools/src/LSP/src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k b/kclvm/tools/src/LSP/src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k new file mode 100644 index 000000000..a36869aea --- /dev/null +++ b/kclvm/tools/src/LSP/src/test_data/goto_def_test/test_goto_identifier_names/test_goto_identifier_names.k @@ -0,0 +1,13 @@ +import ..pkg + +schema Name: + name: str + +schema Person: + n: Name + +p2 = Person { + n: Name {name: pkg.m.name} +} + +s = p2.n.name