aboutsummaryrefslogtreecommitdiff
path: root/crates/ide/src/display
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide/src/display')
-rw-r--r--crates/ide/src/display/navigation_target.rs37
1 files changed, 9 insertions, 28 deletions
diff --git a/crates/ide/src/display/navigation_target.rs b/crates/ide/src/display/navigation_target.rs
index 9c568c90c..23d885218 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
7use ide_db::{ 7use ide_db::{
8 base_db::{FileId, FileRange, SourceDatabase}, 8 base_db::{FileId, FileRange, SourceDatabase},
9 symbol_index::FileSymbolKind, 9 symbol_index::FileSymbolKind,
10 SymbolKind,
10}; 11};
11use ide_db::{defs::Definition, RootDatabase}; 12use ide_db::{defs::Definition, RootDatabase};
12use syntax::{ 13use syntax::{
@@ -18,30 +19,6 @@ use crate::FileSymbol;
18 19
19use super::short_label::ShortLabel; 20use super::short_label::ShortLabel;
20 21
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub enum SymbolKind {
23 Module,
24 Impl,
25 Field,
26 TypeParam,
27 ConstParam,
28 LifetimeParam,
29 ValueParam,
30 SelfParam,
31 Local,
32 Label,
33 Function,
34 Const,
35 Static,
36 Struct,
37 Enum,
38 Variant,
39 Union,
40 TypeAlias,
41 Trait,
42 Macro,
43}
44
45/// `NavigationTarget` represents and element in the editor's UI which you can 22/// `NavigationTarget` represents and element in the editor's UI which you can
46/// click on to navigate to a particular piece of code. 23/// click on to navigate to a particular piece of code.
47/// 24///
@@ -196,6 +173,7 @@ impl ToNav for FileSymbol {
196 FileSymbolKind::Const => SymbolKind::Const, 173 FileSymbolKind::Const => SymbolKind::Const,
197 FileSymbolKind::Static => SymbolKind::Static, 174 FileSymbolKind::Static => SymbolKind::Static,
198 FileSymbolKind::Macro => SymbolKind::Macro, 175 FileSymbolKind::Macro => SymbolKind::Macro,
176 FileSymbolKind::Union => SymbolKind::Union,
199 }), 177 }),
200 full_range: self.range, 178 full_range: self.range,
201 focus_range: self.name_range, 179 focus_range: self.name_range,
@@ -457,13 +435,16 @@ impl TryToNav for hir::TypeParam {
457 fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> { 435 fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
458 let src = self.source(db)?; 436 let src = self.source(db)?;
459 let full_range = match &src.value { 437 let full_range = match &src.value {
460 Either::Left(it) => it.syntax().text_range(), 438 Either::Left(it) => it
439 .name()
440 .map_or_else(|| it.syntax().text_range(), |name| name.syntax().text_range()),
461 Either::Right(it) => it.syntax().text_range(), 441 Either::Right(it) => it.syntax().text_range(),
462 }; 442 };
463 let focus_range = match &src.value { 443 let focus_range = match &src.value {
464 Either::Left(_) => None, 444 Either::Left(it) => it.name(),
465 Either::Right(it) => it.name().map(|it| it.syntax().text_range()), 445 Either::Right(it) => it.name(),
466 }; 446 }
447 .map(|it| it.syntax().text_range());
467 Some(NavigationTarget { 448 Some(NavigationTarget {
468 file_id: src.file_id.original_file(db), 449 file_id: src.file_id.original_file(db),
469 name: self.name(db).to_string().into(), 450 name: self.name(db).to_string().into(),