pub trait QueryAttrs {
// Provided methods
fn query_attr(&self, db: &dyn SyntaxGroup, attr: &str) -> Vec<Attribute> { ... }
fn find_attr(&self, db: &dyn SyntaxGroup, attr: &str) -> Option<Attribute> { ... }
fn has_attr(&self, db: &dyn SyntaxGroup, attr: &str) -> bool { ... }
fn has_attr_with_arg(
&self,
db: &dyn SyntaxGroup,
attr_name: &str,
arg_name: &str,
) -> bool { ... }
}
Expand description
Trait for querying attributes of AST items.
Provided Methods§
Sourcefn query_attr(&self, db: &dyn SyntaxGroup, attr: &str) -> Vec<Attribute>
fn query_attr(&self, db: &dyn SyntaxGroup, attr: &str) -> Vec<Attribute>
Collect all attributes named exactly attr
attached to this node.
Sourcefn find_attr(&self, db: &dyn SyntaxGroup, attr: &str) -> Option<Attribute>
fn find_attr(&self, db: &dyn SyntaxGroup, attr: &str) -> Option<Attribute>
Find first attribute named exactly attr
attached do this node.
Sourcefn has_attr(&self, db: &dyn SyntaxGroup, attr: &str) -> bool
fn has_attr(&self, db: &dyn SyntaxGroup, attr: &str) -> bool
Check if this node has an attribute named exactly attr
.
Sourcefn has_attr_with_arg(
&self,
db: &dyn SyntaxGroup,
attr_name: &str,
arg_name: &str,
) -> bool
fn has_attr_with_arg( &self, db: &dyn SyntaxGroup, attr_name: &str, arg_name: &str, ) -> bool
Checks if the given object has an attribute with the given name and argument.
Implementors§
impl QueryAttrs for ImplItem
impl QueryAttrs for ModuleItem
impl QueryAttrs for Statement
impl QueryAttrs for TraitItem
impl QueryAttrs for AttributeList
impl QueryAttrs for FunctionWithBody
impl QueryAttrs for ItemConstant
impl QueryAttrs for ItemEnum
impl QueryAttrs for ItemExternFunction
impl QueryAttrs for ItemExternType
impl QueryAttrs for ItemImpl
impl QueryAttrs for ItemImplAlias
impl QueryAttrs for ItemInlineMacro
impl QueryAttrs for ItemModule
impl QueryAttrs for ItemStruct
impl QueryAttrs for ItemTrait
impl QueryAttrs for ItemTypeAlias
impl QueryAttrs for ItemUse
impl QueryAttrs for Member
impl QueryAttrs for StatementBreak
impl QueryAttrs for StatementContinue
impl QueryAttrs for StatementExpr
impl QueryAttrs for StatementLet
impl QueryAttrs for StatementReturn
impl QueryAttrs for TraitItemConstant
impl QueryAttrs for TraitItemFunction
impl QueryAttrs for TraitItemImpl
impl QueryAttrs for TraitItemType
impl QueryAttrs for Variant
impl QueryAttrs for SyntaxNode
Allows querying attributes of a syntax node, any typed node which QueryAttrs is implemented for should be added here.