diff options
Diffstat (limited to 'crates/ra_ide/src/display.rs')
-rw-r--r-- | crates/ra_ide/src/display.rs | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/crates/ra_ide/src/display.rs b/crates/ra_ide/src/display.rs index 1ec946369..9d413cf0a 100644 --- a/crates/ra_ide/src/display.rs +++ b/crates/ra_ide/src/display.rs | |||
@@ -13,10 +13,46 @@ use ra_syntax::{ | |||
13 | pub(crate) use navigation_target::{ToNav, TryToNav}; | 13 | pub(crate) use navigation_target::{ToNav, TryToNav}; |
14 | pub(crate) use short_label::ShortLabel; | 14 | pub(crate) use short_label::ShortLabel; |
15 | 15 | ||
16 | use ast::VisibilityOwner; | ||
16 | pub use navigation_target::NavigationTarget; | 17 | pub use navigation_target::NavigationTarget; |
18 | use stdx::format_to; | ||
17 | 19 | ||
18 | pub(crate) fn function_label(node: &ast::FnDef) -> String { | 20 | pub(crate) fn function_label(node: &ast::FnDef) -> String { |
19 | function_signature::FunctionSignature::from(node).to_string() | 21 | let mut buf = String::new(); |
22 | if let Some(vis) = node.visibility() { | ||
23 | format_to!(buf, "{} ", vis); | ||
24 | } | ||
25 | if node.async_token().is_some() { | ||
26 | format_to!(buf, "async "); | ||
27 | } | ||
28 | if node.const_token().is_some() { | ||
29 | format_to!(buf, "const "); | ||
30 | } | ||
31 | if node.unsafe_token().is_some() { | ||
32 | format_to!(buf, "unsafe "); | ||
33 | } | ||
34 | if let Some(abi) = node.abi() { | ||
35 | // Keyword `extern` is included in the string. | ||
36 | format_to!(buf, "{} ", abi); | ||
37 | } | ||
38 | if let Some(name) = node.name() { | ||
39 | format_to!(buf, "fn {}", name) | ||
40 | } | ||
41 | if let Some(type_params) = node.type_param_list() { | ||
42 | format_to!(buf, "{}", type_params); | ||
43 | } | ||
44 | if let Some(param_list) = node.param_list() { | ||
45 | format_to!(buf, "{}", param_list); | ||
46 | } | ||
47 | if let Some(ret_type) = node.ret_type() { | ||
48 | if ret_type.type_ref().is_some() { | ||
49 | format_to!(buf, " {}", ret_type); | ||
50 | } | ||
51 | } | ||
52 | if let Some(where_clause) = node.where_clause() { | ||
53 | format_to!(buf, "\n{}", where_clause); | ||
54 | } | ||
55 | buf | ||
20 | } | 56 | } |
21 | 57 | ||
22 | pub(crate) fn const_label(node: &ast::ConstDef) -> String { | 58 | pub(crate) fn const_label(node: &ast::ConstDef) -> String { |