Documentation
¶
Overview ¶
Package symbol builds per-file Pawn symbol tables.
Index ¶
- func IsTestEntryPoint(item Symbol) bool
- type ID
- type Kind
- type Reference
- type Scope
- type ScopeKind
- type StableID
- type Symbol
- type Table
- func Build(root parser.SyntaxNode, file source.FileID) *Table
- func BuildContext(ctx context.Context, root parser.SyntaxNode, file source.FileID) (*Table, error)
- func BuildMapped(root parser.SyntaxNode, file source.FileID, files func(uint32) source.FileID) *Table
- func BuildMappedContext(ctx context.Context, root parser.SyntaxNode, file source.FileID, ...) (*Table, error)
- func BuildMappedDeclarationsContext(ctx context.Context, root parser.SyntaxNode, file source.FileID, ...) (*Table, error)
- func BuildMappedNavigationContext(ctx context.Context, root parser.SyntaxNode, file source.FileID, ...) (*Table, error)
- func BuildMappedNavigationWithSpansContext(ctx context.Context, root parser.SyntaxNode, file source.FileID, ...) (*Table, error)
- func BuildMappedWithSpansContext(ctx context.Context, root parser.SyntaxNode, file source.FileID, ...) (*Table, error)
- func PatchReference(previous *Table, span source.Span, name string) (*Table, bool)
- func RebaseParenthesized(previous *Table, previousSource, currentSource []byte, ...) (*Table, bool)
- func (t *Table) DeclarationAt(span source.Span) (Symbol, bool)
- func (t *Table) ExportFingerprint() [32]byte
- func (t *Table) Lookup(scope ID, name string) (Symbol, bool)
- func (t *Table) LookupCallable(scope ID, name string, argCount int) (Symbol, bool)
- func (t *Table) OperatorOverloads(name string) []Symbol
- func (t *Table) ReferencedAt(span source.Span) (Symbol, bool)
- func (t *Table) Scope(id ID) (Scope, bool)
- func (t *Table) StableSymbolID(id ID) (StableID, bool)
- func (t *Table) Symbol(id ID) (Symbol, bool)
- func (t *Table) UndefinedReferences() []Reference
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTestEntryPoint ¶ added in v0.30.2
IsTestEntryPoint reports a YSI test function declaration.
Types ¶
type ID ¶
type ID int
ID identifies a Symbol or Scope within one Table. The zero value never refers to a real entry.
type Kind ¶
type Kind uint8
Kind classifies a declared symbol.
func (Kind) IsCallable ¶
IsCallable reports whether k denotes something invoked with call syntax.
type Reference ¶
type Reference struct {
Name string
Span source.Span
Scope ID
Resolved ID // 0 if no declaration was found.
IsCall bool
ArgCount int // -1 for non-call references.
}
Reference is one identifier use, resolved against the scope active at that point in the tree.
type Scope ¶
Scope is one lexical scope. Names declared directly in a scope shadow same-named symbols in Parent.
type StableID ¶ added in v0.2.0
type StableID [32]byte
StableID identifies a top-level declaration across source revisions.
type Symbol ¶
type Symbol struct {
ID ID
Name string
Kind Kind
Tag string // declared tag, e.g. "Float"; "" if untagged.
IsArray bool
IsConst bool
IsStatic bool
Scope ID // the scope this symbol is declared IN.
FuncScope ID // for callable kinds with a body: the scope holding its parameters/locals; 0 otherwise.
MinArgs int // required parameters for callable symbols.
MaxArgs int // total parameters; -1 means variadic.
ParamTags []string // parameter tags in declaration order.
StateSelector string // state selector text; empty for ordinary declarations.
Span source.Span // the declaration name's span.
}
Symbol is one declaration.
type Table ¶
type Table struct {
File source.FileID
Symbols []Symbol
Scopes []Scope
References []Reference
Diagnostics []diagnostic.Diagnostic
// contains filtered or unexported fields
}
Table is the immutable result of Build.
func Build ¶
func Build(root parser.SyntaxNode, file source.FileID) *Table
Build creates a symbol table from an error-tolerant syntax tree.
func BuildContext ¶ added in v0.11.0
BuildContext creates a symbol table and stops when ctx is cancelled.
func BuildMapped ¶
func BuildMapped(root parser.SyntaxNode, file source.FileID, files func(uint32) source.FileID) *Table
BuildMapped maps token provenance file indexes to shared file IDs.
func BuildMappedContext ¶ added in v0.11.0
func BuildMappedContext( ctx context.Context, root parser.SyntaxNode, file source.FileID, files func(uint32) source.FileID, ) (*Table, error)
BuildMappedContext maps token origins and stops when ctx is cancelled.
func BuildMappedDeclarationsContext ¶ added in v0.14.0
func BuildMappedDeclarationsContext( ctx context.Context, root parser.SyntaxNode, file source.FileID, files func(uint32) source.FileID, ) (*Table, error)
BuildMappedDeclarationsContext builds mapped top-level declarations.
func BuildMappedNavigationContext ¶ added in v0.14.1
func BuildMappedNavigationContext( ctx context.Context, root parser.SyntaxNode, file source.FileID, files func(uint32) source.FileID, ) (*Table, error)
BuildMappedNavigationContext keeps details for the active file.
func BuildMappedNavigationWithSpansContext ¶ added in v0.18.0
func BuildMappedNavigationWithSpansContext( ctx context.Context, root parser.SyntaxNode, file source.FileID, mapSpan func(parser.SyntaxNode) (source.Span, bool), ) (*Table, error)
BuildMappedNavigationWithSpansContext keeps active-file details and uses mapSpan to map expanded nodes back to source files.
func BuildMappedWithSpansContext ¶ added in v0.29.0
func BuildMappedWithSpansContext( ctx context.Context, root parser.SyntaxNode, file source.FileID, mapSpan func(parser.SyntaxNode) (source.Span, bool), ) (*Table, error)
BuildMappedWithSpansContext builds full symbols using mapped source spans.
func PatchReference ¶ added in v0.25.0
PatchReference returns a table with one reference name updated.
func RebaseParenthesized ¶ added in v0.27.1
func RebaseParenthesized( previous *Table, previousSource, currentSource []byte, previousTokens, tokens []token.Token, before, after parser.ByteRange, ) (*Table, bool)
RebaseParenthesized returns a table remapped after wrapping or unwrapping text.
func (*Table) DeclarationAt ¶ added in v0.1.19
DeclarationAt returns the first symbol declared at span.
func (*Table) ExportFingerprint ¶ added in v0.3.0
ExportFingerprint identifies the table's top-level signatures.
func (*Table) Lookup ¶
Lookup resolves name starting at scope and walking outward through parent scopes, the same rule used while building references.
func (*Table) LookupCallable ¶ added in v0.30.2
LookupCallable resolves a call by name and argument count.
func (*Table) OperatorOverloads ¶
OperatorOverloads returns operator declarations with the given normalized name.
func (*Table) ReferencedAt ¶ added in v0.1.19
ReferencedAt returns the symbol resolved by the first reference at span.
func (*Table) StableSymbolID ¶ added in v0.2.0
StableSymbolID returns a top-level symbol ID that survives body-only edits.
func (*Table) UndefinedReferences ¶
UndefinedReferences returns names unresolved within this file.