Don't complete non-macro item paths in impls and modules

This commit is contained in:
Lukas Wirth 2021-05-27 04:34:21 +02:00
parent 30948e1ecb
commit f41c983424
6 changed files with 76 additions and 29 deletions

View file

@ -92,9 +92,15 @@ fn test_has_ref_parent() {
}
pub(crate) fn has_item_list_or_source_file_parent(element: SyntaxElement) -> bool {
match not_same_range_ancestor(element) {
Some(it) => it.kind() == SOURCE_FILE || it.kind() == ITEM_LIST,
None => true,
let it = element
.ancestors()
.take_while(|it| it.text_range() == element.text_range())
.last()
.map(|it| (it.kind(), it.parent()));
match it {
Some((_, Some(it))) => it.kind() == SOURCE_FILE || it.kind() == ITEM_LIST,
Some((MACRO_ITEMS, None) | (SOURCE_FILE, None)) => true,
_ => false,
}
}
#[test]