Skip to main content

Module computed_attribute

Module computed_attribute 

Expand description

Parsing for the @computed(params: <Type>?) field attribute’s parenthesized argument. Bare @computed needs no parsing; this module only handles the parameterized form. Mirrors super::composite_key’s shape: syntax parsing lives here in cratestack-core so cratestack-parser’s semantic checker and any other consumer (codegen, later) share one implementation.

Enums§

ComputedParamsArg
The parenthesized argument of a @computed(...) attribute, however it parses.

Functions§

computed_params_type_name
The params type name off a field’s @computed(params: <Type>?) attribute, or None for a bare @computed field (or a field with no @computed attribute at all). Assumes the attribute is already well-formed — per-declaration validation (e.g. cratestack-parser’s validate_computed_field_attribute) must run first and reject anything else. Callers that still need to validate the argument form should parse the raw attribute text with parse_computed_params_arg instead.
is_computed_attribute
True when a single attribute’s raw text is either spelling of @computed — bare @computed or the parameterized @computed(...) form (whatever its argument, valid or not; argument-shape validation is a separate concern — see cratestack-parser’s validate_computed_field_attribute). Anchored with starts_with("@computed(") rather than the looser starts_with("@computed") deliberately: the latter would also match a hypothetical unrelated attribute merely prefixed with the same characters (e.g. @computedSomethingElse).
is_computed_field
True for a field carrying either spelling of @computed — bare or @computed(params: <Type>?). See is_computed_attribute for why this must be the only place the string comparison is written.
parse_computed_params_arg
Parses the text between (but not including) the parens of a @computed(...) attribute into its recognized shape. Whitespace-tolerant around the : and before the trailing ?.