diff options
Diffstat (limited to 'crates/ra_ide/src/display/function_signature.rs')
-rw-r--r-- | crates/ra_ide/src/display/function_signature.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs index 324ad9552..ddc53a52b 100644 --- a/crates/ra_ide/src/display/function_signature.rs +++ b/crates/ra_ide/src/display/function_signature.rs | |||
@@ -34,6 +34,8 @@ pub struct FunctionSignature { | |||
34 | pub generic_parameters: Vec<String>, | 34 | pub generic_parameters: Vec<String>, |
35 | /// Parameters of the function | 35 | /// Parameters of the function |
36 | pub parameters: Vec<String>, | 36 | pub parameters: Vec<String>, |
37 | /// Parameter names of the function | ||
38 | pub parameter_names: Vec<String>, | ||
37 | /// Optional return type | 39 | /// Optional return type |
38 | pub ret_type: Option<String>, | 40 | pub ret_type: Option<String>, |
39 | /// Where predicates | 41 | /// Where predicates |
@@ -75,6 +77,7 @@ impl FunctionSignature { | |||
75 | name: node.name().map(|n| n.text().to_string()), | 77 | name: node.name().map(|n| n.text().to_string()), |
76 | ret_type: node.name().map(|n| n.text().to_string()), | 78 | ret_type: node.name().map(|n| n.text().to_string()), |
77 | parameters: params, | 79 | parameters: params, |
80 | parameter_names: vec![], | ||
78 | generic_parameters: generic_parameters(&node), | 81 | generic_parameters: generic_parameters(&node), |
79 | where_predicates: where_predicates(&node), | 82 | where_predicates: where_predicates(&node), |
80 | doc: None, | 83 | doc: None, |
@@ -114,6 +117,7 @@ impl FunctionSignature { | |||
114 | name: Some(name), | 117 | name: Some(name), |
115 | ret_type: None, | 118 | ret_type: None, |
116 | parameters: params, | 119 | parameters: params, |
120 | parameter_names: vec![], | ||
117 | generic_parameters: vec![], | 121 | generic_parameters: vec![], |
118 | where_predicates: vec![], | 122 | where_predicates: vec![], |
119 | doc: None, | 123 | doc: None, |
@@ -134,6 +138,7 @@ impl FunctionSignature { | |||
134 | name: node.name().map(|n| n.text().to_string()), | 138 | name: node.name().map(|n| n.text().to_string()), |
135 | ret_type: None, | 139 | ret_type: None, |
136 | parameters: params, | 140 | parameters: params, |
141 | parameter_names: vec![], | ||
137 | generic_parameters: vec![], | 142 | generic_parameters: vec![], |
138 | where_predicates: vec![], | 143 | where_predicates: vec![], |
139 | doc: None, | 144 | doc: None, |
@@ -157,6 +162,20 @@ impl From<&'_ ast::FnDef> for FunctionSignature { | |||
157 | res | 162 | res |
158 | } | 163 | } |
159 | 164 | ||
165 | fn param_name_list(node: &ast::FnDef) -> Vec<String> { | ||
166 | let mut res = vec![]; | ||
167 | if let Some(param_list) = node.param_list() { | ||
168 | if let Some(self_param) = param_list.self_param() { | ||
169 | res.push(self_param.syntax().text().to_string()) | ||
170 | } | ||
171 | |||
172 | res.extend(param_list.params().map(|param| { | ||
173 | param.pat().map(|pat| pat.syntax().text().to_string()).unwrap_or_default() | ||
174 | })); | ||
175 | } | ||
176 | res | ||
177 | } | ||
178 | |||
160 | FunctionSignature { | 179 | FunctionSignature { |
161 | kind: CallableKind::Function, | 180 | kind: CallableKind::Function, |
162 | visibility: node.visibility().map(|n| n.syntax().text().to_string()), | 181 | visibility: node.visibility().map(|n| n.syntax().text().to_string()), |
@@ -166,6 +185,7 @@ impl From<&'_ ast::FnDef> for FunctionSignature { | |||
166 | .and_then(|r| r.type_ref()) | 185 | .and_then(|r| r.type_ref()) |
167 | .map(|n| n.syntax().text().to_string()), | 186 | .map(|n| n.syntax().text().to_string()), |
168 | parameters: param_list(node), | 187 | parameters: param_list(node), |
188 | parameter_names: param_name_list(node), | ||
169 | generic_parameters: generic_parameters(node), | 189 | generic_parameters: generic_parameters(node), |
170 | where_predicates: where_predicates(node), | 190 | where_predicates: where_predicates(node), |
171 | // docs are processed separately | 191 | // docs are processed separately |