mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-03 02:23:20 +00:00
simplify
This commit is contained in:
parent
6f02f176c8
commit
4fa972cffb
@ -121,7 +121,7 @@ impl CallInfo {
|
|||||||
node.syntax().text().to_string()
|
node.syntax().text().to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some((comment_range, docs)) = CallInfo::extract_doc_comments(node) {
|
if let Some((comment_range, docs)) = extract_doc_comments(node) {
|
||||||
let comment_range = comment_range
|
let comment_range = comment_range
|
||||||
.checked_sub(node.syntax().range().start())
|
.checked_sub(node.syntax().range().start())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
@ -154,14 +154,15 @@ impl CallInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Some(CallInfo {
|
Some(CallInfo {
|
||||||
parameters: CallInfo::param_list(node),
|
parameters: param_list(node),
|
||||||
label: label.trim().to_owned(),
|
label: label.trim().to_owned(),
|
||||||
doc,
|
doc,
|
||||||
active_parameter: None,
|
active_parameter: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> {
|
fn extract_doc_comments(node: &ast::FnDef) -> Option<(TextRange, String)> {
|
||||||
if node.doc_comments().count() == 0 {
|
if node.doc_comments().count() == 0 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -179,9 +180,9 @@ impl CallInfo {
|
|||||||
let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end));
|
let range = TextRange::from_to(TextUnit::from_usize(begin), TextUnit::from_usize(end));
|
||||||
|
|
||||||
Some((range, comment_text))
|
Some((range, comment_text))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn param_list(node: &ast::FnDef) -> Vec<String> {
|
fn param_list(node: &ast::FnDef) -> Vec<String> {
|
||||||
let mut res = vec![];
|
let mut res = vec![];
|
||||||
if let Some(param_list) = node.param_list() {
|
if let Some(param_list) = node.param_list() {
|
||||||
if let Some(self_param) = param_list.self_param() {
|
if let Some(self_param) = param_list.self_param() {
|
||||||
@ -198,7 +199,6 @@ impl CallInfo {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user