diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index 8f3db6131ef494..32979b78eb6592 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -410,6 +410,12 @@ pub enum ScriptElementKind { JsxAttribute, #[serde(rename = "string")] String, + #[serde(rename = "link")] + Link, + #[serde(rename = "link name")] + LinkName, + #[serde(rename = "link test")] + LinkText, } impl Default for ScriptElementKind { @@ -418,6 +424,7 @@ impl Default for ScriptElementKind { } } +/// This mirrors the method `convertKind` in `completions.ts` in vscode impl From for lsp::CompletionItemKind { fn from(kind: ScriptElementKind) -> Self { match kind { @@ -468,29 +475,33 @@ impl From for lsp::CompletionItemKind { } } +/// This mirrors `fromProtocolScriptElementKind` in vscode impl From for lsp::SymbolKind { fn from(kind: ScriptElementKind) -> Self { match kind { - ScriptElementKind::ModuleElement => lsp::SymbolKind::Module, - ScriptElementKind::ClassElement => lsp::SymbolKind::Class, - ScriptElementKind::EnumElement => lsp::SymbolKind::Enum, - ScriptElementKind::InterfaceElement => lsp::SymbolKind::Interface, - ScriptElementKind::MemberFunctionElement => lsp::SymbolKind::Method, - ScriptElementKind::MemberVariableElement => lsp::SymbolKind::Property, - ScriptElementKind::MemberGetAccessorElement => lsp::SymbolKind::Property, - ScriptElementKind::MemberSetAccessorElement => lsp::SymbolKind::Property, - ScriptElementKind::VariableElement => lsp::SymbolKind::Variable, - ScriptElementKind::ConstElement => lsp::SymbolKind::Variable, - ScriptElementKind::LocalVariableElement => lsp::SymbolKind::Variable, - ScriptElementKind::FunctionElement => lsp::SymbolKind::Function, - ScriptElementKind::LocalFunctionElement => lsp::SymbolKind::Function, - ScriptElementKind::ConstructSignatureElement => { - lsp::SymbolKind::Constructor - } - ScriptElementKind::ConstructorImplementationElement => { - lsp::SymbolKind::Constructor - } - _ => lsp::SymbolKind::Variable, + ScriptElementKind::ModuleElement => Self::Module, + ScriptElementKind::ClassElement => Self::Class, + ScriptElementKind::EnumElement => Self::Enum, + ScriptElementKind::EnumMemberElement => Self::EnumMember, + ScriptElementKind::InterfaceElement => Self::Interface, + ScriptElementKind::IndexSignatureElement => Self::Method, + ScriptElementKind::CallSignatureElement => Self::Method, + ScriptElementKind::MemberFunctionElement => Self::Method, + ScriptElementKind::MemberVariableElement => Self::Property, + ScriptElementKind::MemberGetAccessorElement => Self::Property, + ScriptElementKind::MemberSetAccessorElement => Self::Property, + ScriptElementKind::VariableElement => Self::Variable, + ScriptElementKind::LetElement => Self::Variable, + ScriptElementKind::ConstElement => Self::Variable, + ScriptElementKind::LocalVariableElement => Self::Variable, + ScriptElementKind::Alias => Self::Variable, + ScriptElementKind::FunctionElement => Self::Function, + ScriptElementKind::LocalFunctionElement => Self::Function, + ScriptElementKind::ConstructSignatureElement => Self::Constructor, + ScriptElementKind::ConstructorImplementationElement => Self::Constructor, + ScriptElementKind::TypeParameterElement => Self::TypeParameter, + ScriptElementKind::String => Self::String, + _ => Self::Variable, } } } diff --git a/cli/tests/testdata/lsp/document_symbol_response.json b/cli/tests/testdata/lsp/document_symbol_response.json index 89d56ef7074c34..54c89cc09e8f0a 100644 --- a/cli/tests/testdata/lsp/document_symbol_response.json +++ b/cli/tests/testdata/lsp/document_symbol_response.json @@ -320,7 +320,7 @@ "children": [ { "name": "value1", - "kind": 13, + "kind": 22, "range": { "start": { "line": 15, @@ -344,7 +344,7 @@ }, { "name": "value2", - "kind": 13, + "kind": 22, "range": { "start": { "line": 15,