Marker trait for AST nodes that can be queried with selectors. Implemented by `#[derive(Visitable)]` for queryable nodes, and manually for nodes with `get_property` overrides (named at-rules, declarations). Not part of the `Visit` public API - visitors receive a [`VisitNode`] instead.
| 123 | /// with `get_property` overrides (named at-rules, declarations). |
| 124 | /// Not part of the `Visit` public API - visitors receive a [`VisitNode`] instead. |
| 125 | pub(crate) trait QueryableNode: ToSpan + NodeWithMetadata<CssMetadata> { |
| 126 | /// Unique identifier for this node type. |
| 127 | const NODE_ID: NodeId; |
| 128 | |
| 129 | /// Returns a cursor for the given property kind, if the node has that property. |
| 130 | /// Used by attribute selectors to extract values from nodes. |
| 131 | /// |
| 132 | /// For `PropertyKind::Name`, returns a cursor to the node's name (e.g., property |
| 133 | /// name for declarations, animation name for `@keyframes`). |
| 134 | fn get_property(&self, _kind: PropertyKind) -> Option<Cursor> { |
| 135 | None |
| 136 | } |
| 137 | |
| 138 | /// Builds the [`VisitNode`] passed to every `Visit` callback for this node. |
| 139 | /// |
| 140 | /// `subtree_metadata` (eager) uses `metadata()` (self + subtree) so the prune gate can |
| 141 | /// reject whole subtrees; `self_metadata`/properties are deferred to `&dyn` accessors so |
| 142 | /// they only cost anything when a visitor actually reads them. |
| 143 | fn visit_node(&self) -> VisitNode<'_> |
| 144 | where |
| 145 | Self: Sized, |
| 146 | { |
| 147 | VisitNode::new(self.to_span(), Self::NODE_ID, self.metadata(), self) |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | /// Blanket bridge so any [`QueryableNode`] can be held as a `&dyn` in [`VisitNode`]. |
| 152 | impl<T: QueryableNode> QueryNodeData for T { |
nothing calls this directly
no outgoing calls
no test coverage detected