Gen Context¶
Import: import system.codegen;
GenContext¶
Input and output of a source generator. Inspect selected declarations, request tools, report diagnostics, and add or replace generated source through this context.
generator_name¶
The running generator's name and module::name identity.
generator_id¶
Stable identifier of the generator being executed.
target¶
Target triple of the compile (aarch64-apple-darwin, wasm32-unknown-wasi, ...).
load¶
Reads --snapshot / --result from the program arguments.
types_with¶
Declarations carrying @A (on the declaration or on one of its members).
functions_with¶
Top-level functions carrying @A (on the function or a parameter).
modules_with¶
User modules whose module declaration carries @A, in source order.
module_of¶
The trigger-carrying module that declares decl, so module-level settings can be merged with the declaration's own attributes. None when its module carries no trigger.
module_of¶
The trigger-carrying module that declares function or method f, or None when its module carries no trigger attribute.
decls¶
Every declaration selected by this generator's @on_attribute triggers.
phase¶
Current generation round, starting at zero and increasing after tool requests.
referenced_decls¶
Transitive dependencies of the declarations selected by this generator.
referenced_functions¶
Top-level functions referenced by selected declarations or their dependencies.
find_decl¶
Looks up a selected or referenced declaration by its stable identifier.
find_function¶
Looks up a selected or referenced function, including methods.
type_of¶
The inferred type, or an explicit Unknown when pre-analysis could not resolve it.
type_of¶
The inferred type attached to a statement, or Unknown when it has no value type.
symbol_of¶
The resolved symbol identity, or an empty string for an unresolved expression.
find_symbol¶
Looks up a signature view anywhere in the pre-generation compilation.
compilation_errors¶
Errors found before generation within declarations selected by this generator's triggers.
implementations_of¶
Classes and structs implementing an interface, including inherited interface relations.
subtypes_of¶
Signature views whose declared interface ancestry includes the given identity.
type_index¶
Every type in the program, by name and kind.