Expand description
Visitors for AST positions that carry a currency or an account name.
These exist because hand-rolled “for each currency / for each
account” walks across the AST kept missing positions. The earlier
pattern was: every consumer (LSP completion, hover usage count,
WASM editor extraction, etc.) wrote its own walk over Directive
variants, and silently dropped any position the author happened
not to remember (Note.account, Posting.cost.currency,
MetaValue::Account metadata values, Custom.values, …).
Fixing it in five different files left the underlying problem
intact: the next contributor writing a “for each X” walk will
reach for the same shape and reintroduce the same bug class.
These visitors are the canonical answer. Every position that
carries a currency or an account name is enumerated exactly once
here, with no _ => {} catch-all — at any layer of the match.
That means:
- A future
Directivevariant added to the enum forces a compile error at the top-levelvisit_*match. - A future
MetaValuevariant forces a compile error atvisit_meta_value_currencyandvisit_meta_value_account. - A future
PriceAnnotationvariant forces a compile error atvisit_price_currency.
This file is the ONE place that needs to be updated when new
variants are added to any of those enums. Downstream consumers
calling visit_* benefit automatically.
Spans of source tokens are intentionally NOT exposed here:
source positions are parser-only metadata published via
ParseResult::currency_occurrences (the parser is the canonical
owner of source-position data). Value-level consumers (extract,
hover usage count, completion suggestions) want the strings;
source-position consumers (LSP rename / references /
document-highlight / linked-editing / goto-definition) consume
the parser’s index. Separating the concerns keeps the AST
value types pure.
Functions§
- visit_
accounts - Walk every position an account name can appear in this directive,
invoking
visitonce per occurrence. - visit_
currencies - Walk every position a currency name can appear in this directive,
invoking
visitonce per occurrence. - visit_
links - Walk every position a link can appear in this directive, invoking
visitonce per occurrence (link text without the^sigil). - visit_
tags - Walk every position a tag can appear in this directive, invoking
visitonce per occurrence (tag text without the#sigil).