internal

package
v0.0.0-...-ec57482 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTemplate

func GetTemplate(name string) *template.Template

func InitReservedValues

func InitReservedValues(reservedFuncValues []string)

func ReadAllTemplateFiles

func ReadAllTemplateFiles()

Types

type Field

type Field struct {
	Parent        *Struct
	InputAST      *ast.Field
	InputTypesVar *types.Var

	ParentField *Field
	ChildField  *Field

	Name       string
	Type       string
	StructTag  string
	MapKeyType string

	OwnType      types.Type
	ResolvedType types.Type

	IsBaseModelDerivative bool
	IsBuiltIn             bool
	IsEmbedded            bool
	IsReference           bool

	IsMap     bool
	IsPointer bool
	IsSlice   bool

	IsResolvable bool
	References   *ResolverFieldReferences
}

func (*Field) BuildResolverMethod

func (f *Field) BuildResolverMethod() *Func

func (*Field) CreateChildField

func (f *Field) CreateChildField()

********** SECTION Child Field ********** //

func (*Field) CreateStubResolvableFields

func (f *Field) CreateStubResolvableFields() []*Field

********** SECTION Resolvable Field ********** //

func (*Field) Init

func (f *Field) Init()

func (*Field) MutateResolvableFieldType

func (f *Field) MutateResolvableFieldType()

type Func

type Func struct {
	Parent     *Struct
	SourceFile string
	InputAST   *ast.FuncDecl
	FileSet    *token.FileSet

	Name      string
	Generated bool
}

type Import

type Import struct {
	SourceFile string
	InputAST   *ast.ImportSpec

	Alias string
	Path  string
}

func (*Import) Init

func (i *Import) Init()

type Interface

type Interface struct {
	SourceFile string
	InputAST   *ast.GenDecl
	Name       string
}

type Package

type Package struct {
	IgnoredUserFiles      []string
	IgnoredGeneratedFiles []string

	InputUser           *packages.Package
	InputGenerated      *packages.Package
	InputGeneratedLines map[string][]string

	// Struct-related Values
	Structs       map[string]*Struct // Key: Struct name
	StructMethods map[string][]*Func // Key: Struct name, Value: map[FuncName]*Func

	// Others, key: filename
	Funcs      map[string][]*Func
	Imports    map[string][]*Import
	Interfaces map[string][]*Interface
	Values     map[string][]*Value
}

func (*Package) GeneratePackageFiles

func (p *Package) GeneratePackageFiles() map[string]*PackageFile

func (*Package) Init

func (p *Package) Init()

type PackageFile

type PackageFile struct {
	Filename    string
	PackageName string

	FileContents []string
	Structs      []*Struct
	Functions    []*Func
	ConstValues  []*Value
	Imports      []*Import
	Interfaces   []*Interface
	VarValues    []*Value
}

func (*PackageFile) Init

func (p *PackageFile) Init()

func (*PackageFile) Sort

func (p *PackageFile) Sort()

func (*PackageFile) WriteToFile

func (p *PackageFile) WriteToFile(cfg *config.OutputConfig)

type ResolverFieldReferences

type ResolverFieldReferences struct {
	Level  int
	InLoop bool
	// Where to assign results
	AssignmentVar string
	// Where to obtain ObjectID reference
	IDReferenceVar string

	// Standard References
	RootField     string
	ErrorField    string
	InitBoolField string
	ResolvedField string
}

type Struct

type Struct struct {
	Parent     *Package
	SourceFile string
	InputAST   *ast.StructType
	InputType  *types.Struct

	ParsedMethods []*Func

	// Sorted collection of methods
	CollectionNameMethod *Func
	HookMethods          []*Func // Source file will be set to struct's source file
	DatabaseMethods      []*Func // Source file will be set to struct's source file
	UserDefinedMethods   []*Func // Retain source file for user defined methods
	ResolverMethods      []*Func // Source file will be set to struct's source file

	Name           string
	Generated      bool
	IsCollection   bool
	EmbeddedFields []*Field
	Fields         []*Field
	ResolverFields []*Field
}

func (*Struct) Init

func (s *Struct) Init()

func (*Struct) InitResolverFieldsAndMethods

func (s *Struct) InitResolverFieldsAndMethods()

type Value

type Value struct {
	SourceFile string
	InputTok   token.Token
	InputAST   *ast.ValueSpec
	Name       string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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