ast

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTMLAttrName

func HTMLAttrName(name string) string

HTMLAttrName maps a JSX attribute name to its HTML attribute name, translating React-style aliases (className, htmlFor) to their DOM equivalents (class, for).

Types

type ArrayExpr

type ArrayExpr struct {
	Position Pos
	Elements []Expr
}

func (*ArrayExpr) Pos

func (a *ArrayExpr) Pos() Pos

type ArrowFn

type ArrowFn struct {
	Position   Pos
	Params     []*Param
	Body       []Stmt
	Expression bool
	Async      bool
}

func (*ArrowFn) Pos

func (a *ArrowFn) Pos() Pos

type AwaitExpr

type AwaitExpr struct {
	Position Pos
	Arg      Expr
}

func (*AwaitExpr) Pos

func (a *AwaitExpr) Pos() Pos

type BinaryExpr

type BinaryExpr struct {
	Position Pos
	Left     Expr
	Op       string
	Right    Expr
}

func (*BinaryExpr) Pos

func (b *BinaryExpr) Pos() Pos

type BlockStmt

type BlockStmt struct {
	Position Pos
	Body     []Stmt
}

func (*BlockStmt) Pos

func (b *BlockStmt) Pos() Pos

type BreakStmt

type BreakStmt struct {
	Position Pos
	Label    string
}

func (*BreakStmt) Pos

func (b *BreakStmt) Pos() Pos

type CallExpr

type CallExpr struct {
	Position Pos
	Callee   Expr
	Args     []Expr
}

func (*CallExpr) Pos

func (c *CallExpr) Pos() Pos

type CaseClause

type CaseClause struct {
	Position Pos
	Test     Expr
	Body     []Stmt
}

type CatchClause

type CatchClause struct {
	Position Pos
	Param    string
	Body     []Stmt
}

type ConditionalExpr

type ConditionalExpr struct {
	Position   Pos
	Test       Expr
	Consequent Expr
	Alternate  Expr
}

func (*ConditionalExpr) Pos

func (c *ConditionalExpr) Pos() Pos

type ContinueStmt

type ContinueStmt struct {
	Position Pos
	Label    string
}

func (*ContinueStmt) Pos

func (c *ContinueStmt) Pos() Pos

type DoWhileStmt

type DoWhileStmt struct {
	Position Pos
	Body     []Stmt
	Test     Expr
}

func (*DoWhileStmt) Pos

func (d *DoWhileStmt) Pos() Pos

type DynamicImport

type DynamicImport struct {
	Position Pos
	Arg      Expr
}

func (*DynamicImport) Pos

func (d *DynamicImport) Pos() Pos

type ExportStmt

type ExportStmt struct {
	Position       Pos
	Declaration    Stmt
	Default        bool
	Local          string
	StarReexport   bool   // export * from 'source'
	ReexportSource string // source path for re-exports (export * from '...' or export { X } from '...')
}

func (*ExportStmt) Pos

func (e *ExportStmt) Pos() Pos

type Expr

type Expr interface {
	Node
	// contains filtered or unexported methods
}

type ExprStmt

type ExprStmt struct {
	Position   Pos
	Expression Expr
}

func (*ExprStmt) Pos

func (e *ExprStmt) Pos() Pos

type FnDecl

type FnDecl struct {
	Position Pos
	Name     string
	Params   []*Param
	Body     []Stmt
	Async    bool
	Export   bool
	Default  bool
}

func (*FnDecl) Pos

func (f *FnDecl) Pos() Pos

type ForInStmt

type ForInStmt struct {
	Position Pos
	Left     Expr
	Right    Expr
	Body     []Stmt
	IsForOf  bool
}

func (*ForInStmt) Pos

func (f *ForInStmt) Pos() Pos

type ForStmt

type ForStmt struct {
	Position Pos
	Init     Stmt
	Test     Expr
	Update   Expr
	Body     []Stmt
}

func (*ForStmt) Pos

func (f *ForStmt) Pos() Pos

type Identifier

type Identifier struct {
	Position Pos
	Name     string
}

func (*Identifier) Pos

func (i *Identifier) Pos() Pos

type IfStmt

type IfStmt struct {
	Position   Pos
	Test       Expr
	Consequent []Stmt
	Alternate  []Stmt
}

func (*IfStmt) Pos

func (i *IfStmt) Pos() Pos

type ImportMetaExpr

type ImportMetaExpr struct {
	Position Pos
}

func (*ImportMetaExpr) Pos

func (im *ImportMetaExpr) Pos() Pos

type ImportStmt

type ImportStmt struct {
	Position  Pos
	Default   string
	Named     []NamedImport
	Namespace string
	Source    string
}

func (*ImportStmt) Pos

func (i *ImportStmt) Pos() Pos

type JSXAttr

type JSXAttr struct {
	Position Pos
	Name     string
	Value    Expr
	Spread   bool
}

func (*JSXAttr) Pos

func (j *JSXAttr) Pos() Pos

type JSXChild

type JSXChild interface {
	// contains filtered or unexported methods
}

type JSXClosing

type JSXClosing struct {
	Name string
}

type JSXElement

type JSXElement struct {
	Position Pos
	Opening  *JSXOpening
	Children []JSXChild
	Closing  *JSXClosing
}

func (*JSXElement) Pos

func (j *JSXElement) Pos() Pos

type JSXElementChild

type JSXElementChild struct {
	Element *JSXElement
}

type JSXExprContainer

type JSXExprContainer struct {
	Expression Expr
}

type JSXFragment

type JSXFragment struct {
	Position Pos
	Children []JSXChild
}

func (*JSXFragment) Pos

func (j *JSXFragment) Pos() Pos

type JSXFragmentChild

type JSXFragmentChild struct {
	Fragment *JSXFragment
}

type JSXOpening

type JSXOpening struct {
	Name        string
	Attributes  []*JSXAttr
	SelfClosing bool
}

type JSXText

type JSXText struct {
	Value string
}

type LitKind

type LitKind int
const (
	StringLit LitKind = iota
	NumberLit
	BoolLit
	NullLit
	RegexpLit
)

type Literal

type Literal struct {
	Position Pos
	Kind     LitKind
	Value    string
}

func (*Literal) Pos

func (l *Literal) Pos() Pos

type MemberExpr

type MemberExpr struct {
	Position Pos
	Object   Expr
	Property Expr
	Computed bool
	Optional bool
}

func (*MemberExpr) Pos

func (m *MemberExpr) Pos() Pos

type NamedImport

type NamedImport struct {
	Local  string
	Remote string
}

type NewExpr

type NewExpr struct {
	Position Pos
	Callee   Expr
	Args     []Expr
}

func (*NewExpr) Pos

func (n *NewExpr) Pos() Pos

type Node

type Node interface {
	Pos() Pos
	// contains filtered or unexported methods
}

type ObjectExpr

type ObjectExpr struct {
	Position   Pos
	Properties []*ObjectProp
}

func (*ObjectExpr) Pos

func (o *ObjectExpr) Pos() Pos

type ObjectProp

type ObjectProp struct {
	Key       string
	Value     Expr
	Shorthand bool
	Spread    bool
	Method    bool
}

type Param

type Param struct {
	Position Pos
	Name     string
	Default  Expr // Store the expression here
	IsRest   bool // Added this
}

func (*Param) Pos

func (p *Param) Pos() Pos

type Pos

type Pos struct {
	Line int
	Col  int
}

type Program

type Program struct {
	Position Pos
	Body     []Stmt
}

func (*Program) Pos

func (p *Program) Pos() Pos

type ReturnStmt

type ReturnStmt struct {
	Position Pos
	Value    Expr
}

func (*ReturnStmt) Pos

func (r *ReturnStmt) Pos() Pos

type Stmt

type Stmt interface {
	Node
	// contains filtered or unexported methods
}

type SwitchStmt

type SwitchStmt struct {
	Position     Pos
	Discriminant Expr
	Cases        []*CaseClause
}

func (*SwitchStmt) Pos

func (s *SwitchStmt) Pos() Pos

type TemplateExpr

type TemplateExpr struct {
	Position Pos
	Parts    []Expr
	Raw      []string
}

func (*TemplateExpr) Pos

func (t *TemplateExpr) Pos() Pos

type ThisExpr

type ThisExpr struct {
	Position Pos
}

func (*ThisExpr) Pos

func (t *ThisExpr) Pos() Pos

type ThrowStmt

type ThrowStmt struct {
	Position Pos
	Value    Expr
}

func (*ThrowStmt) Pos

func (t *ThrowStmt) Pos() Pos

type TryStmt

type TryStmt struct {
	Position Pos
	Body     []Stmt
	Catch    *CatchClause
	Finally  []Stmt
}

func (*TryStmt) Pos

func (t *TryStmt) Pos() Pos

type TypeAssertion

type TypeAssertion struct {
	Position Pos
	Expr     Expr
	TypeRef  string
}

func (*TypeAssertion) Pos

func (t *TypeAssertion) Pos() Pos

type UnaryExpr

type UnaryExpr struct {
	Position Pos
	Op       string
	Arg      Expr
	Postfix  bool
}

func (*UnaryExpr) Pos

func (u *UnaryExpr) Pos() Pos

type VarDecl

type VarDecl struct {
	Name            string
	Names           []string
	IsDestructuring bool
	Pattern         string
	RestName        string
	Init            Expr
}

type VarKind

type VarKind int
const (
	VarConst VarKind = iota
	VarLet
	VarVar
)

type VarStmt

type VarStmt struct {
	Position Pos
	Kind     VarKind
	Decls    []*VarDecl
}

func (*VarStmt) Pos

func (v *VarStmt) Pos() Pos

type WhileStmt

type WhileStmt struct {
	Position Pos
	Test     Expr
	Body     []Stmt
}

func (*WhileStmt) Pos

func (w *WhileStmt) Pos() Pos

Jump to

Keyboard shortcuts

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