Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Primitives PosType = reflect.TypeOf(token.Pos(0)) StringType = reflect.TypeOf("") // Structs BlockStmtType = reflect.TypeOf(ast.BlockStmt{}) CaseClauseType = reflect.TypeOf(ast.CaseClause{}) CommClauseType = reflect.TypeOf(ast.CommClause{}) CommentGroupType = reflect.TypeOf(ast.CommentGroup{}) FieldListType = reflect.TypeOf(ast.FieldList{}) FieldType = reflect.TypeOf(ast.Field{}) FileType = reflect.TypeOf(ast.File{}) ForStmtType = reflect.TypeOf(ast.ForStmt{}) FuncDeclType = reflect.TypeOf(ast.FuncDecl{}) GenDeclType = reflect.TypeOf(ast.GenDecl{}) IdentType = reflect.TypeOf(ast.Ident{}) ObjectType = reflect.TypeOf(ast.Object{}) RangeStmtType = reflect.TypeOf(ast.RangeStmt{}) ScopeType = reflect.TypeOf(ast.Scope{}) // Struct Pointers CommentGroupPtrType = reflect.PtrTo(CommentGroupType) FieldListPtrType = reflect.PtrTo(FieldListType) FieldPtrType = reflect.PtrTo(FieldType) FilePtrType = reflect.PtrTo(FileType) ForStmtPtrType = reflect.PtrTo(ForStmtType) FuncDeclPtrType = reflect.PtrTo(FuncDeclType) GenDeclPtrType = reflect.PtrTo(GenDeclType) IdentPtrType = reflect.PtrTo(IdentType) ObjectPtrType = reflect.PtrTo(ObjectType) RangeStmtPtrType = reflect.PtrTo(RangeStmtType) ScopePtrType = reflect.PtrTo(ScopeType) // Interfaces ExprType = reflect.TypeOf((*ast.Expr)(nil)).Elem() NodeType = reflect.TypeOf((*ast.Node)(nil)).Elem() StmtType = reflect.TypeOf((*ast.Stmt)(nil)).Elem() // Slices ExprSliceType = reflect.SliceOf(ExprType) FieldPtrSliceType = reflect.SliceOf(FieldPtrType) StmtSliceType = reflect.SliceOf(StmtType) )
Reflected types of various AST nodes.
Functions ¶
func FindImportSpec ¶
func FindImportSpec(f *ast.File, path string) *ast.ImportSpec
FindImportSpec finds and returns the ImportSpec for an import with the given import path, returning nil if a matching ImportSpec was not found.
func ImportName ¶
func ImportName(spec *ast.ImportSpec) string
ImportName returns the name of the provided import or an empty string if it's not a named import.
func ImportPath ¶
func ImportPath(spec *ast.ImportSpec) string
ImportPath returns the import path of the provided Go import.
func OffsetPos ¶
OffsetPos offsets all token.Pos values found in the given object and its descendants in-place.
Caveat: Free-floating comments on File objects are not handled by OffsetPos.
func TransformPos ¶
TransformPos runs the given function on all token.Pos values found in the given object and its descendants, replacing them in-place with the value produced by the provided function.
Caveat: Free-floating comments on File objects are not handled by TransformPos.
Types ¶
This section is empty.