summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-11-09 21:45:40 +1100
committerGitHub <noreply@github.com>2021-11-09 21:45:40 +1100
commit31fde9deba6d4ca55293d60a030babd8d4ce12af (patch)
tree7399ba3da50c2fdb290c4e449cff934ff3a6c4b1
parent22dd1b90c4eb5671decd458cc70935898f9ccf0d (diff)
chore(lsp): align ScriptElementKind to current versions of TypeScript/vscode (#12663)
-rw-r--r--cli/lsp/tsc.rs51
-rw-r--r--cli/tests/testdata/lsp/document_symbol_response.json4
2 files changed, 33 insertions, 22 deletions
diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs
index d5538eb48..fc3695a5b 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<ScriptElementKind> for lsp::CompletionItemKind {
fn from(kind: ScriptElementKind) -> Self {
match kind {
@@ -468,29 +475,33 @@ impl From<ScriptElementKind> for lsp::CompletionItemKind {
}
}
+/// This mirrors `fromProtocolScriptElementKind` in vscode
impl From<ScriptElementKind> 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 89d56ef70..54c89cc09 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,