From 563a175fdb9073a548fc2e161d5de0a093b0d74d Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 20 Jan 2021 15:25:34 +0100 Subject: Move SymbolKind to ide_db --- crates/ide/src/display/navigation_target.rs | 25 +------------------------ crates/ide/src/file_structure.rs | 3 +-- crates/ide/src/lib.rs | 2 +- crates/ide/src/runnables.rs | 4 ++-- crates/ide/src/syntax_highlighting.rs | 4 ++-- crates/ide/src/syntax_highlighting/format.rs | 3 ++- crates/ide/src/syntax_highlighting/highlight.rs | 4 ++-- crates/ide/src/syntax_highlighting/tags.rs | 2 +- crates/ide_db/src/lib.rs | 24 ++++++++++++++++++++++++ crates/rust-analyzer/src/handlers.rs | 3 ++- crates/rust-analyzer/src/to_proto.rs | 3 ++- 11 files changed, 40 insertions(+), 37 deletions(-) diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs index 00e601244..8d08e4763 100644 --- a/crates/ide/src/display/navigation_target.rs +++ b/crates/ide/src/display/navigation_target.rs @@ -7,6 +7,7 @@ use hir::{AssocItem, Documentation, FieldSource, HasAttrs, HasSource, InFile, Mo use ide_db::{ base_db::{FileId, FileRange, SourceDatabase}, symbol_index::FileSymbolKind, + SymbolKind, }; use ide_db::{defs::Definition, RootDatabase}; use syntax::{ @@ -18,30 +19,6 @@ use crate::FileSymbol; use super::short_label::ShortLabel; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] -pub enum SymbolKind { - Module, - Impl, - Field, - TypeParam, - ConstParam, - LifetimeParam, - ValueParam, - SelfParam, - Local, - Label, - Function, - Const, - Static, - Struct, - Enum, - Variant, - Union, - TypeAlias, - Trait, - Macro, -} - /// `NavigationTarget` represents and element in the editor's UI which you can /// click on to navigate to a particular piece of code. /// diff --git a/crates/ide/src/file_structure.rs b/crates/ide/src/file_structure.rs index 32556dad3..26793bdb4 100644 --- a/crates/ide/src/file_structure.rs +++ b/crates/ide/src/file_structure.rs @@ -1,10 +1,9 @@ +use ide_db::SymbolKind; use syntax::{ ast::{self, AttrsOwner, GenericParamsOwner, NameOwner}, match_ast, AstNode, SourceFile, SyntaxNode, TextRange, WalkEvent, }; -use crate::SymbolKind; - #[derive(Debug, Clone)] pub struct StructureNode { pub parent: Option, diff --git a/crates/ide/src/lib.rs b/crates/ide/src/lib.rs index 567b8117e..989e94a31 100644 --- a/crates/ide/src/lib.rs +++ b/crates/ide/src/lib.rs @@ -65,7 +65,7 @@ use crate::display::ToNav; pub use crate::{ call_hierarchy::CallItem, diagnostics::{Diagnostic, DiagnosticsConfig, Fix, Severity}, - display::navigation_target::{NavigationTarget, SymbolKind}, + display::navigation_target::NavigationTarget, expand_macro::ExpandedMacro, file_structure::StructureNode, folding_ranges::{Fold, FoldKind}, diff --git a/crates/ide/src/runnables.rs b/crates/ide/src/runnables.rs index 8976f1080..e282b31af 100644 --- a/crates/ide/src/runnables.rs +++ b/crates/ide/src/runnables.rs @@ -3,7 +3,7 @@ use std::fmt; use assists::utils::test_related_attribute; use cfg::CfgExpr; use hir::{AsAssocItem, HasAttrs, HasSource, Semantics}; -use ide_db::{defs::Definition, RootDatabase}; +use ide_db::{defs::Definition, RootDatabase, SymbolKind}; use itertools::Itertools; use syntax::{ ast::{self, AstNode, AttrsOwner}, @@ -12,7 +12,7 @@ use syntax::{ use crate::{ display::{ToNav, TryToNav}, - FileId, NavigationTarget, SymbolKind, + FileId, NavigationTarget, }; #[derive(Debug, Clone)] diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index f2d4da78d..a3d4e4f77 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -13,7 +13,7 @@ mod html; mod tests; use hir::{Name, Semantics}; -use ide_db::RootDatabase; +use ide_db::{RootDatabase, SymbolKind}; use rustc_hash::FxHashMap; use syntax::{ ast::{self, HasFormatSpecifier}, @@ -27,7 +27,7 @@ use crate::{ format::highlight_format_string, highlights::Highlights, macro_rules::MacroRulesHighlighter, tags::Highlight, }, - FileId, HlMod, HlTag, SymbolKind, + FileId, HlMod, HlTag, }; pub(crate) use html::highlight_as_html; diff --git a/crates/ide/src/syntax_highlighting/format.rs b/crates/ide/src/syntax_highlighting/format.rs index a74ca844b..63bff6376 100644 --- a/crates/ide/src/syntax_highlighting/format.rs +++ b/crates/ide/src/syntax_highlighting/format.rs @@ -1,10 +1,11 @@ //! Syntax highlighting for format macro strings. +use ide_db::SymbolKind; use syntax::{ ast::{self, FormatSpecifier, HasFormatSpecifier}, AstNode, AstToken, TextRange, }; -use crate::{syntax_highlighting::highlights::Highlights, HlRange, HlTag, SymbolKind}; +use crate::{syntax_highlighting::highlights::Highlights, HlRange, HlTag}; pub(super) fn highlight_format_string( stack: &mut Highlights, diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 8625ef5df..24fcbb584 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -3,7 +3,7 @@ use hir::{AsAssocItem, Semantics, VariantDef}; use ide_db::{ defs::{Definition, NameClass, NameRefClass}, - RootDatabase, + RootDatabase, SymbolKind, }; use rustc_hash::FxHashMap; use syntax::{ @@ -12,7 +12,7 @@ use syntax::{ SyntaxNode, SyntaxToken, T, }; -use crate::{syntax_highlighting::tags::HlPunct, Highlight, HlMod, HlTag, SymbolKind}; +use crate::{syntax_highlighting::tags::HlPunct, Highlight, HlMod, HlTag}; pub(super) fn element( sema: &Semantics, diff --git a/crates/ide/src/syntax_highlighting/tags.rs b/crates/ide/src/syntax_highlighting/tags.rs index 8dd05ac52..3c02fdb11 100644 --- a/crates/ide/src/syntax_highlighting/tags.rs +++ b/crates/ide/src/syntax_highlighting/tags.rs @@ -3,7 +3,7 @@ use std::{fmt, ops}; -use crate::SymbolKind; +use ide_db::SymbolKind; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Highlight { diff --git a/crates/ide_db/src/lib.rs b/crates/ide_db/src/lib.rs index 118c090d7..ee35d02f5 100644 --- a/crates/ide_db/src/lib.rs +++ b/crates/ide_db/src/lib.rs @@ -134,3 +134,27 @@ fn line_index(db: &dyn LineIndexDatabase, file_id: FileId) -> Arc { let text = db.file_text(file_id); Arc::new(LineIndex::new(&*text)) } + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] +pub enum SymbolKind { + Module, + Impl, + Field, + TypeParam, + ConstParam, + LifetimeParam, + ValueParam, + SelfParam, + Local, + Label, + Function, + Const, + Static, + Struct, + Enum, + Variant, + Union, + TypeAlias, + Trait, + Macro, +} diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 001f3a37d..10cbd7eeb 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs @@ -10,8 +10,9 @@ use std::{ use ide::{ FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, LineIndex, NavigationTarget, - Query, RangeInfo, Runnable, RunnableKind, SearchScope, SourceChange, SymbolKind, TextEdit, + Query, RangeInfo, Runnable, RunnableKind, SearchScope, SourceChange, TextEdit, }; +use ide_db::SymbolKind; use itertools::Itertools; use lsp_server::ErrorCode; use lsp_types::{ diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 9fd32a8c7..18e8a6d22 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -8,8 +8,9 @@ use ide::{ Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation, FileId, FileRange, FileSystemEdit, Fold, FoldKind, Highlight, HlMod, HlPunct, HlRange, HlTag, Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, NavigationTarget, ReferenceAccess, - RenameError, Runnable, Severity, SourceChange, SymbolKind, TextEdit, TextRange, TextSize, + RenameError, Runnable, Severity, SourceChange, TextEdit, TextRange, TextSize, }; +use ide_db::SymbolKind; use itertools::Itertools; use crate::{ -- cgit v1.2.3