mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
8021: Enable searching for builtin types r=matklad a=Veykril Not too sure how useful this is for reference search overall, but for completeness sake it should be there  Also enables document highlighting for them. 8022: some clippy::performance fixes r=matklad a=matthiaskrgr use vec![] instead of Vec::new() + push() avoid redundant clones use chars instead of &str for single char patterns in ends_with() and starts_with() allocate some Vecs with capacity to avoid unnecessary resizing Co-authored-by: Lukas Wirth <lukastw97@gmail.com> Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
This commit is contained in:
commit
5138baf2ac
14 changed files with 59 additions and 40 deletions
|
@ -846,9 +846,9 @@ pub(crate) fn handle_references(
|
|||
};
|
||||
|
||||
let decl = if params.context.include_declaration {
|
||||
Some(FileRange {
|
||||
file_id: refs.declaration.nav.file_id,
|
||||
range: refs.declaration.nav.focus_or_full_range(),
|
||||
refs.declaration.map(|decl| FileRange {
|
||||
file_id: decl.nav.file_id,
|
||||
range: decl.nav.focus_or_full_range(),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
@ -1153,14 +1153,12 @@ pub(crate) fn handle_document_highlight(
|
|||
Some(refs) => refs,
|
||||
};
|
||||
|
||||
let decl = if refs.declaration.nav.file_id == position.file_id {
|
||||
Some(DocumentHighlight {
|
||||
range: to_proto::range(&line_index, refs.declaration.nav.focus_or_full_range()),
|
||||
kind: refs.declaration.access.map(to_proto::document_highlight_kind),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let decl = refs.declaration.filter(|decl| decl.nav.file_id == position.file_id).map(|decl| {
|
||||
DocumentHighlight {
|
||||
range: to_proto::range(&line_index, decl.nav.focus_or_full_range()),
|
||||
kind: decl.access.map(to_proto::document_highlight_kind),
|
||||
}
|
||||
});
|
||||
|
||||
let file_refs = refs.references.get(&position.file_id).map_or(&[][..], Vec::as_slice);
|
||||
let mut res = Vec::with_capacity(file_refs.len() + 1);
|
||||
|
|
|
@ -360,11 +360,11 @@ mod tests {
|
|||
"Completion with disjoint edits is valid"
|
||||
);
|
||||
assert!(
|
||||
!all_edits_are_disjoint(&completion_with_disjoint_edits, &[joint_edit.clone()]),
|
||||
!all_edits_are_disjoint(&completion_with_disjoint_edits, &[joint_edit]),
|
||||
"Completion with disjoint edits and joint extra edit is invalid"
|
||||
);
|
||||
assert!(
|
||||
all_edits_are_disjoint(&completion_with_disjoint_edits, &[disjoint_edit_2.clone()]),
|
||||
all_edits_are_disjoint(&completion_with_disjoint_edits, &[disjoint_edit_2]),
|
||||
"Completion with disjoint edits and joint extra edit is valid"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue