module std.comptime
std.comptime — the read-only AST seen by lint plugins (ч. III.4, §15.4; D-6560..).
A plugin is an OxL file listed in [lint] plugins = ["lints/my_rule.oxl"] of oxl.toml. Every comptime fn of the file
with one parameter of type Decl is called by the compiler for every declaration of the package (types, functions,
methods, rpcs, actor messages, fields, variants, consts, ...). The values are plain data built by the compiler; the
plugin reads them and reports problems with warn(at, message) or by failing with CompileError. The rule's level is
[lint] my_rule = "warn" | "error" | "off" (the name is the file name without .oxl; default warn).
Kinds are lower-case strings, listed in docs/analyzer.md.
Example:
use std.comptime { Decl, warn }
// lints/short_names.oxl, listed in `[lint] plugins = ["lints/short_names.oxl"]`
comptime fn short_names(d: Decl) {
if d.isPub && d.name.len() < 3 {
warn(d.span, "public name `{d.name}` is too short")
}
}Types
data Attr | An attribute @name(args). |
data AttrArg | An argument of an attribute |
data CompileError | The error of a plugin |
data Decl | A declaration or a member of one. |
data Expr | An expression of a body, in pre-order. |
data Span | A source range: file path, 1-based line and column of the start, byte offset and length. |
Functions
warn | Reports a diagnostic of the plugin's rule at at (its level comes from [lint], default warning). |