go/src/go/ast/ast.go

type Node

type Expr

type Stmt

type Decl

type Comment

func (c *Comment) Pos() token.Pos {}

func (c *Comment) End() token.Pos {}

type CommentGroup

func (g *CommentGroup) Pos() token.Pos {}

func (g *CommentGroup) End() token.Pos {}

func isWhitespace(ch byte) bool {}

func stripTrailingWhitespace(s string) string {}

// Text returns the text of the comment.
// Comment markers (//, /*, and */), the first space of a line comment, and
// leading and trailing empty lines are removed.
// Comment directives like "//line" and "//go:noinline" are also removed.
// Multiple empty lines are reduced to one, and trailing space on lines is trimmed.
// Unless the result is empty, it is newline-terminated.
func (g *CommentGroup) Text() string {}

// isDirective reports whether c is a comment directive.
// This code is also in go/printer.
func isDirective(c string) bool {}

type Field

func (f *Field) Pos() token.Pos {}

func (f *Field) End() token.Pos {}

type FieldList

func (f *FieldList) Pos() token.Pos {}

func (f *FieldList) End() token.Pos {}

// NumFields returns the number of parameters or struct fields represented by a [FieldList].
func (f *FieldList) NumFields() int {}

type BadExpr

type Ident

type Ellipsis

type BasicLit

type FuncLit

type CompositeLit

type ParenExpr

type SelectorExpr

type IndexExpr

type IndexListExpr

type SliceExpr

type TypeAssertExpr

type CallExpr

type StarExpr

type UnaryExpr

type BinaryExpr

type KeyValueExpr

type ChanDir

const SEND

const RECV

type ArrayType

type StructType

type FuncType

type InterfaceType

type MapType

type ChanType

func (x *BadExpr) Pos() token.Pos  {}

func (x *Ident) Pos() token.Pos    {}

func (x *Ellipsis) Pos() token.Pos {}

func (x *BasicLit) Pos() token.Pos {}

func (x *FuncLit) Pos() token.Pos  {}

func (x *CompositeLit) Pos() token.Pos {}

func (x *ParenExpr) Pos() token.Pos      {}

func (x *SelectorExpr) Pos() token.Pos   {}

func (x *IndexExpr) Pos() token.Pos      {}

func (x *IndexListExpr) Pos() token.Pos  {}

func (x *SliceExpr) Pos() token.Pos      {}

func (x *TypeAssertExpr) Pos() token.Pos {}

func (x *CallExpr) Pos() token.Pos       {}

func (x *StarExpr) Pos() token.Pos       {}

func (x *UnaryExpr) Pos() token.Pos      {}

func (x *BinaryExpr) Pos() token.Pos     {}

func (x *KeyValueExpr) Pos() token.Pos   {}

func (x *ArrayType) Pos() token.Pos      {}

func (x *StructType) Pos() token.Pos     {}

func (x *FuncType) Pos() token.Pos {}

func (x *InterfaceType) Pos() token.Pos {}

func (x *MapType) Pos() token.Pos       {}

func (x *ChanType) Pos() token.Pos      {}

func (x *BadExpr) End() token.Pos {}

func (x *Ident) End() token.Pos   {}

func (x *Ellipsis) End() token.Pos {}

func (x *BasicLit) End() token.Pos       {}

func (x *FuncLit) End() token.Pos        {}

func (x *CompositeLit) End() token.Pos   {}

func (x *ParenExpr) End() token.Pos      {}

func (x *SelectorExpr) End() token.Pos   {}

func (x *IndexExpr) End() token.Pos      {}

func (x *IndexListExpr) End() token.Pos  {}

func (x *SliceExpr) End() token.Pos      {}

func (x *TypeAssertExpr) End() token.Pos {}

func (x *CallExpr) End() token.Pos       {}

func (x *StarExpr) End() token.Pos       {}

func (x *UnaryExpr) End() token.Pos      {}

func (x *BinaryExpr) End() token.Pos     {}

func (x *KeyValueExpr) End() token.Pos   {}

func (x *ArrayType) End() token.Pos      {}

func (x *StructType) End() token.Pos     {}

func (x *FuncType) End() token.Pos {}

func (x *InterfaceType) End() token.Pos {}

func (x *MapType) End() token.Pos       {}

func (x *ChanType) End() token.Pos      {}

// exprNode() ensures that only expression/type nodes can be
// assigned to an Expr.
func (*BadExpr) exprNode()        {}

func (*Ident) exprNode()          {}

func (*Ellipsis) exprNode()       {}

func (*BasicLit) exprNode()       {}

func (*FuncLit) exprNode()        {}

func (*CompositeLit) exprNode()   {}

func (*ParenExpr) exprNode()      {}

func (*SelectorExpr) exprNode()   {}

func (*IndexExpr) exprNode()      {}

func (*IndexListExpr) exprNode()  {}

func (*SliceExpr) exprNode()      {}

func (*TypeAssertExpr) exprNode() {}

func (*CallExpr) exprNode()       {}

func (*StarExpr) exprNode()       {}

func (*UnaryExpr) exprNode()      {}

func (*BinaryExpr) exprNode()     {}

func (*KeyValueExpr) exprNode()   {}

func (*ArrayType) exprNode()     {}

func (*StructType) exprNode()    {}

func (*FuncType) exprNode()      {}

func (*InterfaceType) exprNode() {}

func (*MapType) exprNode()       {}

func (*ChanType) exprNode()      {}

// NewIdent creates a new [Ident] without position.
// Useful for ASTs generated by code other than the Go parser.
func NewIdent(name string) *Ident {}

// IsExported reports whether name starts with an upper-case letter.
func IsExported(name string) bool {}

// IsExported reports whether id starts with an upper-case letter.
func (id *Ident) IsExported() bool {}

func (id *Ident) String() string {}

type BadStmt

type DeclStmt

type EmptyStmt

type LabeledStmt

type ExprStmt

type SendStmt

type IncDecStmt

type AssignStmt

type GoStmt

type DeferStmt

type ReturnStmt

type BranchStmt

type BlockStmt

type IfStmt

type CaseClause

type SwitchStmt

type TypeSwitchStmt

type CommClause

type SelectStmt

type ForStmt

type RangeStmt

func (s *BadStmt) Pos() token.Pos        {}

func (s *DeclStmt) Pos() token.Pos       {}

func (s *EmptyStmt) Pos() token.Pos      {}

func (s *LabeledStmt) Pos() token.Pos    {}

func (s *ExprStmt) Pos() token.Pos       {}

func (s *SendStmt) Pos() token.Pos       {}

func (s *IncDecStmt) Pos() token.Pos     {}

func (s *AssignStmt) Pos() token.Pos     {}

func (s *GoStmt) Pos() token.Pos         {}

func (s *DeferStmt) Pos() token.Pos      {}

func (s *ReturnStmt) Pos() token.Pos     {}

func (s *BranchStmt) Pos() token.Pos     {}

func (s *BlockStmt) Pos() token.Pos      {}

func (s *IfStmt) Pos() token.Pos         {}

func (s *CaseClause) Pos() token.Pos     {}

func (s *SwitchStmt) Pos() token.Pos     {}

func (s *TypeSwitchStmt) Pos() token.Pos {}

func (s *CommClause) Pos() token.Pos     {}

func (s *SelectStmt) Pos() token.Pos     {}

func (s *ForStmt) Pos() token.Pos        {}

func (s *RangeStmt) Pos() token.Pos      {}

func (s *BadStmt) End() token.Pos  {}

func (s *DeclStmt) End() token.Pos {}

func (s *EmptyStmt) End() token.Pos {}

func (s *LabeledStmt) End() token.Pos {}

func (s *ExprStmt) End() token.Pos    {}

func (s *SendStmt) End() token.Pos    {}

func (s *IncDecStmt) End() token.Pos {}

func (s *AssignStmt) End() token.Pos {}

func (s *GoStmt) End() token.Pos     {}

func (s *DeferStmt) End() token.Pos  {}

func (s *ReturnStmt) End() token.Pos {}

func (s *BranchStmt) End() token.Pos {}

func (s *BlockStmt) End() token.Pos {}

func (s *IfStmt) End() token.Pos {}

func (s *CaseClause) End() token.Pos {}

func (s *SwitchStmt) End() token.Pos     {}

func (s *TypeSwitchStmt) End() token.Pos {}

func (s *CommClause) End() token.Pos {}

func (s *SelectStmt) End() token.Pos {}

func (s *ForStmt) End() token.Pos    {}

func (s *RangeStmt) End() token.Pos  {}

// stmtNode() ensures that only statement nodes can be
// assigned to a Stmt.
func (*BadStmt) stmtNode()        {}

func (*DeclStmt) stmtNode()       {}

func (*EmptyStmt) stmtNode()      {}

func (*LabeledStmt) stmtNode()    {}

func (*ExprStmt) stmtNode()       {}

func (*SendStmt) stmtNode()       {}

func (*IncDecStmt) stmtNode()     {}

func (*AssignStmt) stmtNode()     {}

func (*GoStmt) stmtNode()         {}

func (*DeferStmt) stmtNode()      {}

func (*ReturnStmt) stmtNode()     {}

func (*BranchStmt) stmtNode()     {}

func (*BlockStmt) stmtNode()      {}

func (*IfStmt) stmtNode()         {}

func (*CaseClause) stmtNode()     {}

func (*SwitchStmt) stmtNode()     {}

func (*TypeSwitchStmt) stmtNode() {}

func (*CommClause) stmtNode()     {}

func (*SelectStmt) stmtNode()     {}

func (*ForStmt) stmtNode()        {}

func (*RangeStmt) stmtNode()      {}

type Spec

type ImportSpec

type ValueSpec

type TypeSpec

func (s *ImportSpec) Pos() token.Pos {}

func (s *ValueSpec) Pos() token.Pos {}

func (s *TypeSpec) Pos() token.Pos  {}

func (s *ImportSpec) End() token.Pos {}

func (s *ValueSpec) End() token.Pos {}

func (s *TypeSpec) End() token.Pos {}

// specNode() ensures that only spec nodes can be
// assigned to a Spec.
func (*ImportSpec) specNode() {}

func (*ValueSpec) specNode()  {}

func (*TypeSpec) specNode()   {}

type BadDecl

type GenDecl

type FuncDecl

func (d *BadDecl) Pos() token.Pos  {}

func (d *GenDecl) Pos() token.Pos  {}

func (d *FuncDecl) Pos() token.Pos {}

func (d *BadDecl) End() token.Pos {}

func (d *GenDecl) End() token.Pos {}

func (d *FuncDecl) End() token.Pos {}

// declNode() ensures that only declaration nodes can be
// assigned to a Decl.
func (*BadDecl) declNode()  {}

func (*GenDecl) declNode()  {}

func (*FuncDecl) declNode() {}

type File

// Pos returns the position of the package declaration.
// (Use FileStart for the start of the entire file.)
func (f *File) Pos() token.Pos {}

// End returns the end of the last declaration in the file.
// (Use FileEnd for the end of the entire file.)
func (f *File) End() token.Pos {}

type Package

func (p *Package) Pos() token.Pos {}

func (p *Package) End() token.Pos {}

// IsGenerated reports whether the file was generated by a program,
// not handwritten, by detecting the special comment described
// at https://go.dev/s/generatedcode.
//
// The syntax tree must have been parsed with the [parser.ParseComments] flag.
// Example:
//
//	f, err := parser.ParseFile(fset, filename, src, parser.ParseComments|parser.PackageClauseOnly)
//	if err != nil { ... }
//	gen := ast.IsGenerated(f)
func IsGenerated(file *File) bool {}

func generator(file *File) (string, bool) {}

// Unparen returns the expression with any enclosing parentheses removed.
func Unparen(e Expr) Expr {}