v.astquery #
max_doc_gap is how far above a declaration a comment may sit and still be read as its documentation. A larger gap means the comment documents something else.
fn declarations #
fn declarations(a &flat.FlatAst) []Declaration
declarations returns every named declaration in the user code of a.
Order is the order the parser produced, which is source order for a single file. A declaration nested in a $if block is reported where it appears.
fn occurrence_at #
fn occurrence_at(a &flat.FlatAst, name string, line int, column int) ?Occurrence
occurrence_at returns the innermost mention of name that covers line:column, which is what a cursor position asks for.
fn parse #
fn parse(path string) &flat.FlatAst
parse reads one V file into a fresh AST with the preferences a formatter and an inspector agree on.
fn references #
fn references(a &flat.FlatAst, name string) []Occurrence
references returns every mention of name in the user code of a.
The name is matched against identifier positions in the AST, not against raw text, so a comment or a string literal that happens to contain it is not reported.
enum DeclKind #
enum DeclKind {
module
import
fn
method
struct
field
enum
enum_value
interface
interface_method
type_alias
sumtype
const
global
}
DeclKind classifies a declaration found by declarations.
fn (DeclKind) str #
fn (k DeclKind) str() string
str returns the lowercase name of the kind, as used in JSON output.
struct Declaration #
struct Declaration {
pub:
kind DeclKind
// name is the declared name. A method is `receiver` plus `name`.
name string
// receiver is the type a method belongs to, empty otherwise.
receiver string
// type_name is the field type, the function return type, or empty.
type_name string
file string
// line and column are 1-based, as an editor reports them.
line int
column int
// end_line and end_column bound the declaration.
end_line int
end_column int
// doc is the doc comment directly above the declaration, without its `//`
// markers, when there is one.
doc string
}
Declaration is one named declaration, with where it starts and what it is.
struct Occurrence #
struct Occurrence {
pub:
name string
// node_kind is the AST kind that carries the name, for example `ident` or
// `selector`.
node_kind string
file string
line int
// column and end_column bound the name itself, one past the end.
column int
end_column int
// declaration is true when the mention is the declaration itself.
declaration bool
// type_name is what the parser resolved the mention to, when known.
type_name string
}
Occurrence is one mention of a name.