Documentation
¶
Overview ¶
Package ast provides AST parsing and inspection utilities for Go source code.
Package ast provides AST parsing and inspection utilities for Go source code.
Package ast provides AST parsing and inspection utilities for Go source code.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FlattenStringExprAST ¶
FlattenStringExprAST recursively extracts string content from an expression tree consisting of string literals and binary '+' operations. This is the AST version that takes an already-parsed expression.
func HasNestedCall ¶
HasNestedCall returns true if any argument of the call expression is itself a call expression or contains a call expression in parentheses.
func IsCallExpr ¶
IsCallExpr returns true if s parses as a function call expression. Also matches parenthesized call expressions like (fn()).
func IsCompositeLit ¶
IsCompositeLit returns true if s parses as a composite literal. Also matches parenthesized composite literals like (T{}).
Types ¶
type OffsetSpan ¶
OffsetSpan is a half-open interval [Start, End) in byte offsets.
type OffsetSpanSet ¶
type OffsetSpanSet struct {
// contains filtered or unexported fields
}
OffsetSpanSet is a sorted, non-overlapping set of spans.
func NewOffsetSpanSet ¶
func NewOffsetSpanSet(spans []OffsetSpan) OffsetSpanSet
func OwnedSpansFromAST ¶
func OwnedSpansFromAST(file *ast.File, fset *token.FileSet, src []byte, opts OwnedSpanOptions) OffsetSpanSet
func OwnedSpansFromSource ¶
func OwnedSpansFromSource(src []byte, opts OwnedSpanOptions) OffsetSpanSet
func (OffsetSpanSet) Contains ¶
func (s OffsetSpanSet) Contains(off int) bool
Contains returns true if off falls inside any span in the set.
func (OffsetSpanSet) Overlaps ¶
func (s OffsetSpanSet) Overlaps(start, end int) bool
Overlaps reports whether any span in the set intersects the half-open interval [start, end). Intervals where end <= start are treated as empty and never overlap.
func (OffsetSpanSet) Union ¶
func (s OffsetSpanSet) Union(other OffsetSpanSet) OffsetSpanSet
Union returns a new set that contains all spans from s and other.