Documentation
¶
Overview ¶
Package language provides language intelligence over an analysis Snapshot: the symbol index (by name, qualified name, and document), scope lookup, context-aware completion, definition resolution, hover content, and the single structured registry of Rune built-ins, settings, and attributes (spec FR-026, FR-027). It is read-only and never executes anything (FR-028).
Index ¶
- func Definition(ix *Index, f *ast.File, file string, offset int) ([]token.Span, bool)
- func Hover(f *ast.File, file string, offset int) (markdown string, span token.Span, ok bool)
- func IsValid(kind BuiltinKind, name string) bool
- func SortOutlineByPosition(o DocumentOutline)
- func TaskSignature(t *ast.Task) string
- type Builtin
- type BuiltinKind
- type CompletionItem
- type CompletionKind
- type DocumentOutline
- type Index
- type OutlineEntry
- type OutlineGroup
- type ScopeID
- type Symbol
- type SymbolKind
- type Target
- type TargetKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Definition ¶
Definition resolves the declaration location(s) for the symbol at offset. It returns the declaration span(s) and true when a navigable definition exists. Attributes and built-ins have no source location (their docs surface via hover), so they return false.
func Hover ¶
Hover returns markdown documentation for the symbol at offset, along with the hovered span, or ok=false when there is nothing to show.
func IsValid ¶
func IsValid(kind BuiltinKind, name string) bool
IsValid reports whether name is a recognized entry of the given kind. This is what analyzer validation consults so completion and validation agree (R9).
func SortOutlineByPosition ¶
func SortOutlineByPosition(o DocumentOutline)
SortOutlineByPosition orders entries within each group by source position (declaration order), which editors expect for an outline.
func TaskSignature ¶
TaskSignature renders a task's signature line, e.g. `build target="debug"`.
Types ¶
type Builtin ¶
type Builtin struct {
Name string
Kind BuiltinKind
Signature string
Documentation string
// IntroducedIn is the semver in which the symbol first appeared, when known;
// empty means "present since before versions were tracked". It feeds the
// incompatible-version story and future minimum-version checks.
IntroducedIn string
}
Builtin is one entry of Rune language metadata. This registry is the SINGLE source consumed by hover, completion, and (incrementally) analyzer validation and CLI reference generation (spec FR-027): duplicate hard-coded lists of this metadata must not exist.
func Lookup ¶
func Lookup(kind BuiltinKind, name string) (Builtin, bool)
Lookup returns the registry entry of the given kind and name, if present.
func MatchKind ¶
func MatchKind(kind BuiltinKind, prefix string) []Builtin
MatchKind returns the entries of a kind whose name starts with prefix, ordered as declared (used by completion).
func OfKind ¶
func OfKind(kind BuiltinKind) []Builtin
OfKind returns the registry entries of a single kind.
type BuiltinKind ¶
type BuiltinKind int
BuiltinKind classifies an entry in the language registry.
const ( BuiltinFunction BuiltinKind = iota // an expression built-in, e.g. env(...) BuiltinSetting // a `set NAME` setting BuiltinAttribute // a `[name]` task attribute BuiltinExecutor // a task executor, e.g. (python) )
type CompletionItem ¶
type CompletionItem struct {
Label string
Detail string // signature
Documentation string
Kind CompletionKind
}
CompletionItem is one suggestion.
func Complete ¶
Complete returns context-aware completions at byte offset. Context is detected from the text around the cursor (which is mid-edit and may not parse), while candidates come from the symbol index and the language registry. Results are filtered by the identifier prefix being typed (spec FR-018).
type CompletionKind ¶
type CompletionKind int
CompletionKind classifies a completion item (mapped to an LSP kind by the server).
const ( CompletionTask CompletionKind = iota CompletionVariable CompletionParameter CompletionSetting CompletionAttribute CompletionExecutor CompletionFunction )
type DocumentOutline ¶
type DocumentOutline struct {
Groups []OutlineGroup
}
DocumentOutline is a document's symbols grouped into the categories an editor outline shows: settings, variables, imports, modules, and tasks (spec User Story 6). Each entry carries the span to navigate to.
type Index ¶
type Index struct {
ByName map[string][]Symbol
ByQualified map[string]Symbol
ByDocument map[string][]Symbol
}
Index is the symbol index over a composed *ast.File. The MVP provides lookup by base name, by qualified name, and by document (spec FR-026); a references index and full scope tree are deferred (rename/find-refs are out of scope).
ByDocument is keyed by the origin file path (token.Span.File), which every AST node retains through import composition — this is what makes cross-file attribution and navigation fall out for free (research R6).
func BuildIndex ¶
BuildIndex constructs the symbol index from a composed file. It must be called after config.Compose, so imported/module tasks are present with their origin spans intact.
type OutlineEntry ¶
type OutlineEntry struct {
Name string
Detail string // e.g. a task signature
Selection token.Span // the declaration span to navigate to
}
OutlineEntry is a single symbol in the outline.
type OutlineGroup ¶
type OutlineGroup struct {
Name string
Kind SymbolKind
Entries []OutlineEntry
}
OutlineGroup is one named category of outline entries.
type ScopeID ¶
type ScopeID string
ScopeID identifies the scope a symbol belongs to: the empty string is module (file) scope; a task's name is its parameter scope.
const ModuleScope ScopeID = ""
type Symbol ¶
type Symbol struct {
Name string
QualifiedName string // namespaced name (e.g. docker::build); == Name when unqualified
Kind SymbolKind
Definition token.Span // declaration span (carries the origin file via Span.File)
Selection token.Span // precise span to navigate to (name)
Scope ScopeID
Documentation string
Signature string
Exported bool // false for [private] tasks
}
Symbol is a named language entity with its declaration location.
type SymbolKind ¶
type SymbolKind int
SymbolKind classifies an indexed language entity.
const ( SymbolTask SymbolKind = iota SymbolVariable SymbolParameter SymbolSetting SymbolAttribute SymbolBuiltin SymbolImport SymbolModule )
func (SymbolKind) String ¶
func (k SymbolKind) String() string
type Target ¶
type Target struct {
Kind TargetKind
Name string
Scope ScopeID // enclosing task scope (for variable/parameter resolution)
Span token.Span // the hovered token's span
}
Target describes the symbol under a cursor offset.
func TargetAt ¶
TargetAt returns what is at byte offset within the given file (the document the cursor is in), checking the most specific constructs first (expression references beat the dependency or body line that contains them).
The file guard matters because the composed AST contains nodes from imported files, whose byte offsets share the same integer space as the cursor's file; only nodes originating in `file` are hit-tested.
type TargetKind ¶
type TargetKind int
TargetKind classifies what the cursor is on.
const ( TargetNone TargetKind = iota TargetDependency // a dependency/post-hook task reference TargetVarRef // a variable or parameter reference (expr or interpolation) TargetTaskName // a task declaration's name TargetParamDecl // a parameter declaration in a header TargetAttribute // a task attribute TargetBuiltin // a built-in function call )