mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Introduce StructureNodeKind
This commit is contained in:
parent
8602f9573b
commit
7d48e04f31
7 changed files with 110 additions and 57 deletions
|
@ -11,7 +11,7 @@ use ide::{
|
|||
AnnotationConfig, FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, Query,
|
||||
RangeInfo, Runnable, RunnableKind, SearchScope, SourceChange, TextEdit,
|
||||
};
|
||||
use ide_db::SymbolKind;
|
||||
use ide_db::{StructureNodeKind, SymbolKind};
|
||||
use itertools::Itertools;
|
||||
use lsp_server::ErrorCode;
|
||||
use lsp_types::{
|
||||
|
@ -289,7 +289,7 @@ pub(crate) fn handle_document_symbol(
|
|||
let doc_symbol = lsp_types::DocumentSymbol {
|
||||
name: symbol.label,
|
||||
detail: symbol.detail,
|
||||
kind: to_proto::symbol_kind(symbol.kind),
|
||||
kind: to_proto::structure_node_kind(symbol.kind),
|
||||
tags: Some(tags),
|
||||
deprecated: Some(symbol.deprecated),
|
||||
range: to_proto::range(&line_index, symbol.node_range),
|
||||
|
|
|
@ -11,7 +11,7 @@ use ide::{
|
|||
Markup, NavigationTarget, ReferenceAccess, RenameError, Runnable, Severity, SourceChange,
|
||||
TextEdit, TextRange, TextSize,
|
||||
};
|
||||
use ide_db::SymbolKind;
|
||||
use ide_db::{StructureNodeKind, SymbolKind};
|
||||
use itertools::Itertools;
|
||||
use serde_json::to_value;
|
||||
|
||||
|
@ -60,7 +60,13 @@ pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind {
|
|||
| SymbolKind::ValueParam
|
||||
| SymbolKind::Label => lsp_types::SymbolKind::Variable,
|
||||
SymbolKind::Union => lsp_types::SymbolKind::Struct,
|
||||
SymbolKind::Region => lsp_types::SymbolKind::Namespace,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn structure_node_kind(kind: StructureNodeKind) -> lsp_types::SymbolKind {
|
||||
match kind {
|
||||
StructureNodeKind::SymbolKind(symbol) => symbol_kind(symbol),
|
||||
StructureNodeKind::Region => lsp_types::SymbolKind::Namespace,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +124,6 @@ pub(crate) fn completion_item_kind(
|
|||
SymbolKind::Local => lsp_types::CompletionItemKind::Variable,
|
||||
SymbolKind::Macro => lsp_types::CompletionItemKind::Method,
|
||||
SymbolKind::Module => lsp_types::CompletionItemKind::Module,
|
||||
SymbolKind::Region => lsp_types::CompletionItemKind::Keyword,
|
||||
SymbolKind::SelfParam => lsp_types::CompletionItemKind::Value,
|
||||
SymbolKind::Static => lsp_types::CompletionItemKind::Value,
|
||||
SymbolKind::Struct => lsp_types::CompletionItemKind::Struct,
|
||||
|
@ -430,7 +435,6 @@ fn semantic_token_type_and_modifiers(
|
|||
SymbolKind::TypeAlias => semantic_tokens::TYPE_ALIAS,
|
||||
SymbolKind::Trait => lsp_types::SemanticTokenType::INTERFACE,
|
||||
SymbolKind::Macro => lsp_types::SemanticTokenType::MACRO,
|
||||
SymbolKind::Region => lsp_types::SemanticTokenType::NAMESPACE,
|
||||
},
|
||||
HlTag::BuiltinType => semantic_tokens::BUILTIN_TYPE,
|
||||
HlTag::None => semantic_tokens::GENERIC,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue