describe

package
v0.0.199 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package describe adapts source positions to typed compiler queries. The lookup is isolated from the CLI and its output format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParsePosition

func ParsePosition(text string) (diag.Pos, error)

Types

type Result

type Result struct {
	Rebinds       *diag.Pos                 `json:"rebinds,omitempty"`
	Async         *check.AsyncDescription   `json:"async,omitempty"`
	Lazy          *check.LazyDescription    `json:"lazy,omitempty"`
	Assembly      *check.Assembly           `json:"assembly,omitempty"`
	Documentation string                    `json:"documentation,omitempty"`
	SchemaVersion int                       `json:"schema_version"`
	Position      diag.Pos                  `json:"position"`
	Type          string                    `json:"type"`
	Expression    string                    `json:"expression,omitempty"`
	Definition    *diag.Pos                 `json:"definition,omitempty"`
	Methods       []check.MethodDescription `json:"methods"`
	Facts         []check.KnownFact         `json:"facts"`
	// BelongsTo lists the scopes the value belongs to: it is usable
	// while all of them are open.
	BelongsTo []string `json:"belongs_to,omitempty"`
	// Ownership says whether a resource variable was acquired here and
	// can be moved, is borrowed, is kept by a task or a channel, or was
	// moved.
	Ownership string                     `json:"ownership,omitempty"`
	Proof     *check.Proof               `json:"proof,omitempty"`
	Callable  *check.CallableDescription `json:"callable,omitempty"`
	// TailCall says, at a call of a function by itself, whether it is
	// compiled as a jump.
	TailCall *check.TailCall `json:"tail_call,omitempty"`
}

type Selection

type Selection struct {
	Expr       check.Expr
	Func       *check.Func
	Package    *check.Package
	Type       check.Type
	Expression string
	Definition *diag.Pos
	Site       diag.Pos
	Value      bool
	Callable   *check.CallableDescription
	Assembly   *check.Assembly
	TailCall   *check.TailCall
}

Selection is a source value and the position at which to query its facts.

func Lookup

func Lookup(files []*syntax.File, info *check.Info, pos diag.Pos, src []byte) (*Selection, error)

Lookup maps a source token to the typed tree. Only the function containing the position is visited, so inserted defaults in other bodies cannot select a declaration in the current file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL