Documentation
¶
Index ¶
- Variables
- func ConvertToTreeSitterQuery(node ast.Node, p *QueryContext) (string, error)
- func Debug(format string, args ...interface{})
- func ExtractTreeSitterQuery(filePath string) (string, error)
- func GetSnippetForMatch(filePath string, match Match) (string, error)
- func GetTSLanguageFromEnry(filename string, contents []byte) (*sitter.Language, error)
- func IsDebugging() bool
- type ArrayType
- type AssignStmt
- type BadDecl
- type BadStmt
- type BasicLit
- type BinaryExpr
- type BlockStmt
- type BranchStmt
- type CallExpr
- type ChanType
- type CompositeLit
- type Decl
- type DeclStmt
- type DefaultDecl
- type DefaultExpr
- type DefaultNode
- type DefaultStmt
- type DeferStmt
- type EmptyStmt
- type Expr
- type ExprStmt
- type Field
- type FieldList
- type FuncDecl
- type FuncLit
- type FuncType
- type GenDecl
- type GoStmt
- type Ident
- type IfStmt
- type IncDecStmt
- type LabeledStmt
- type MapType
- type Match
- type MatchGroup
- type Node
- type Package
- type QueryContext
- type RangeInterval
- type RangeStmt
- type ReturnStmt
- type SelectStmt
- type SelectorExpr
- type SendStmt
- type Stmt
- type StructType
- type SwitchStmt
- type TypeSpec
- type TypeSwitchStmt
- type ValueSpec
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnsupportedLang = errors.New("unsupported language")
)
Functions ¶
func ConvertToTreeSitterQuery ¶
func ConvertToTreeSitterQuery(node ast.Node, p *QueryContext) (string, error)
ConvertToTreeSitterQuery converts a Go AST node to a tree-sitter query string
func ExtractTreeSitterQuery ¶
ExtractTreeSitterQuery parses a Go file and extracts the code between //asq_start and //asq_end comments, then converts it to a tree-sitter query.
func GetSnippetForMatch ¶
GetSnippetForMatch returns the code snippet for a given match, including context. If the match is within a function, returns the entire function. Otherwise, returns 5 lines before and after the match.
func GetTSLanguageFromEnry ¶
GetTSLanguageFromEnry detects the language of a file using go-enry and returns the corresponding tree-sitter language parser. Currently only supports Go.
func IsDebugging ¶
func IsDebugging() bool
Types ¶
type AssignStmt ¶
type AssignStmt struct { Ast *ast.AssignStmt Lhs []Expr Rhs []Expr }
AssignStmt wraps an ast.AssignStmt node
func (*AssignStmt) AstNode ¶
func (a *AssignStmt) AstNode() ast.Node
func (*AssignStmt) WriteTreeSitterQuery ¶
func (a *AssignStmt) WriteTreeSitterQuery(w io.Writer) error
type BinaryExpr ¶
DefaultExpr wraps any ast.Expr type that doesn't have a specific implementation
func (*BinaryExpr) AstNode ¶
func (b *BinaryExpr) AstNode() ast.Node
func (*BinaryExpr) WriteTreeSitterQuery ¶
func (b *BinaryExpr) WriteTreeSitterQuery(w io.Writer) error
type BranchStmt ¶
type BranchStmt struct { Ast *ast.BranchStmt Label *Ident }
BranchStmt wraps an ast.BranchStmt node
func (*BranchStmt) AstNode ¶
func (b *BranchStmt) AstNode() ast.Node
func (*BranchStmt) WriteTreeSitterQuery ¶
func (b *BranchStmt) WriteTreeSitterQuery(w io.Writer) error
type CompositeLit ¶
type CompositeLit struct { Ast *ast.CompositeLit Type Node Elts []Expr }
CompositeLit wraps an ast.CompositeLit node
func (*CompositeLit) AstNode ¶
func (c *CompositeLit) AstNode() ast.Node
func (*CompositeLit) WriteTreeSitterQuery ¶
func (c *CompositeLit) WriteTreeSitterQuery(w io.Writer) error
type Decl ¶
type Decl interface { Node // contains filtered or unexported methods }
Decl nodes contain declarations and implement the Decl interface.
func BuildAsqDecl ¶
func BuildAsqDecl(decl ast.Decl, p *QueryContext) Decl
BuildAsqDecl converts an ast.Decl to its corresponding asq.Decl
type DefaultDecl ¶
DefaultDecl wraps any ast.Decl type that doesn't have a specific implementation
func (*DefaultDecl) AstNode ¶
func (d *DefaultDecl) AstNode() ast.Node
func (*DefaultDecl) WriteTreeSitterQuery ¶
func (d *DefaultDecl) WriteTreeSitterQuery(w io.Writer) error
type DefaultExpr ¶
func (*DefaultExpr) AstNode ¶
func (d *DefaultExpr) AstNode() ast.Node
func (*DefaultExpr) WriteTreeSitterQuery ¶
func (d *DefaultExpr) WriteTreeSitterQuery(w io.Writer) error
type DefaultNode ¶
DefaultNode wraps any ast.Node type that doesn't have a specific implementation
func (*DefaultNode) AstNode ¶
func (d *DefaultNode) AstNode() ast.Node
func (*DefaultNode) WriteTreeSitterQuery ¶
func (d *DefaultNode) WriteTreeSitterQuery(w io.Writer) error
type DefaultStmt ¶
DefaultStmt wraps any ast.Stmt type that doesn't have a specific implementation
func (*DefaultStmt) AstNode ¶
func (d *DefaultStmt) AstNode() ast.Node
func (*DefaultStmt) WriteTreeSitterQuery ¶
func (d *DefaultStmt) WriteTreeSitterQuery(w io.Writer) error
type Expr ¶
type Expr interface { Node // contains filtered or unexported methods }
Expr nodes contain expressions and implement the Expr interface.
func BuildAsqExpr ¶
func BuildAsqExpr(node ast.Node, p *QueryContext) Expr
BuildAsqExpr converts an ast.Node to its corresponding asq.Node
type IncDecStmt ¶
type IncDecStmt struct { Ast *ast.IncDecStmt X Expr }
IncDecStmt wraps an ast.IncDecStmt node
func (*IncDecStmt) AstNode ¶
func (i *IncDecStmt) AstNode() ast.Node
func (*IncDecStmt) WriteTreeSitterQuery ¶
func (i *IncDecStmt) WriteTreeSitterQuery(w io.Writer) error
type LabeledStmt ¶
type LabeledStmt struct { Ast *ast.LabeledStmt Label *Ident Stmt Stmt }
LabeledStmt wraps an ast.LabeledStmt node
func (*LabeledStmt) AstNode ¶
func (l *LabeledStmt) AstNode() ast.Node
func (*LabeledStmt) WriteTreeSitterQuery ¶
func (l *LabeledStmt) WriteTreeSitterQuery(w io.Writer) error
type Match ¶
Match represents a single tree-sitter query match
func ValidateTreeSitterQuery ¶
ValidateTreeSitterQuery executes a tree-sitter query directly on the given file returns all matches with their line numbers, column numbers, and matched code
type MatchGroup ¶
type MatchGroup struct { FilePath string StartLine int EndLine int Snippet string IsFunction bool FunctionPos token.Pos // Used for sorting function groups }
MatchGroup represents a group of matches that should be displayed together
func GroupMatchesForCursorDedup ¶
func GroupMatchesForCursorDedup(filePath string, matches []Match) ([]MatchGroup, error)
GroupMatchesForCursorDedup takes a list of matches for a file and groups them by their containing functions or root-level context. Returns groups sorted by position.
type Node ¶
Node is the interface that all asq nodes implement.
func BuildAsqNode ¶
func BuildAsqNode(node ast.Node, p *QueryContext) Node
BuildAsqNode converts an ast.Node to its corresponding asq.Node
type QueryContext ¶
type QueryContext struct {
// contains filtered or unexported fields
}
QueryContext is an internal struct used during the first pass of AST processing to track which identifiers should be treated as wildcards based on active intervals.
func NewQueryContext ¶
NewQueryContext creates a new QueryContext instance
func (*QueryContext) AddInterval ¶
func (p *QueryContext) AddInterval(c *ast.Comment)
AddInterval adds a new wildcard interval
func (*QueryContext) IsWildcard ¶
func (p *QueryContext) IsWildcard(node ast.Node) bool
IsWildcard checks if the given node should be treated as a wildcard. A node is considered a wildcard if either: 1. It is an ast.Ident node with a name prefixed by "_asq_" 2. It is the first syntactic entity in an active interval
func (*QueryContext) SetLastIntervalEnd ¶
func (p *QueryContext) SetLastIntervalEnd(start token.Pos)
SetLastIntervalEnd sets the end of the last wildcard interval
type RangeInterval ¶
type RangeInterval struct { Start token.Pos // Start offset in the line TokenEnd token.Pos // End offset in the line End token.Pos // contains filtered or unexported fields }
RangeInterval represents an active interval for a wildcard tag
type ReturnStmt ¶
type ReturnStmt struct { Ast *ast.ReturnStmt Results []Expr }
ReturnStmt wraps an ast.ReturnStmt node
func (*ReturnStmt) AstNode ¶
func (r *ReturnStmt) AstNode() ast.Node
func (*ReturnStmt) WriteTreeSitterQuery ¶
func (r *ReturnStmt) WriteTreeSitterQuery(w io.Writer) error
type SelectStmt ¶
type SelectStmt struct { Ast *ast.SelectStmt Body *BlockStmt }
SelectStmt wraps an ast.SelectStmt node
func (*SelectStmt) AstNode ¶
func (s *SelectStmt) AstNode() ast.Node
func (*SelectStmt) WriteTreeSitterQuery ¶
func (s *SelectStmt) WriteTreeSitterQuery(w io.Writer) error
type SelectorExpr ¶
type SelectorExpr struct { Ast *ast.SelectorExpr X Expr Wildcard bool }
SelectorExpr wraps an ast.SelectorExpr node
func (*SelectorExpr) AstNode ¶
func (s *SelectorExpr) AstNode() ast.Node
func (*SelectorExpr) WriteTreeSitterQuery ¶
func (s *SelectorExpr) WriteTreeSitterQuery(w io.Writer) error
type Stmt ¶
type Stmt interface { Node // contains filtered or unexported methods }
Stmt nodes contain statements and implement the Stmt interface.
func BuildAsqStmt ¶
func BuildAsqStmt(stmt ast.Stmt, p *QueryContext) Stmt
BuildAsqStmt converts an ast.Stmt to its corresponding asq.Stmt
type StructType ¶
type StructType struct { Ast *ast.StructType Fields *FieldList }
StructType wraps an ast.StructType node
func (*StructType) AstNode ¶
func (s *StructType) AstNode() ast.Node
func (*StructType) WriteTreeSitterQuery ¶
func (s *StructType) WriteTreeSitterQuery(w io.Writer) error
type SwitchStmt ¶
type SwitchStmt struct { Ast *ast.SwitchStmt Init Stmt Tag Expr Body *BlockStmt }
SwitchStmt wraps an ast.SwitchStmt node
func (*SwitchStmt) AstNode ¶
func (s *SwitchStmt) AstNode() ast.Node
func (*SwitchStmt) WriteTreeSitterQuery ¶
func (s *SwitchStmt) WriteTreeSitterQuery(w io.Writer) error
type TypeSwitchStmt ¶
type TypeSwitchStmt struct { Ast *ast.TypeSwitchStmt Init Stmt Assign Stmt Body *BlockStmt }
TypeSwitchStmt wraps an ast.TypeSwitchStmt node
func (*TypeSwitchStmt) AstNode ¶
func (t *TypeSwitchStmt) AstNode() ast.Node
func (*TypeSwitchStmt) WriteTreeSitterQuery ¶
func (t *TypeSwitchStmt) WriteTreeSitterQuery(w io.Writer) error