Expand description
This module implements a reference search.
First, the element at the cursor position must be either an ast::Name
or ast::NameRef. If it’s an ast::NameRef, at the classification step we
try to resolve the direct tree parent of this element, otherwise we
already have a definition and just need to get its HIR together with
some information that is needed for further steps of searching.
After that, we collect files that might contain references and look
for text occurrences of the identifier. If there’s an ast::NameRef
at the index that the match starts at and its tree parent is
resolved to the search element definition, we get a reference.
Special handling for constructors/initializations: When searching for references to a struct/enum/variant, if the cursor is positioned on:
{after a struct/enum/variant definition(for tuple structs/variants;for unit structs- The type name in a struct/enum/variant definition Then only constructor/initialization usages will be shown, filtering out other references.
Structs§
- Declaration
- Information about the declaration site of a searched item.
- Find
AllRefs Config - Reference
Search Result - Result of a reference search operation.
Functions§
- find_
all_ 🔒refs - Find all references to the item at the given position.
- find_
defs 🔒 - handle_
control_ 🔒flow_ keywords - is_
enum_ 🔒lit_ name_ ref - Checks if a name reference is part of an enum variant literal expression. Used to filter references when searching for enum variant constructors.
- is_
lit_ 🔒name_ ref - Checks if a name reference is used in a literal (constructor) context. Used to filter references when searching for struct/variant constructors.
- name_
for_ 🔒constructor_ search - Returns
Someif the cursor is at a position where we should search for constructor/initialization usages. This is used to implement the special constructor search behavior when the cursor is on specific tokens in a struct/enum/variant definition. - path_
ends_ 🔒with - Checks if a path ends with the given name reference. Helper function for checking constructor usage patterns.
- retain_
adt_ 🔒literal_ usages - Filter out all non-literal usages for adt-defs