diff options
author | Jeremy Kolb <[email protected]> | 2019-10-28 00:11:02 +0000 |
---|---|---|
committer | Jeremy Kolb <[email protected]> | 2019-10-28 12:32:22 +0000 |
commit | 55d4b06a53246c144be900877e6ac03237d6f8b4 (patch) | |
tree | e31953e2db157710932d3c689b6e691d92bee6da /crates/ra_ide_api/src/display | |
parent | 5a59bc9fcbbacb3d214e5bb9490f66ccb0abf5cb (diff) |
Add disciminant
Diffstat (limited to 'crates/ra_ide_api/src/display')
-rw-r--r-- | crates/ra_ide_api/src/display/function_signature.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/display/function_signature.rs b/crates/ra_ide_api/src/display/function_signature.rs index 0697a0727..6555f8619 100644 --- a/crates/ra_ide_api/src/display/function_signature.rs +++ b/crates/ra_ide_api/src/display/function_signature.rs | |||
@@ -12,9 +12,16 @@ use crate::{ | |||
12 | display::{generic_parameters, where_predicates}, | 12 | display::{generic_parameters, where_predicates}, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | #[derive(Debug)] | ||
16 | pub enum SigKind { | ||
17 | Function, | ||
18 | Struct, | ||
19 | } | ||
20 | |||
15 | /// Contains information about a function signature | 21 | /// Contains information about a function signature |
16 | #[derive(Debug)] | 22 | #[derive(Debug)] |
17 | pub struct FunctionSignature { | 23 | pub struct FunctionSignature { |
24 | pub kind: SigKind, | ||
18 | /// Optional visibility | 25 | /// Optional visibility |
19 | pub visibility: Option<String>, | 26 | pub visibility: Option<String>, |
20 | /// Name of the function | 27 | /// Name of the function |
@@ -59,6 +66,7 @@ impl FunctionSignature { | |||
59 | .collect(); | 66 | .collect(); |
60 | 67 | ||
61 | FunctionSignature { | 68 | FunctionSignature { |
69 | kind: SigKind::Struct, | ||
62 | visibility: node.visibility().map(|n| n.syntax().text().to_string()), | 70 | visibility: node.visibility().map(|n| n.syntax().text().to_string()), |
63 | name: node.name().map(|n| n.text().to_string()), | 71 | name: node.name().map(|n| n.text().to_string()), |
64 | ret_type: node.name().map(|n| n.text().to_string()), | 72 | ret_type: node.name().map(|n| n.text().to_string()), |
@@ -86,6 +94,7 @@ impl From<&'_ ast::FnDef> for FunctionSignature { | |||
86 | } | 94 | } |
87 | 95 | ||
88 | FunctionSignature { | 96 | FunctionSignature { |
97 | kind: SigKind::Function, | ||
89 | visibility: node.visibility().map(|n| n.syntax().text().to_string()), | 98 | visibility: node.visibility().map(|n| n.syntax().text().to_string()), |
90 | name: node.name().map(|n| n.text().to_string()), | 99 | name: node.name().map(|n| n.text().to_string()), |
91 | ret_type: node | 100 | ret_type: node |
@@ -108,7 +117,10 @@ impl Display for FunctionSignature { | |||
108 | } | 117 | } |
109 | 118 | ||
110 | if let Some(name) = &self.name { | 119 | if let Some(name) = &self.name { |
111 | write!(f, "fn {}", name)?; | 120 | match self.kind { |
121 | SigKind::Function => write!(f, "fn {}", name)?, | ||
122 | SigKind::Struct => write!(f, "struct {}", name)?, | ||
123 | } | ||
112 | } | 124 | } |
113 | 125 | ||
114 | if !self.generic_parameters.is_empty() { | 126 | if !self.generic_parameters.is_empty() { |