diff options
author | Aleksey Kladov <[email protected]> | 2020-12-17 11:29:05 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-12-18 16:28:48 +0000 |
commit | 55ba353b39db1e9d850f1df943ab6a16e7c15838 (patch) | |
tree | c29c3a31ea9e046d2767dfc189e0ab77b8ffdafe /crates/rust-analyzer/src/to_proto.rs | |
parent | 2465fa02b7aa268d7d711b81417e7717427217c3 (diff) |
Don't expose SyntaxKind from IDE API
SyntaxKind is somewhat of an internal type, but IDE is using it to
basically specify an icon. Let's have a dedicated entity for this
instead.
Diffstat (limited to 'crates/rust-analyzer/src/to_proto.rs')
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 1753bbff2..79caafe80 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -9,10 +9,9 @@ use ide::{ | |||
9 | FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag, | 9 | FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag, |
10 | HighlightedRange, Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, | 10 | HighlightedRange, Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, |
11 | NavigationTarget, ReferenceAccess, ResolvedAssist, Runnable, Severity, SourceChange, | 11 | NavigationTarget, ReferenceAccess, ResolvedAssist, Runnable, Severity, SourceChange, |
12 | SourceFileEdit, TextEdit, TextRange, TextSize, | 12 | SourceFileEdit, SymbolKind, TextEdit, TextRange, TextSize, |
13 | }; | 13 | }; |
14 | use itertools::Itertools; | 14 | use itertools::Itertools; |
15 | use syntax::SyntaxKind; | ||
16 | 15 | ||
17 | use crate::{ | 16 | use crate::{ |
18 | cargo_target_spec::CargoTargetSpec, global_state::GlobalStateSnapshot, | 17 | cargo_target_spec::CargoTargetSpec, global_state::GlobalStateSnapshot, |
@@ -30,21 +29,25 @@ pub(crate) fn range(line_index: &LineIndex, range: TextRange) -> lsp_types::Rang | |||
30 | lsp_types::Range::new(start, end) | 29 | lsp_types::Range::new(start, end) |
31 | } | 30 | } |
32 | 31 | ||
33 | pub(crate) fn symbol_kind(syntax_kind: SyntaxKind) -> lsp_types::SymbolKind { | 32 | pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind { |
34 | match syntax_kind { | 33 | match symbol_kind { |
35 | SyntaxKind::FN => lsp_types::SymbolKind::Function, | 34 | SymbolKind::Function => lsp_types::SymbolKind::Function, |
36 | SyntaxKind::STRUCT => lsp_types::SymbolKind::Struct, | 35 | SymbolKind::Struct => lsp_types::SymbolKind::Struct, |
37 | SyntaxKind::ENUM => lsp_types::SymbolKind::Enum, | 36 | SymbolKind::Enum => lsp_types::SymbolKind::Enum, |
38 | SyntaxKind::VARIANT => lsp_types::SymbolKind::EnumMember, | 37 | SymbolKind::Variant => lsp_types::SymbolKind::EnumMember, |
39 | SyntaxKind::TRAIT => lsp_types::SymbolKind::Interface, | 38 | SymbolKind::Trait => lsp_types::SymbolKind::Interface, |
40 | SyntaxKind::MACRO_CALL => lsp_types::SymbolKind::Function, | 39 | SymbolKind::Macro => lsp_types::SymbolKind::Function, |
41 | SyntaxKind::MODULE => lsp_types::SymbolKind::Module, | 40 | SymbolKind::Module => lsp_types::SymbolKind::Module, |
42 | SyntaxKind::TYPE_ALIAS => lsp_types::SymbolKind::TypeParameter, | 41 | SymbolKind::TypeAlias | SymbolKind::TypeParam => lsp_types::SymbolKind::TypeParameter, |
43 | SyntaxKind::RECORD_FIELD => lsp_types::SymbolKind::Field, | 42 | SymbolKind::Field => lsp_types::SymbolKind::Field, |
44 | SyntaxKind::STATIC => lsp_types::SymbolKind::Constant, | 43 | SymbolKind::Static => lsp_types::SymbolKind::Constant, |
45 | SyntaxKind::CONST => lsp_types::SymbolKind::Constant, | 44 | SymbolKind::Const => lsp_types::SymbolKind::Constant, |
46 | SyntaxKind::IMPL => lsp_types::SymbolKind::Object, | 45 | SymbolKind::Impl => lsp_types::SymbolKind::Object, |
47 | _ => lsp_types::SymbolKind::Variable, | 46 | SymbolKind::Local |
47 | | SymbolKind::SelfParam | ||
48 | | SymbolKind::LifetimeParam | ||
49 | | SymbolKind::DocTest => lsp_types::SymbolKind::Variable, | ||
50 | SymbolKind::Union => lsp_types::SymbolKind::Struct, | ||
48 | } | 51 | } |
49 | } | 52 | } |
50 | 53 | ||