Help us shape the future of Go! Take the 2026 Go Developer Survey

reflection

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AstFileAccessor

type AstFileAccessor func() (*AstFileSource, error)

func AstFromFile

func AstFromFile(sourceFilePath string) AstFileAccessor

AstFromFile Creates an AstFileAccessor object for the given Golang source file.

func AstFromSource

func AstFromSource(code []byte) AstFileAccessor

AstFromSource Creates an AstFileAccessor object for the given source code.

type AstFileSource added in v0.10.0

type AstFileSource struct {
	File     *ast.File
	Filename string
}

type AstFileVisitor

type AstFileVisitor interface {
	AstVisitor
	VisitComment(comment *ast.Comment)
	VisitFile(file *ast.File)
	VisitImport(importSpec *ast.ImportSpec)
	VisitInterfaceType(name string, interfaceType *ast.InterfaceType)
	VisitFuncType(name string, funcType *ast.FuncType)
	VisitStructType(name string, structType *ast.StructType)
	Model() (*Model, error)
}

func NewFileVisitor

func NewFileVisitor() AstFileVisitor

type AstTypeSpecWalker

type AstTypeSpecWalker interface {
	WalkInterface(interfaceType *ast.InterfaceType)
	WalkFunc(name string, funcSpec *ast.FuncType)
}

func NewTypeWalker

func NewTypeWalker(typeVisitor AstTypeVisitor) AstTypeSpecWalker

NewTypeWalker Creates a new AstTypeSpecWalker object.

type AstTypeVisitor

type AstTypeVisitor interface {
	VisitMethod(name string, method *ast.FuncType)
}

type AstVisitor

type AstVisitor interface {
	VisitNode(node ast.Node) bool
}

type AstWalker

type AstWalker interface {
	WalkSyntaxTree(file *ast.File) error
}

func NewSyntaxWalker

func NewSyntaxWalker(visitor AstVisitor) AstWalker

NewSyntaxWalker Creates a new AstWalker object.

type Comment

type Comment struct {
	SymbolInfo
	Text string
}

type FuncType

type FuncType struct {
	SymbolInfo
	Name       string
	Parameters []Parameter
	Results    []Parameter
}

type Interface

type Interface struct {
	SymbolInfo
	Name    string
	Methods []Method
}

func InterfaceWithName

func InterfaceWithName(name string, info SymbolInfo) Interface

type Method

type Method struct {
	SymbolInfo
	Name       string
	Parameters []Parameter
	Results    []Parameter
}

type Model

type Model struct {
	Comments    []Comment
	Interfaces  []Interface
	FuncTypes   []FuncType
	PackageName string
	Imports     []string
}

Model The generator root model type.

func (*Model) AddImport

func (m *Model) AddImport(s string)

type ModelConfigurationFunc

type ModelConfigurationFunc func(m *Model)

type Parameter

type Parameter struct {
	Name string
	Type *ParameterType
}

func CollectParametersFor

func CollectParametersFor(funcType *ast.FuncType) []Parameter

func CollectResultFieldsFor

func CollectResultFieldsFor(funcType *ast.FuncType) []Parameter

func (Parameter) IsEllipsis added in v1.0.1

func (p Parameter) IsEllipsis() bool

IsEllipsis determines if the parameter type is an ellipsis (`...`) parameter.

func (Parameter) MatchesType

func (p Parameter) MatchesType(name string) bool

type ParameterType added in v0.10.0

type ParameterType struct {
	Name         string
	SelectorName string
	IsArray      bool
	IsEllipsis   bool
	IsInterface  bool
	IsPointer    bool
	Next         *ParameterType
}

type SymbolInfo

type SymbolInfo struct {
	Id  uint64
	Pos token.Pos
	End token.Pos
}

Jump to

Keyboard shortcuts

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