package module
Version: v0.0.0-...-879c3ba Latest Latest

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 11 Imported by: 0






View Source
const (
	EOF = -(iota + 1)
View Source
const Whitespace = 1<<'\t' | 1<<'\r' | 1<<' '


This section is empty.


func EachFile

func EachFile(collector *Collector, pkg *Package, callback Callback)

func IsDecimal

func IsDecimal(character rune) bool

func IsIdentifier

func IsIdentifier(character rune, index int) bool

func LowerCamelCase

func LowerCamelCase(str string) string

func NewErrorList

func NewErrorList(errors []error) error


type Argument

type Argument struct {
	Name     string
	TypeInfo ArgumentTypeInfo
	Pointer  bool
	Required bool

func ExtractArgument

func ExtractArgument(structField reflect.StructField) (Argument, error)

type ArgumentType

type ArgumentType int
const (
	InvalidType ArgumentType = iota

type ArgumentTypeInfo

type ArgumentTypeInfo struct {
	ActualType ArgumentType
	ItemType   *ArgumentTypeInfo

func GetArgumentTypeInfo

func GetArgumentTypeInfo(typ reflect.Type) (ArgumentTypeInfo, error)

func (ArgumentTypeInfo) Parse

func (typeInfo ArgumentTypeInfo) Parse(scanner *Scanner, out reflect.Value) error

type Callback

type Callback func(element *File, error error)

type Collector

type Collector struct {

func NewCollector

func NewCollector(registry *Registry) *Collector

func (*Collector) Collect

func (collector *Collector) Collect(pkg *Package) (map[ast.Node]MarkerValues, error)

type Definition

type Definition struct {
	Name   string
	Level  TargetLevel
	Output Output

func MakeDefinition

func MakeDefinition(name string, level TargetLevel, output interface{}) (*Definition, error)

func (*Definition) Parse

func (definition *Definition) Parse(marker string) (interface{}, error)

type ErrorList

type ErrorList []error

func (ErrorList) Error

func (errorList ErrorList) Error() string

type Field

type Field struct {
	Name     string
	Position Position
	Markers  MarkerValues
	Type     Type
	RawFile  *ast.File
	RawField *ast.Field

type File

type File struct {
	Name        string
	FullPath    string
	PackageName string
	Imports     []Import
	Markers     MarkerValues

	Functions      []Function
	StructTypes    []StructType
	InterfaceTypes []InterfaceType
	RawFile        *ast.File

type Function

type Function struct {
	Name         string
	Position     Position
	Markers      MarkerValues
	Parameters   []TypeInfo
	ReturnValues []TypeInfo
	File         *File
	RawFile      *ast.File
	RawFuncDecl  *ast.FuncDecl
	RawFuncType  *ast.FuncType

type Import

type Import struct {
	Name          string
	Path          string
	Position      Position
	RawImportSpec *ast.ImportSpec

type InterfaceType

type InterfaceType struct {
	Name        string
	Position    Position
	Markers     MarkerValues
	Methods     []Method
	File        *File
	RawFile     *ast.File
	RawGenDecl  *ast.GenDecl
	RawTypeSpec *ast.TypeSpec

type MarkerValues

type MarkerValues map[string][]interface{}

func (MarkerValues) Get

func (markerValues MarkerValues) Get(name string) interface{}

type Method

type Method struct {
	Name         string
	Position     Position
	Markers      MarkerValues
	Receiver     *TypeInfo
	Parameters   []TypeInfo
	ReturnValues []TypeInfo
	File         *File
	RawFile      *ast.File
	RawField     *ast.Field
	RawFuncDecl  *ast.FuncDecl
	RawFuncType  *ast.FuncType

type Output

type Output struct {
	Type              reflect.Type
	IsAnonymous       bool
	AnonymousTypeInfo ArgumentTypeInfo
	Fields            map[string]Argument
	FieldNames        map[string]string

type Package

type Package struct {
	// contains filtered or unexported fields

func LoadPackages

func LoadPackages(patterns ...string) ([]*Package, error)

func LoadPackagesWithConfig

func LoadPackagesWithConfig(config *packages.Config, patterns ...string) ([]*Package, error)

type ParserError

type ParserError struct {
	FileName string
	Position Position
	// contains filtered or unexported fields

type Position

type Position struct {
	Line   int
	Column int

type Registry

type Registry struct {
	// contains filtered or unexported fields

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Lookup

func (registry *Registry) Lookup(marker string) *Definition

func (*Registry) Register

func (registry *Registry) Register(name string, level TargetLevel, output interface{}) error

func (*Registry) RegisterWithDefinition

func (registry *Registry) RegisterWithDefinition(definition *Definition) error

type Scanner

type Scanner struct {
	ErrorCallback func(scanner *Scanner, message string)
	// contains filtered or unexported fields

func NewScanner

func NewScanner(source string) *Scanner

func (*Scanner) AddError

func (scanner *Scanner) AddError(message string)

func (*Scanner) ErrorCount

func (scanner *Scanner) ErrorCount() int

func (*Scanner) Expect

func (scanner *Scanner) Expect(expected rune, description string) bool

func (*Scanner) Next

func (scanner *Scanner) Next() rune

func (*Scanner) Peek

func (scanner *Scanner) Peek() rune

func (*Scanner) Scan

func (scanner *Scanner) Scan() rune

func (*Scanner) ScanIdentifier

func (scanner *Scanner) ScanIdentifier() rune

func (*Scanner) ScanNumber

func (scanner *Scanner) ScanNumber() rune

func (*Scanner) ScanString

func (scanner *Scanner) ScanString(quote rune) (len int)

func (*Scanner) SearchIndex

func (scanner *Scanner) SearchIndex() int

func (*Scanner) SetSearchIndex

func (scanner *Scanner) SetSearchIndex(searchIndex int)

func (*Scanner) SkipWhitespaces

func (scanner *Scanner) SkipWhitespaces() rune

func (*Scanner) SourceLength

func (scanner *Scanner) SourceLength() int

func (*Scanner) Token

func (scanner *Scanner) Token() string

type ScannerError

type ScannerError struct {
	Position int
	Message  string

func (ScannerError) Error

func (err ScannerError) Error() string

type StructType

type StructType struct {
	Name        string
	Position    Position
	Markers     MarkerValues
	Fields      []Field
	Methods     []Method
	File        *File
	RawFile     *ast.File
	RawGenDecl  *ast.GenDecl
	RawTypeSpec *ast.TypeSpec

type TargetLevel

type TargetLevel int
const (
	PackageLevel TargetLevel = 1 << iota

type Type

type Type struct {
	PackageName string
	Name        string
	IsPointer   bool
	RawObject   *ast.Object

type TypeInfo

type TypeInfo struct {
	Names    []string
	Type     Type
	RawField *ast.Field

type Visitor

type Visitor struct {
	// contains filtered or unexported fields

func (*Visitor) Visit

func (visitor *Visitor) Visit(node ast.Node) (w ast.Visitor)


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL