From 034ddf9abdb380430dbecac2a9207b166d1d2a0d Mon Sep 17 00:00:00 2001 From: he1pa <18012015693@163.com> Date: Tue, 13 Aug 2024 16:00:54 +0800 Subject: [PATCH] feat: Add the prefix `schema` to the name of the document symbol Signed-off-by: he1pa <18012015693@163.com> --- kclvm/tools/src/LSP/src/document_symbol.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/kclvm/tools/src/LSP/src/document_symbol.rs b/kclvm/tools/src/LSP/src/document_symbol.rs index 16c1287f1..cce7d7c81 100644 --- a/kclvm/tools/src/LSP/src/document_symbol.rs +++ b/kclvm/tools/src/LSP/src/document_symbol.rs @@ -66,6 +66,10 @@ pub(crate) fn document_symbol( } schema_symbol.children = Some(children); + schema_symbol.name = format!( + "schema {}", + schema_symbol.name + ); document_symbols .push(schema_symbol.clone()); } @@ -186,7 +190,7 @@ mod tests { let mut res = document_symbol(file.as_str(), &gs).unwrap(); let mut expect = vec![]; expect.push(build_document_symbol( - "Person4", + "schema Person4", SymbolKind::STRUCT, ((0, 7), (0, 14)), Some(vec![build_document_symbol( @@ -206,6 +210,8 @@ mod tests { Some("Person4".to_string()), )); + expect.sort_by(|a, b| a.name.cmp(&b.name)); + match &mut res { DocumentSymbolResponse::Flat(_) => panic!("test failed"), DocumentSymbolResponse::Nested(got) => {