mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 04:44:57 +00:00
internal: Improve completion tests by checking that the offset is included in the source_range of items
This commit is contained in:
parent
57a9915c1f
commit
582f99d293
2 changed files with 12 additions and 2 deletions
|
@ -214,7 +214,17 @@ pub(crate) fn check_pattern_is_applicable(code: &str, check: impl FnOnce(SyntaxE
|
|||
|
||||
pub(crate) fn get_all_items(config: CompletionConfig, code: &str) -> Vec<CompletionItem> {
|
||||
let (db, position) = position(code);
|
||||
crate::completions(&db, &config, position).map_or_else(Vec::default, Into::into)
|
||||
let res = crate::completions(&db, &config, position).map_or_else(Vec::default, Into::into);
|
||||
// validate
|
||||
res.iter().for_each(|it| {
|
||||
let sr = it.source_range();
|
||||
assert!(
|
||||
sr.contains_inclusive(position.offset),
|
||||
"source range {sr:?} does not contain the offset {:?} of the completion request: {it:?}",
|
||||
position.offset
|
||||
);
|
||||
});
|
||||
res
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue