diff options
Diffstat (limited to 'crates/ra_ide/src/display')
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 40 | ||||
-rw-r--r-- | crates/ra_ide/src/display/short_label.rs | 34 |
2 files changed, 37 insertions, 37 deletions
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index fd245705c..45fbc86ef 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -379,16 +379,16 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option | |||
379 | 379 | ||
380 | match_ast! { | 380 | match_ast! { |
381 | match node { | 381 | match node { |
382 | ast::FnDef(it) => it.doc_comment_text(), | 382 | ast::Fn(it) => it.doc_comment_text(), |
383 | ast::StructDef(it) => it.doc_comment_text(), | 383 | ast::Struct(it) => it.doc_comment_text(), |
384 | ast::EnumDef(it) => it.doc_comment_text(), | 384 | ast::Enum(it) => it.doc_comment_text(), |
385 | ast::TraitDef(it) => it.doc_comment_text(), | 385 | ast::Trait(it) => it.doc_comment_text(), |
386 | ast::Module(it) => it.doc_comment_text(), | 386 | ast::Module(it) => it.doc_comment_text(), |
387 | ast::TypeAliasDef(it) => it.doc_comment_text(), | 387 | ast::TypeAlias(it) => it.doc_comment_text(), |
388 | ast::ConstDef(it) => it.doc_comment_text(), | 388 | ast::Const(it) => it.doc_comment_text(), |
389 | ast::StaticDef(it) => it.doc_comment_text(), | 389 | ast::Static(it) => it.doc_comment_text(), |
390 | ast::RecordFieldDef(it) => it.doc_comment_text(), | 390 | ast::RecordField(it) => it.doc_comment_text(), |
391 | ast::EnumVariant(it) => it.doc_comment_text(), | 391 | ast::Variant(it) => it.doc_comment_text(), |
392 | ast::MacroCall(it) => it.doc_comment_text(), | 392 | ast::MacroCall(it) => it.doc_comment_text(), |
393 | _ => None, | 393 | _ => None, |
394 | } | 394 | } |
@@ -404,16 +404,16 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> | |||
404 | 404 | ||
405 | match_ast! { | 405 | match_ast! { |
406 | match node { | 406 | match node { |
407 | ast::FnDef(it) => it.short_label(), | 407 | ast::Fn(it) => it.short_label(), |
408 | ast::StructDef(it) => it.short_label(), | 408 | ast::Struct(it) => it.short_label(), |
409 | ast::EnumDef(it) => it.short_label(), | 409 | ast::Enum(it) => it.short_label(), |
410 | ast::TraitDef(it) => it.short_label(), | 410 | ast::Trait(it) => it.short_label(), |
411 | ast::Module(it) => it.short_label(), | 411 | ast::Module(it) => it.short_label(), |
412 | ast::TypeAliasDef(it) => it.short_label(), | 412 | ast::TypeAlias(it) => it.short_label(), |
413 | ast::ConstDef(it) => it.short_label(), | 413 | ast::Const(it) => it.short_label(), |
414 | ast::StaticDef(it) => it.short_label(), | 414 | ast::Static(it) => it.short_label(), |
415 | ast::RecordFieldDef(it) => it.short_label(), | 415 | ast::RecordField(it) => it.short_label(), |
416 | ast::EnumVariant(it) => it.short_label(), | 416 | ast::Variant(it) => it.short_label(), |
417 | _ => None, | 417 | _ => None, |
418 | } | 418 | } |
419 | } | 419 | } |
@@ -446,7 +446,7 @@ fn foo() { enum FooInner { } } | |||
446 | 5..13, | 446 | 5..13, |
447 | ), | 447 | ), |
448 | name: "FooInner", | 448 | name: "FooInner", |
449 | kind: ENUM_DEF, | 449 | kind: ENUM, |
450 | container_name: None, | 450 | container_name: None, |
451 | description: Some( | 451 | description: Some( |
452 | "enum FooInner", | 452 | "enum FooInner", |
@@ -462,7 +462,7 @@ fn foo() { enum FooInner { } } | |||
462 | 34..42, | 462 | 34..42, |
463 | ), | 463 | ), |
464 | name: "FooInner", | 464 | name: "FooInner", |
465 | kind: ENUM_DEF, | 465 | kind: ENUM, |
466 | container_name: Some( | 466 | container_name: Some( |
467 | "foo", | 467 | "foo", |
468 | ), | 468 | ), |
diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index 5588130a1..0fdf8e9a5 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs | |||
@@ -1,37 +1,37 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | use ra_syntax::ast::{self, AstNode, NameOwner, TypeAscriptionOwner, VisibilityOwner}; | 3 | use ra_syntax::ast::{self, AstNode, NameOwner, VisibilityOwner}; |
4 | use stdx::format_to; | 4 | use stdx::format_to; |
5 | 5 | ||
6 | pub(crate) trait ShortLabel { | 6 | pub(crate) trait ShortLabel { |
7 | fn short_label(&self) -> Option<String>; | 7 | fn short_label(&self) -> Option<String>; |
8 | } | 8 | } |
9 | 9 | ||
10 | impl ShortLabel for ast::FnDef { | 10 | impl ShortLabel for ast::Fn { |
11 | fn short_label(&self) -> Option<String> { | 11 | fn short_label(&self) -> Option<String> { |
12 | Some(crate::display::function_declaration(self)) | 12 | Some(crate::display::function_declaration(self)) |
13 | } | 13 | } |
14 | } | 14 | } |
15 | 15 | ||
16 | impl ShortLabel for ast::StructDef { | 16 | impl ShortLabel for ast::Struct { |
17 | fn short_label(&self) -> Option<String> { | 17 | fn short_label(&self) -> Option<String> { |
18 | short_label_from_node(self, "struct ") | 18 | short_label_from_node(self, "struct ") |
19 | } | 19 | } |
20 | } | 20 | } |
21 | 21 | ||
22 | impl ShortLabel for ast::UnionDef { | 22 | impl ShortLabel for ast::Union { |
23 | fn short_label(&self) -> Option<String> { | 23 | fn short_label(&self) -> Option<String> { |
24 | short_label_from_node(self, "union ") | 24 | short_label_from_node(self, "union ") |
25 | } | 25 | } |
26 | } | 26 | } |
27 | 27 | ||
28 | impl ShortLabel for ast::EnumDef { | 28 | impl ShortLabel for ast::Enum { |
29 | fn short_label(&self) -> Option<String> { | 29 | fn short_label(&self) -> Option<String> { |
30 | short_label_from_node(self, "enum ") | 30 | short_label_from_node(self, "enum ") |
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | impl ShortLabel for ast::TraitDef { | 34 | impl ShortLabel for ast::Trait { |
35 | fn short_label(&self) -> Option<String> { | 35 | fn short_label(&self) -> Option<String> { |
36 | if self.unsafe_token().is_some() { | 36 | if self.unsafe_token().is_some() { |
37 | short_label_from_node(self, "unsafe trait ") | 37 | short_label_from_node(self, "unsafe trait ") |
@@ -47,43 +47,43 @@ impl ShortLabel for ast::Module { | |||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | impl ShortLabel for ast::TypeAliasDef { | 50 | impl ShortLabel for ast::TypeAlias { |
51 | fn short_label(&self) -> Option<String> { | 51 | fn short_label(&self) -> Option<String> { |
52 | short_label_from_node(self, "type ") | 52 | short_label_from_node(self, "type ") |
53 | } | 53 | } |
54 | } | 54 | } |
55 | 55 | ||
56 | impl ShortLabel for ast::ConstDef { | 56 | impl ShortLabel for ast::Const { |
57 | fn short_label(&self) -> Option<String> { | 57 | fn short_label(&self) -> Option<String> { |
58 | short_label_from_ascribed_node(self, "const ") | 58 | short_label_from_ty(self, self.ty(), "const ") |
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | impl ShortLabel for ast::StaticDef { | 62 | impl ShortLabel for ast::Static { |
63 | fn short_label(&self) -> Option<String> { | 63 | fn short_label(&self) -> Option<String> { |
64 | short_label_from_ascribed_node(self, "static ") | 64 | short_label_from_ty(self, self.ty(), "static ") |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | impl ShortLabel for ast::RecordFieldDef { | 68 | impl ShortLabel for ast::RecordField { |
69 | fn short_label(&self) -> Option<String> { | 69 | fn short_label(&self) -> Option<String> { |
70 | short_label_from_ascribed_node(self, "") | 70 | short_label_from_ty(self, self.ty(), "") |
71 | } | 71 | } |
72 | } | 72 | } |
73 | 73 | ||
74 | impl ShortLabel for ast::EnumVariant { | 74 | impl ShortLabel for ast::Variant { |
75 | fn short_label(&self) -> Option<String> { | 75 | fn short_label(&self) -> Option<String> { |
76 | Some(self.name()?.text().to_string()) | 76 | Some(self.name()?.text().to_string()) |
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | fn short_label_from_ascribed_node<T>(node: &T, prefix: &str) -> Option<String> | 80 | fn short_label_from_ty<T>(node: &T, ty: Option<ast::Type>, prefix: &str) -> Option<String> |
81 | where | 81 | where |
82 | T: NameOwner + VisibilityOwner + TypeAscriptionOwner, | 82 | T: NameOwner + VisibilityOwner, |
83 | { | 83 | { |
84 | let mut buf = short_label_from_node(node, prefix)?; | 84 | let mut buf = short_label_from_node(node, prefix)?; |
85 | 85 | ||
86 | if let Some(type_ref) = node.ascribed_type() { | 86 | if let Some(type_ref) = ty { |
87 | format_to!(buf, ": {}", type_ref.syntax()); | 87 | format_to!(buf, ": {}", type_ref.syntax()); |
88 | } | 88 | } |
89 | 89 | ||