From dac7abfdf72cd75f19dfc316ed552c5977e1e8b6 Mon Sep 17 00:00:00 2001 From: Shruti Sharma <98698727+shruti2522@users.noreply.github.com> Date: Wed, 22 May 2024 15:35:27 +0530 Subject: [PATCH] feat: lsp hover keyword highlight (#1331) * feat: syntax highlighting for hover content Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 kcl formatting Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 updated test cases Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 test check Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 add markup Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 resolved func formatting error Signed-off-by: shruti2522 updated test cases Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 updated test cases for tests.rs Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 syntax highlighting with LanguageString Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 updated test case Signed-off-by: shruti2522 updated tests.rs Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 fixed ci Signed-off-by: shruti2522 add pkgpath without override Signed-off-by: shruti2522 updated completion.rs Signed-off-by: shruti2522 updated tests.rs Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 updated doc style Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 updated comment Signed-off-by: shruti2522 added indentation for attrs Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 merge schema attr docs Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 update hover def comment Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 render doc at end Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 removed additional def Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 fix dict_key_in_schema test Signed-off-by: shruti2522 merged rest_sign and attr Signed-off-by: shruti2522 fixed ci Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 * feat: syntax highlighting for hover content Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 kcl formatting Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 updated test cases Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 test check Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 add markup Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 resolved func formatting error Signed-off-by: shruti2522 updated test cases Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 updated test cases for tests.rs Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 syntax highlighting with LanguageString Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 updated test case Signed-off-by: shruti2522 updated tests.rs Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 fixed ci Signed-off-by: shruti2522 add pkgpath without override Signed-off-by: shruti2522 updated completion.rs Signed-off-by: shruti2522 updated tests.rs Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 updated doc style Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 updated comment Signed-off-by: shruti2522 added indentation for attrs Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 merge schema attr docs Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 update hover def comment Signed-off-by: shruti2522 updated tests Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 render doc at end Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 removed additional def Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 fix ci Signed-off-by: shruti2522 fix dict_key_in_schema test Signed-off-by: shruti2522 merged rest_sign and attr Signed-off-by: shruti2522 fixed ci Signed-off-by: shruti2522 fmt check Signed-off-by: shruti2522 feat: syntax highlighting for hover content Signed-off-by: shruti2522 * fmt check Signed-off-by: shruti2522 * added MarkedStringType to hover Signed-off-by: shruti2522 * fmt check Signed-off-by: shruti2522 * add spaces and fix ci Signed-off-by: shruti2522 * fix ci Signed-off-by: shruti2522 * updated hover tests Signed-off-by: shruti2522 * update pkgpath handling Signed-off-by: shruti2522 * fmt check Signed-off-by: shruti2522 --------- Signed-off-by: shruti2522 --- kclvm/sema/src/ty/mod.rs | 15 +-- kclvm/tools/src/LSP/src/completion.rs | 8 +- kclvm/tools/src/LSP/src/hover.rs | 151 +++++++++++++++----------- kclvm/tools/src/LSP/src/tests.rs | 14 +-- 4 files changed, 102 insertions(+), 86 deletions(-) diff --git a/kclvm/sema/src/ty/mod.rs b/kclvm/sema/src/ty/mod.rs index 20255d151..2910beb1e 100644 --- a/kclvm/sema/src/ty/mod.rs +++ b/kclvm/sema/src/ty/mod.rs @@ -293,7 +293,7 @@ impl SchemaType { } } - pub fn schema_ty_signature_str(&self) -> String { + pub fn schema_ty_signature_str(&self) -> (String, String) { let base: String = if let Some(base) = &self.base { format!("({})", base.name) } else { @@ -312,17 +312,10 @@ impl SchemaType { .join(", ") ) }; - let params_str = if !params.is_empty() && !base.is_empty() { - format!("\\{}{}", params, base) - } else if !params.is_empty() { - format!("{}", params) - } else if !base.is_empty() { - format!("{}", base) - } else { - "".to_string() - }; - format!("{}\n\nschema {}{}", self.pkgpath, self.name, params_str) + let rest_sign = format!("schema {}{}{}:", self.name, params, base); + + (self.pkgpath.clone(), rest_sign) } pub fn schema_ty_signature_no_pkg(&self) -> String { diff --git a/kclvm/tools/src/LSP/src/completion.rs b/kclvm/tools/src/LSP/src/completion.rs index bc43309a9..29bf3aa71 100644 --- a/kclvm/tools/src/LSP/src/completion.rs +++ b/kclvm/tools/src/LSP/src/completion.rs @@ -490,7 +490,8 @@ fn schema_ty_to_value_complete_item(schema_ty: &SchemaType) -> KCLCompletionItem ); let detail = { let mut details = vec![]; - details.push(schema_ty.schema_ty_signature_str()); + let (pkgpath, rest_sign) = schema_ty.schema_ty_signature_str(); + details.push(format!("{}\n\n{}", pkgpath, rest_sign)); details.push("Attributes:".to_string()); for (name, attr) in &schema_ty.attrs { details.push(format!( @@ -543,7 +544,8 @@ fn schema_ty_to_value_complete_item(schema_ty: &SchemaType) -> KCLCompletionItem fn schema_ty_to_type_complete_item(schema_ty: &SchemaType) -> KCLCompletionItem { let detail = { let mut details = vec![]; - details.push(schema_ty.schema_ty_signature_str()); + let (pkgpath, rest_sign) = schema_ty.schema_ty_signature_str(); + details.push(format!("{}\n\n{}", pkgpath, rest_sign)); details.push("Attributes:".to_string()); for (name, attr) in &schema_ty.attrs { details.push(format!( @@ -1259,7 +1261,7 @@ mod tests { label: "Person(b){}".to_string(), kind: Some(CompletionItemKind::CLASS), detail: Some( - "__main__\n\nschema Person\\[b: int](Base)\nAttributes:\nc: int" + "__main__\n\nschema Person[b: int](Base):\nAttributes:\nc: int" .to_string() ), documentation: Some(lsp_types::Documentation::String("".to_string())), diff --git a/kclvm/tools/src/LSP/src/hover.rs b/kclvm/tools/src/LSP/src/hover.rs index 5b8fe7ef3..a0574a8af 100644 --- a/kclvm/tools/src/LSP/src/hover.rs +++ b/kclvm/tools/src/LSP/src/hover.rs @@ -9,14 +9,13 @@ use lsp_types::{Hover, HoverContents, MarkedString}; use crate::goto_def::find_def_with_gs; -/// Returns a short text describing element at position. -/// Specifically, the doc for schema and schema attr(todo) - enum MarkedStringType { String, LanguageString, } +/// Returns a short text describing element at position. +/// Specifically, the doc for schema and schema attr(todo) pub(crate) fn hover( _program: &Program, kcl_pos: &KCLPos, @@ -33,25 +32,24 @@ pub(crate) fn hover( // Schema Definition hover // ``` // pkg - // schema Foo(Base)[param: type] + // schema Foo(Base)[param: type]: + // ----------------- // attr1: type // attr2? type - // ``` // ----------------- // doc - // ----------------- // ``` let schema_ty = ty.into_schema_type(); - - let schema_ty_signature_no_pkg = schema_ty.schema_ty_signature_no_pkg(); - - docs.push((schema_ty.pkgpath, MarkedStringType::String)); + let (pkgpath, rest_sign) = schema_ty.schema_ty_signature_str(); + if !pkgpath.is_empty() { + docs.push((pkgpath.clone(), MarkedStringType::String)); + } // The attr of schema_ty does not contain the attrs from inherited base schema. // Use the api provided by GlobalState to get all attrs let module_info = gs.get_packages().get_module_info(&kcl_pos.filename); let schema_attrs = obj.get_all_attributes(gs.get_symbols(), module_info); - let mut attrs = vec![schema_ty_signature_no_pkg]; + let mut attrs: Vec = vec![]; for schema_attr in schema_attrs { if let kclvm_sema::core::symbol::SymbolKind::Attribute = schema_attr.get_kind() @@ -72,7 +70,10 @@ pub(crate) fn hover( )); } } - docs.push((attrs.join("\n"), MarkedStringType::LanguageString)); + + let merged_doc = format!("{}\n{}", rest_sign.clone(), attrs.join("\n")); + docs.push((merged_doc, MarkedStringType::LanguageString)); + if !schema_ty.doc.is_empty() { docs.push((schema_ty.doc.clone(), MarkedStringType::String)); } @@ -146,12 +147,13 @@ pub(crate) fn hover( docs_to_hover(docs) } +// Convert doc to Marked String. This function will convert docs to Markedstrings fn convert_doc_to_marked_string(doc: &(String, MarkedStringType)) -> MarkedString { match doc.1 { MarkedStringType::String => MarkedString::String(doc.0.clone()), MarkedStringType::LanguageString => { MarkedString::LanguageString(lsp_types::LanguageString { - language: "kcl".to_string(), + language: "KCL".to_owned(), value: doc.0.clone(), }) } @@ -161,18 +163,20 @@ fn convert_doc_to_marked_string(doc: &(String, MarkedStringType)) -> MarkedStrin // Convert docs to Hover. This function will convert to // None, Scalar or Array according to the number of positions fn docs_to_hover(docs: Vec<(String, MarkedStringType)>) -> Option { - match docs.len() { + let mut all_docs: Vec = Vec::new(); + + for doc in docs { + all_docs.push(convert_doc_to_marked_string(&doc)); + } + + match all_docs.len() { 0 => None, 1 => Some(Hover { - contents: HoverContents::Scalar(convert_doc_to_marked_string(&docs[0])), + contents: HoverContents::Scalar(all_docs.remove(0)), range: None, }), _ => Some(Hover { - contents: HoverContents::Array( - docs.iter() - .map(|doc| convert_doc_to_marked_string(doc)) - .collect(), - ), + contents: HoverContents::Array(all_docs), range: None, }), } @@ -228,7 +232,7 @@ mod tests { use std::path::PathBuf; use kclvm_error::Position as KCLPos; - use lsp_types::MarkedString; + use lsp_types::{LanguageString, MarkedString}; use proc_macro_crate::bench_test; use crate::tests::compile_test_file; @@ -260,7 +264,7 @@ mod tests { if let MarkedString::LanguageString(s) = vec[1].clone() { assert_eq!( s.value, - "schema Person\n name: str\n age: int".to_string() + "schema Person:\n name: str\n age: int".to_string() ); } else { unreachable!("Wrong type"); @@ -352,14 +356,10 @@ mod tests { assert_eq!(s, "__main__"); } if let MarkedString::LanguageString(s) = vec[1].clone() { - assert_eq!(s.value, "schema Person\n name: str\n age?: int"); - } else { - unreachable!("Wrong type"); + assert_eq!(s.value, "schema Person:\n name: str\n age?: int"); } if let MarkedString::String(s) = vec[2].clone() { assert_eq!(s, "hover doc test"); - } else { - unreachable!("Wrong type"); } } _ => unreachable!("test error"), @@ -380,8 +380,8 @@ mod tests { match got.contents { lsp_types::HoverContents::Array(vec) => { - if let MarkedString::String(s) = vec[0].clone() { - assert_eq!(s, "name: str"); + if let MarkedString::LanguageString(s) = vec[0].clone() { + assert_eq!(s.value, "name: str"); } if let MarkedString::String(s) = vec[1].clone() { assert_eq!(s, "name doc test"); @@ -399,10 +399,10 @@ mod tests { match got.contents { lsp_types::HoverContents::Array(vec) => { - if let MarkedString::String(s) = vec[0].clone() { - assert_eq!(s, "age: int"); + if let MarkedString::LanguageString(s) = vec[0].clone() { + assert_eq!(s.value, "age: int"); } - if let MarkedString::String(s) = vec[1].clone() { + if let MarkedString::String(s) = vec[0].clone() { assert_eq!(s, "age doc test"); } } @@ -424,10 +424,10 @@ mod tests { match got.contents { lsp_types::HoverContents::Array(vec) => { - if let MarkedString::String(s) = vec[0].clone() { - assert_eq!(s, "fn f(x: any) -> any"); + if let MarkedString::LanguageString(s) = vec[0].clone() { + assert_eq!(s.value, "fn f(x: any) -> any"); } - if let MarkedString::String(s) = vec[1].clone() { + if let MarkedString::String(s) = vec[0].clone() { assert_eq!(s, "lambda documents"); } } @@ -450,8 +450,8 @@ mod tests { match got.contents { lsp_types::HoverContents::Array(vec) => { assert_eq!(vec.len(), 2); - if let MarkedString::String(s) = vec[0].clone() { - assert_eq!(s, "fn encode(value: str, encoding: str) -> str"); + if let MarkedString::LanguageString(s) = vec[0].clone() { + assert_eq!(s.value, "fn encode(value: str, encoding: str) -> str"); } if let MarkedString::String(s) = vec[1].clone() { assert_eq!( @@ -476,8 +476,8 @@ mod tests { if let MarkedString::String(s) = vec[0].clone() { assert_eq!(s, "str\n\n"); } - if let MarkedString::String(s) = vec[1].clone() { - assert_eq!(s, "fn count(sub: str, start: int, end: int) -> int"); + if let MarkedString::LanguageString(s) = vec[1].clone() { + assert_eq!(s.value, "fn count(sub: str, start: int, end: int) -> int"); } if let MarkedString::String(s) = vec[2].clone() { assert_eq!(s, "Return the number of non-overlapping occurrences of substring sub in the range [start, end]. Optional arguments start and end are interpreted as in slice notation."); @@ -496,8 +496,8 @@ mod tests { match got.contents { lsp_types::HoverContents::Array(vec) => { assert_eq!(vec.len(), 2); - if let MarkedString::String(s) = vec[0].clone() { - assert_eq!(s, "fn print() -> NoneType"); + if let MarkedString::LanguageString(s) = vec[0].clone() { + assert_eq!(s.value, "fn print() -> NoneType"); } if let MarkedString::String(s) = vec[1].clone() { assert_eq!(s, "Prints the values to a stream, or to the system stdout by default.\n\nOptional keyword arguments:\n\nsep: string inserted between values, default a space.\n\nend: string appended after the last value, default a newline."); @@ -519,8 +519,8 @@ mod tests { let got = hover(&program, &pos, &gs).unwrap(); match got.contents { lsp_types::HoverContents::Scalar(marked_string) => { - if let MarkedString::String(s) = marked_string { - assert_eq!(s, "value: int"); + if let MarkedString::LanguageString(s) = marked_string { + assert_eq!(s.value, "value: int"); } } _ => unreachable!("test error"), @@ -539,8 +539,8 @@ mod tests { let got = hover(&program, &pos, &gs).unwrap(); match got.contents { lsp_types::HoverContents::Scalar(marked_string) => { - if let MarkedString::String(s) = marked_string { - assert_eq!(s, "result: {str:str}"); + if let MarkedString::LanguageString(s) = marked_string { + assert_eq!(s.value, "result: {str:str}"); } } _ => unreachable!("test error"), @@ -563,8 +563,8 @@ mod tests { if let MarkedString::String(s) = vec[0].clone() { assert_eq!(s, "str\n\n"); } - if let MarkedString::String(s) = vec[1].clone() { - assert_eq!(s, "fn capitalize() -> str"); + if let MarkedString::LanguageString(s) = vec[1].clone() { + assert_eq!(s.value, "fn capitalize() -> str"); } if let MarkedString::String(s) = vec[2].clone() { assert_eq!(s, "Return a copy of the string with its first character capitalized and the rest lowercased."); @@ -590,8 +590,8 @@ mod tests { if let MarkedString::String(s) = vec[0].clone() { assert_eq!(s, "fib"); } - if let MarkedString::String(s) = vec[1].clone() { - assert_eq!(s, "schema Fib\n\n n: int\n\n value: int"); + if let MarkedString::LanguageString(s) = vec[1].clone() { + assert_eq!(s.value, "schema Fib:\n n: int\n value: int"); } } _ => unreachable!("test error"), @@ -610,8 +610,8 @@ mod tests { let got = hover(&program, &pos, &gs).unwrap(); match got.contents { lsp_types::HoverContents::Scalar(marked_string) => { - if let MarkedString::String(s) = marked_string { - assert_eq!(s, "stratege: str"); + if let MarkedString::LanguageString(s) = marked_string { + assert_eq!(s.value, "stratege: str"); } } _ => unreachable!("test error"), @@ -630,8 +630,8 @@ mod tests { let got = hover(&program, &pos, &gs).unwrap(); match got.contents { lsp_types::HoverContents::Scalar(marked_string) => { - if let MarkedString::String(s) = marked_string { - assert_eq!(s, "n1: int"); + if let MarkedString::LanguageString(s) = marked_string { + assert_eq!(s.value, "n1: int"); } } _ => unreachable!("test error"), @@ -648,11 +648,15 @@ mod tests { column: Some(1), }; let got = hover(&program, &pos, &gs).unwrap(); - let expect_content = vec![MarkedString::LanguageString(lsp_types::LanguageString { - language: "kcl".to_string(), - value: "fn deprecated(version: str, reason: str, strict: bool) -> any".to_string(), + let expect_content = vec![ + MarkedString::LanguageString(LanguageString { + language: "KCL".to_string(), + value: "fn deprecated(version: str, reason: str, strict: bool) -> any".to_string(), }), - MarkedString::String("This decorator is used to get the deprecation message according to the wrapped key-value pair.".to_string())]; + MarkedString::String( + "This decorator is used to get the deprecation message according to the wrapped key-value pair.".to_string(), + ), + ]; match got.contents { lsp_types::HoverContents::Array(vec) => { assert_eq!(vec, expect_content) @@ -685,12 +689,11 @@ mod tests { }; let got = hover(&program, &pos, &gs).unwrap(); - let expect_content: Vec = vec![ + let expect_content = vec![ MarkedString::String("__main__".to_string()), - MarkedString::LanguageString(lsp_types::LanguageString { - language: "kcl".to_string(), - value: "schema Data1\\[m: {str:str}](Data)\n name: str\n age: int" - .to_string(), + MarkedString::LanguageString(LanguageString { + language: "KCL".to_string(), + value: "schema Data1[m: {str:str}](Data):\n name: str\n age: int".to_string(), }), ]; @@ -713,7 +716,15 @@ mod tests { column: Some(5), }; let got = hover(&program, &pos, &gs).unwrap(); - insta::assert_snapshot!(format!("{:?}", got)); + + match got.contents { + lsp_types::HoverContents::Scalar(marked_string) => { + if let MarkedString::LanguageString(s) = marked_string { + assert_eq!(s.value, "name: int"); + } + } + _ => unreachable!("test error"), + } let pos = KCLPos { filename: file.clone(), @@ -721,7 +732,12 @@ mod tests { column: Some(5), }; let got = hover(&program, &pos, &gs).unwrap(); - insta::assert_snapshot!(format!("{:?}", got)); + let expected = + lsp_types::HoverContents::Scalar(MarkedString::LanguageString(LanguageString { + language: "KCL".to_string(), + value: "name: int".to_string(), + })); + assert_eq!(got.contents, expected); let pos = KCLPos { filename: file.clone(), @@ -729,6 +745,11 @@ mod tests { column: Some(5), }; let got = hover(&program, &pos, &gs).unwrap(); - insta::assert_snapshot!(format!("{:?}", got)); + let expected = + lsp_types::HoverContents::Scalar(MarkedString::LanguageString(LanguageString { + language: "KCL".to_string(), + value: "name: int".to_string(), + })); + assert_eq!(got.contents, expected); } } diff --git a/kclvm/tools/src/LSP/src/tests.rs b/kclvm/tools/src/LSP/src/tests.rs index 52539a12b..f55d05173 100644 --- a/kclvm/tools/src/LSP/src/tests.rs +++ b/kclvm/tools/src/LSP/src/tests.rs @@ -1171,8 +1171,8 @@ fn hover_test() { contents: HoverContents::Array(vec![ MarkedString::String("__main__".to_string()), MarkedString::LanguageString(lsp_types::LanguageString { - language: "kcl".to_string(), - value: "schema Person\n name: str\n age?: int".to_string() + language: "KCL".to_string(), + value: "schema Person:\n name: str\n age?: int".to_string() }), MarkedString::String("hover doc test".to_string()), ]), @@ -1230,7 +1230,7 @@ fn hover_assign_in_lambda_test() { to_json(Hover { contents: HoverContents::Scalar(MarkedString::LanguageString( lsp_types::LanguageString { - language: "kcl".to_string(), + language: "KCL".to_string(), value: "images: [str]".to_string() } )), @@ -1674,8 +1674,8 @@ fn konfig_hover_test_main() { let expect: Vec = vec![ MarkedString::String("base.pkg.kusion_models.kube.frontend".to_string()), MarkedString::LanguageString(lsp_types::LanguageString { - language: "kcl".to_string(), - value: "schema Server\n name?: str\n workloadType: str(Deployment) | str(StatefulSet)\n renderType?: str(Server) | str(KubeVelaApplication)\n replicas: int\n image: str\n schedulingStrategy: SchedulingStrategy\n mainContainer: Main\n sidecarContainers?: [Sidecar]\n initContainers?: [Sidecar]\n useBuiltInLabels?: bool\n labels?: {str:str}\n annotations?: {str:str}\n useBuiltInSelector?: bool\n selector?: {str:str}\n podMetadata?: ObjectMeta\n volumes?: [Volume]\n needNamespace?: bool\n enableMonitoring?: bool\n configMaps?: [ConfigMap]\n secrets?: [Secret]\n services?: [Service]\n ingresses?: [Ingress]\n serviceAccount?: ServiceAccount\n storage?: ObjectStorage\n database?: DataBase".to_string() + language: "KCL".to_string(), + value: "schema Server:\n name?: str\n workloadType: str(Deployment) | str(StatefulSet)\n renderType?: str(Server) | str(KubeVelaApplication)\n replicas: int\n image: str\n schedulingStrategy: SchedulingStrategy\n mainContainer: Main\n sidecarContainers?: [Sidecar]\n initContainers?: [Sidecar]\n useBuiltInLabels?: bool\n labels?: {str:str}\n annotations?: {str:str}\n useBuiltInSelector?: bool\n selector?: {str:str}\n podMetadata?: ObjectMeta\n volumes?: [Volume]\n needNamespace?: bool\n enableMonitoring?: bool\n configMaps?: [ConfigMap]\n secrets?: [Secret]\n services?: [Service]\n ingresses?: [Ingress]\n serviceAccount?: ServiceAccount\n storage?: ObjectStorage\n database?: DataBase".to_string() }), MarkedString::String("Server is abstaction of Deployment and StatefulSet.".to_string()), ]; @@ -1695,7 +1695,7 @@ fn konfig_hover_test_main() { HoverContents::Array(arr) => { let expect: Vec = vec![ MarkedString::LanguageString(lsp_types::LanguageString { - language: "kcl".to_string(), + language: "KCL".to_string(), value: "schedulingStrategy: SchedulingStrategy".to_string(), }), MarkedString::String( @@ -1719,7 +1719,7 @@ fn konfig_hover_test_main() { assert_eq!( s, MarkedString::LanguageString(lsp_types::LanguageString { - language: "kcl".to_string(), + language: "KCL".to_string(), value: "appConfiguration: Server".to_string() }) );