deepparser

package
v0.0.0-...-f938e11 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: MIT Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AstPrint

func AstPrint(t ast.Node, fs *token.FileSet) string

func DetectPackageInType

func DetectPackageInType(t ast.Expr) string

func RebuildOps

func RebuildOps(t ast.Expr) string

func RebuildTypeNameWithoutPackage

func RebuildTypeNameWithoutPackage(t ast.Expr) string

func RemoveJsonIgnoredFields

func RemoveJsonIgnoredFields(def *Definition)

Types

type Constant

type Constant struct {
	Def      *Definition
	Name     string
	Value    string
	ASTValue ast.Expr
}

type Definition

type Definition struct {
	Import   godetector.Import
	Decl     *ast.GenDecl
	Type     *ast.TypeSpec
	TypeName string
	FS       *token.FileSet
	FileDir  string
	File     *ast.File
	Package  map[string]*ast.Package
	// contains filtered or unexported fields
}

func FindDefinitionFromAst

func FindDefinitionFromAst(typeName, alias string, file *ast.File, fileDir string) *Definition

func (*Definition) FindEnumValues

func (def *Definition) FindEnumValues() []Constant

func (*Definition) IsStruct

func (def *Definition) IsStruct() bool

func (*Definition) IsTypeAlias

func (def *Definition) IsTypeAlias() bool

func (*Definition) RemoveJSONIgnoredFields

func (def *Definition) RemoveJSONIgnoredFields()

func (*Definition) StructFields

func (def *Definition) StructFields() []*StField

type StField

type StField struct {
	Name       string
	Type       string
	Tag        string
	Comment    string
	AST        *ast.Field
	Omitempty  bool
	Definition *Definition // could be null if can't parse
}

type Typer

type Typer struct {
	Ordered       []*Definition          // Inspected and parsed definition in order of inspection
	Parsed        map[string]*Definition // Indexed definition where index is <path>@<type>
	BeforeInspect func(def *Definition)  // Invoke hook before inspection (ex: RemoveJsonIgnoredFields)
}

Deeply parsed types. Currently supports only structs

func (*Typer) Add

func (tsg *Typer) Add(def *Definition)

Add recursively pre-parsed structure definition

func (*Typer) AddFromDir

func (tsg *Typer) AddFromDir(typeName string, dir string)

Parse and add recursively type from directory. Do nothing if not found

func (*Typer) AddFromFile

func (tsg *Typer) AddFromFile(typeName string, filename string)

Parse and add recursively type from specific file

func (*Typer) AddFromImport

func (tsg *Typer) AddFromImport(typeName string, importPath string)

Parse and add type using full import name using current working directory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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