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 
![image](https://user-images.githubusercontent.com/3757771/111132711-f69db600-8579-11eb-8c90-22fd6862d11f.png)

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:
bors[bot] 2021-03-15 10:05:49 +00:00 committed by GitHub
commit 5138baf2ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 59 additions and 40 deletions

View file

@ -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);

View file

@ -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"
);
}