mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 01:34:21 +00:00
Return all usages inside macros in usage searches
This commit is contained in:
parent
512135920d
commit
72bfbb0691
@ -181,7 +181,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
||||
node: &SyntaxNode,
|
||||
offset: TextSize,
|
||||
) -> Option<N> {
|
||||
self.imp.descend_node_at_offset(node, offset).find_map(N::cast)
|
||||
self.imp.descend_node_at_offset(node, offset).flatten().find_map(N::cast)
|
||||
}
|
||||
|
||||
pub fn hir_file_for(&self, syntax_node: &SyntaxNode) -> HirFileId {
|
||||
@ -235,7 +235,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
||||
return Some(it);
|
||||
}
|
||||
|
||||
self.imp.descend_node_at_offset(node, offset).find_map(N::cast)
|
||||
self.imp.descend_node_at_offset(node, offset).flatten().find_map(N::cast)
|
||||
}
|
||||
|
||||
/// Find an AstNode by offset inside SyntaxNode, if it is inside *MacroCall*,
|
||||
@ -245,7 +245,7 @@ impl<'db, DB: HirDatabase> Semantics<'db, DB> {
|
||||
node: &SyntaxNode,
|
||||
offset: TextSize,
|
||||
) -> impl Iterator<Item = N> + 'slf {
|
||||
self.imp.descend_node_at_offset(node, offset).flat_map(N::cast)
|
||||
self.imp.descend_node_at_offset(node, offset).filter_map(|mut it| it.find_map(N::cast))
|
||||
}
|
||||
|
||||
pub fn resolve_lifetime_param(&self, lifetime: &ast::Lifetime) -> Option<LifetimeParam> {
|
||||
@ -542,11 +542,11 @@ impl<'db> SemanticsImpl<'db> {
|
||||
&self,
|
||||
node: &SyntaxNode,
|
||||
offset: TextSize,
|
||||
) -> impl Iterator<Item = SyntaxNode> + '_ {
|
||||
) -> impl Iterator<Item = impl Iterator<Item = SyntaxNode> + '_> + '_ {
|
||||
// Handle macro token cases
|
||||
node.token_at_offset(offset)
|
||||
.flat_map(move |token| self.descend_into_macros(token))
|
||||
.map(move |it| self.token_ancestors_with_macros(it))
|
||||
.map(move |token| self.descend_into_macros(token))
|
||||
.map(|it| it.into_iter().map(move |it| self.token_ancestors_with_macros(it)))
|
||||
.flatten()
|
||||
}
|
||||
|
||||
|
@ -424,6 +424,7 @@ macro_rules! foo {
|
||||
foo!(bar$0);
|
||||
// ^^^
|
||||
// ^^^
|
||||
// ^^^
|
||||
fn foo() {
|
||||
let bar: bar = bar();
|
||||
// ^^^
|
||||
@ -442,6 +443,7 @@ macro_rules! foo {
|
||||
|
||||
foo!(bar);
|
||||
// ^^^
|
||||
// ^^^
|
||||
fn foo() {
|
||||
let bar: bar$0 = bar();
|
||||
// ^^^
|
||||
|
@ -393,7 +393,7 @@ impl<'a> FindUsages<'a> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(name) = sema.find_node_at_offset_with_descend(&tree, offset) {
|
||||
for name in sema.find_nodes_at_offset_with_descend(&tree, offset) {
|
||||
if match name {
|
||||
ast::NameLike::NameRef(name_ref) => self.found_name_ref(&name_ref, sink),
|
||||
ast::NameLike::Name(name) => self.found_name(&name, sink),
|
||||
@ -410,9 +410,7 @@ impl<'a> FindUsages<'a> {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(ast::NameLike::NameRef(name_ref)) =
|
||||
sema.find_node_at_offset_with_descend(&tree, offset)
|
||||
{
|
||||
for name_ref in sema.find_nodes_at_offset_with_descend(&tree, offset) {
|
||||
if self.found_self_ty_name_ref(self_ty, &name_ref, sink) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user