parser

package
v0.0.0-...-704dcf6 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2018 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {

	// DefList map
	DefList map[string]*ModelDef

	// PkgFile path for parse
	PkgFile string

	// PkgName contains name of parsed package
	PkgName string

	// ModelImport name, by default `model`
	ModelImport string

	// FieldImport name, by default `field`
	FieldImport string
	// contains filtered or unexported fields
}

Context for parsing

type FieldDef

type FieldDef struct {
	// Field instance
	Field field.Mapper

	// MethodName in model instance which returns this field
	MethodName string
}

func NewFieldDef

func NewFieldDef(fieldName string) *FieldDef

NewFieldDef instance constructo, name should be method name not name from table

type ModelDef

type ModelDef struct {
	// Model instance
	Model model.Base

	// Fields map by their model instance getter methods names
	Fields map[string]*FieldDef

	// TypeDefined in parsed file, and no need generate it struct
	TypeDefined bool
}

ModelDef options

func NewModelDef

func NewModelDef(modelName string) *ModelDef

NewModelDef instance constructor

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser golang file

func New

func New(filePath string) *Parser

New parser instance

func (*Parser) InspectTypes

func (p *Parser) InspectTypes(ctx *Context) func(ast.Node) bool

InspectTypes declarations

func (*Parser) InspectVars

func (p *Parser) InspectVars(ctx *Context) func(ast.Node) bool

InspectVars declarations

func (*Parser) Parse

func (p *Parser) Parse() (*Context, error)

Parse go source file

Jump to

Keyboard shortcuts

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