Documentation
¶
Overview ¶
Package parser parses a setup file's functions, types, and fields using an Abstract Syntax Tree.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type FieldSearch ¶ added in v0.2.1
type FieldSearch struct {
// The import of the field (used for the cache).
Import string
// The package name of the field.
Package string
// The name of the field.
Name string
// The actual typename of the field (i.e `DomainUser` in `User DomainUser`).
Definition string
// The parent of the field the FieldSearch will find.
// In the context of the program, a top-level field with no parent is a TypeField.
Parent *models.Field
// The file that holds the type declaration for the field being searched.
DecFile *ast.File
// The options that pertain to a field (and its subfields).
Options []Option
// The current depth-level of the FieldSearch.
Depth int
// The maximum allowed depth-level of the FieldSearch.
MaxDepth int
// contains filtered or unexported fields
}
FieldSearch represents a search that uses Abstract Syntax Tree analysis to find the fields of a typefield.
type Option ¶
type Option struct {
// The compiled regex the option uses for its arguments (map[position]regex).
Regex map[int]*regexp.Regexp
// The values to assign to a type (function or field) if the option applies.
Value interface{}
// The category the option falls under.
// There are currently five: convert, depth, deepcopy, map, custom
Category string
}
Option represents an option applied to functions and fields.
type Parser ¶
type Parser struct {
// The parser options contain options located in the entire setup file.
Options OptionMap
// The fileset of the parser.
Fileset *token.FileSet
// The setup file as an Abstract Syntax Tree.
SetupFile *ast.File
// The ast.Node of the `type Copygen Interface`.
Copygen *ast.InterfaceType
// The last package to be loaded by a Locater.
LastLocated *packages.Package
// The setup filepath.
Setpath string
// The option-comments parsed in the OptionMap.
Comments []*ast.Comment
// contains filtered or unexported fields
}
Parser represents a parser that parses Abstract Syntax Tree data into models.
func (*Parser) SearchForField ¶ added in v0.2.1
func (p *Parser) SearchForField(fs *FieldSearch) (*models.Field, error)
SearchForField executes a field search by locating a field's type declaration, then its subfields.
type TypeDeclaration ¶ added in v0.2.1
type TypeDeclaration struct {
// The package of the type declaration.
Package *packages.Package
// The file the type declaration is located in.
File *ast.File
// The *ast.TypeSpec of the type declaration.
TypeSpec *ast.TypeSpec
}
TypeDeclaration represents the information related to a type's declaration.
Click to show internal directories.
Click to hide internal directories.