codegen

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

README

Grammar

Parameter auto-detection

Set Marker

Struct types

Relations

Documentation

Overview

Package codegen implements code generation logic

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CustomSlice

type CustomSlice struct {
	Name         string
	ReceiverName string
	ItemType     reflect.Type
	Item         string
}

type IndexBy

type IndexBy struct {
	FnName    string
	SliceType string
	IndexType string
}

type IndexGenerator

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

func NewIndexGenerator

func NewIndexGenerator(specState inference.State) *IndexGenerator

func (*IndexGenerator) OnAssign

func (n *IndexGenerator) OnAssign(assign *ast.Assign) (ast.Expression, error)

func (*IndexGenerator) OnCallExpr

func (n *IndexGenerator) OnCallExpr(expr *ast.CallExpr) (ast.Expression, error)

func (*IndexGenerator) OnConditionStmt

func (n *IndexGenerator) OnConditionStmt(value *ast.Condition) (ast.Expression, error)

func (*IndexGenerator) OnSliceItem

func (n *IndexGenerator) OnSliceItem(value *ast.Ident, set *ast.Ident) error

type Option

type Option func(o *Options)

func WithDML

func WithDML() Option

func WithHTTPMethod

func WithHTTPMethod(method string) Option

func WithInsert

func WithInsert() Option

func WithLang

func WithLang(lang string) Option

func WithLowerCamelIdent

func WithLowerCamelIdent() Option

func WithPatch

func WithPatch() Option

func WithUpdate

func WithUpdate() Option

func WithoutBusinessLogic

func WithoutBusinessLogic() Option

type Options

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

func (*Options) IsGoLang

func (o *Options) IsGoLang() bool

func (*Options) IsInsertOnly added in v0.10.0

func (o *Options) IsInsertOnly() bool

type Plugin

type Plugin struct{}

func NewPlugin

func NewPlugin() *Plugin

func (*Plugin) GenerateChecksum

func (p *Plugin) GenerateChecksum(info *plugin.Info) string

func (*Plugin) GenerateDependency

func (p *Plugin) GenerateDependency(info *plugin.Info) string

func (*Plugin) GeneratePlugin

func (p *Plugin) GeneratePlugin(info *plugin.Info) string

type Template

type Template struct {
	Resource   *translator.Resource
	Spec       *inference.Spec
	Config     *translator.Rule
	TypeDef    *view.TypeDefinition
	IsHandler  bool
	InsertOnly bool
	inference.Imports
	State          inference.State
	Output         inference.State
	BusinessLogic  *ast.Block
	IndexGenerator *IndexGenerator
	IndexByCode    string

	InputType      reflect.Type
	BodyType       reflect.Type
	BodyParameter  *inference.Parameter
	OutputType     reflect.Type
	MethodFragment string

	Prefix string
	// contains filtered or unexported fields
}

func NewTemplate

func NewTemplate(rule *translator.Rule, spec *inference.Spec) *Template

func (*Template) BuildInput

func (t *Template) BuildInput(spec *inference.Spec, explicitInput inference.State, opts ...Option)

func (*Template) BuildLogic

func (t *Template) BuildLogic(spec *inference.Spec, opts ...Option)

func (*Template) BuildTypeDef

func (t *Template) BuildTypeDef(spec *inference.Spec, wrapperField string, columns state.Documentation)

func (*Template) ColumnParameterNamer

func (t *Template) ColumnParameterNamer(selector inference.Selector) inference.ColumnParameterNamer

func (*Template) EnsureImports

func (t *Template) EnsureImports(aType *inference.Type)

func (*Template) FileMethodFragment

func (t *Template) FileMethodFragment() string

func (*Template) FilePrefix

func (t *Template) FilePrefix() string

func (*Template) GenerateDSQL

func (t *Template) GenerateDSQL(opts ...Option) (string, error)

func (*Template) GenerateEntity

func (t *Template) GenerateEntity(ctx context.Context, pkg string, info *plugin.Info, embedContent map[string]string) (string, error)

GenerateEntity generate golang entity

func (*Template) GenerateHandler

func (t *Template) GenerateHandler(opts *options.Generate, info *plugin.Info) (string, string, string, error)

func (*Template) GenerateInput

func (t *Template) GenerateInput(pkg string, info *plugin.Info, embedContent map[string]string) string

func (*Template) GenerateInputInit added in v0.10.0

func (t *Template) GenerateInputInit(pkg string) string

func (*Template) GenerateInputValidate added in v0.10.0

func (t *Template) GenerateInputValidate(pkg string) string

func (*Template) GenerateOutput

func (t *Template) GenerateOutput(pkg string, info *plugin.Info) string

func (*Template) InputDataField added in v0.10.0

func (t *Template) InputDataField() string

func (*Template) OutputDataField added in v0.10.0

func (t *Template) OutputDataField() string

func (*Template) ParamIndexName

func (t *Template) ParamIndexName(name, by string) string

func (*Template) ParamName

func (t *Template) ParamName(name string) string

func (*Template) ParamPrefix

func (t *Template) ParamPrefix() string

func (*Template) RecordName

func (t *Template) RecordName(name string) string

func (*Template) RecordPrefix

func (t *Template) RecordPrefix() string

func (*Template) SetResource

func (t *Template) SetResource(resource *translator.Resource)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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