Skip to content

Commit 4fa972c

Browse files
committed
simplify
1 parent 6f02f17 commit 4fa972c

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

crates/ra_analysis/src/call_info.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl CallInfo {
121121
node.syntax().text().to_string()
122122
};
123123

124-
if let Some((comment_range, docs)) = CallInfo::extract_doc_comments(node) {
124+
if let Some((comment_range, docs)) = extract_doc_comments(node) {
125125
let comment_range = comment_range
126126
.checked_sub(node.syntax().range().start())
127127
.unwrap();
@@ -154,51 +154,51 @@ impl CallInfo {
154154
}
155155

156156
Some(CallInfo {
157-
parameters: CallInfo::param_list(node),
157+
parameters: param_list(node),
158158
label: label.trim().to_owned(),
159159
doc,
160160
active_parameter: None,
161161
})
162162
}
163+
}
163164

164-
fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> {
165-
if node.doc_comments().count() == 0 {
166-
return None;
167-
}
168-
169-
let comment_text = node.doc_comment_text();
165+
fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> {
166+
if node.doc_comments().count() == 0 {
167+
return None;
168+
}
170169

171-
let (begin, end) = node
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-
});
170+
let comment_text = node.doc_comment_text();
178171

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+
});
180179

181-
Some((range, comment_text))
182-
}
180+
let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end));
183181

184-
fn param_list(node: &ast::FnDef) -> Vec<String> {
185-
let mut res = vec![];
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-
}
182+
Some((range, comment_text))
183+
}
190184

191-
// Maybe use param.pat here? See if we can just extract the name?
192-
//res.extend(param_list.params().map(|p| p.syntax().text().to_string()));
193-
res.extend(
194-
param_list
195-
.params()
196-
.filter_map(|p| p.pat())
197-
.map(|pat| pat.syntax().text().to_string()),
198-
);
185+
fn param_list(node: &ast::FnDef) -> Vec<String> {
186+
let mut res = vec![];
187+
if let Some(param_list) = node.param_list() {
188+
if let Some(self_param) = param_list.self_param() {
189+
res.push(self_param.syntax().text().to_string())
199190
}
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+
);
201200
}
201+
res
202202
}
203203

204204
#[cfg(test)]

0 commit comments

Comments
 (0)