aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/call_info.rs66
1 files changed, 33 insertions, 33 deletions
diff --git a/crates/ra_analysis/src/call_info.rs b/crates/ra_analysis/src/call_info.rs
index edb87be11..1dac95584 100644
--- a/crates/ra_analysis/src/call_info.rs
+++ b/crates/ra_analysis/src/call_info.rs
@@ -121,7 +121,7 @@ impl CallInfo {
121 node.syntax().text().to_string() 121 node.syntax().text().to_string()
122 }; 122 };
123 123
124 if let Some((comment_range, docs)) = CallInfo::extract_doc_comments(node) { 124 if let Some((comment_range, docs)) = extract_doc_comments(node) {
125 let comment_range = comment_range 125 let comment_range = comment_range
126 .checked_sub(node.syntax().range().start()) 126 .checked_sub(node.syntax().range().start())
127 .unwrap(); 127 .unwrap();
@@ -154,51 +154,51 @@ impl CallInfo {
154 } 154 }
155 155
156 Some(CallInfo { 156 Some(CallInfo {
157 parameters: CallInfo::param_list(node), 157 parameters: param_list(node),
158 label: label.trim().to_owned(), 158 label: label.trim().to_owned(),
159 doc, 159 doc,
160 active_parameter: None, 160 active_parameter: None,
161 }) 161 })
162 } 162 }
163}
163 164
164 fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> { 165fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> {
165 if node.doc_comments().count() == 0 { 166 if node.doc_comments().count() == 0 {
166 return None; 167 return None;
167 } 168 }
168
169 let comment_text = node.doc_comment_text();
170 169
171 let (begin, end) = node 170 let comment_text = node.doc_comment_text();
172 .doc_comments()
173 .map(|comment| comment.syntax().range())
174 .map(|range| (range.start().to_usize(), range.end().to_usize()))
175 .fold((std::usize::MAX, std::usize::MIN), |acc, range| {
176 (min(acc.0, range.0), max(acc.1, range.1))
177 });
178 171
179 let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end)); 172 let (begin, end) = node
173 .doc_comments()
174 .map(|comment| comment.syntax().range())
175 .map(|range| (range.start().to_usize(), range.end().to_usize()))
176 .fold((std::usize::MAX, std::usize::MIN), |acc, range| {
177 (min(acc.0, range.0), max(acc.1, range.1))
178 });
180 179
181 Some((range, comment_text)) 180 let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end));
182 }
183 181
184 fn param_list(node: &ast::FnDef) -> Vec<String> { 182 Some((range, comment_text))
185 let mut res = vec![]; 183}
186 if let Some(param_list) = node.param_list() {
187 if let Some(self_param) = param_list.self_param() {
188 res.push(self_param.syntax().text().to_string())
189 }
190 184
191 // Maybe use param.pat here? See if we can just extract the name? 185fn param_list(node: &ast::FnDef) -> Vec<String> {
192 //res.extend(param_list.params().map(|p| p.syntax().text().to_string())); 186 let mut res = vec![];
193 res.extend( 187 if let Some(param_list) = node.param_list() {
194 param_list 188 if let Some(self_param) = param_list.self_param() {
195 .params() 189 res.push(self_param.syntax().text().to_string())
196 .filter_map(|p| p.pat())
197 .map(|pat| pat.syntax().text().to_string()),
198 );
199 } 190 }
200 res 191
192 // Maybe use param.pat here? See if we can just extract the name?
193 //res.extend(param_list.params().map(|p| p.syntax().text().to_string()));
194 res.extend(
195 param_list
196 .params()
197 .filter_map(|p| p.pat())
198 .map(|pat| pat.syntax().text().to_string()),
199 );
201 } 200 }
201 res
202} 202}
203 203
204#[cfg(test)] 204#[cfg(test)]