Documentation ¶
Overview ¶
Package codegen implements code generation logic
Index ¶
- type CustomSlice
- type IndexBy
- type IndexGenerator
- func (n *IndexGenerator) OnAssign(assign *ast.Assign) (ast.Expression, error)
- func (n *IndexGenerator) OnCallExpr(expr *ast.CallExpr) (ast.Expression, error)
- func (n *IndexGenerator) OnConditionStmt(value *ast.Condition) (ast.Expression, error)
- func (n *IndexGenerator) OnSliceItem(value *ast.Ident, set *ast.Ident) error
- type Option
- type Options
- type Plugin
- type Template
- func (t *Template) BuildInput(spec *inference.Spec, explicitInput inference.State, opts ...Option)
- func (t *Template) BuildLogic(spec *inference.Spec, opts ...Option)
- func (t *Template) BuildTypeDef(spec *inference.Spec, wrapperField string, columns state.Documentation)
- func (t *Template) ColumnParameterNamer(selector inference.Selector) inference.ColumnParameterNamer
- func (t *Template) EnsureImports(aType *inference.Type)
- func (t *Template) FileMethodFragment() string
- func (t *Template) FilePrefix() string
- func (t *Template) GenerateDSQL(opts ...Option) (string, error)
- func (t *Template) GenerateEntity(ctx context.Context, pkg string, info *plugin.Info, ...) (string, error)
- func (t *Template) GenerateHandler(opts *options.Generate, info *plugin.Info) (string, string, string, error)
- func (t *Template) GenerateInput(pkg string, info *plugin.Info, embedContent map[string]string) string
- func (t *Template) GenerateInputInit(pkg string) string
- func (t *Template) GenerateInputValidate(pkg string) string
- func (t *Template) GenerateOutput(pkg string, info *plugin.Info) string
- func (t *Template) InputDataField() string
- func (t *Template) OutputDataField() string
- func (t *Template) ParamIndexName(name, by string) string
- func (t *Template) ParamName(name string) string
- func (t *Template) ParamPrefix() string
- func (t *Template) RecordName(name string) string
- func (t *Template) RecordPrefix() string
- func (t *Template) SetResource(resource *translator.Resource)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CustomSlice ¶
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 ¶
type Option ¶
type Option func(o *Options)
func WithHTTPMethod ¶
func WithInsert ¶
func WithInsert() Option
func WithLowerCamelIdent ¶
func WithLowerCamelIdent() Option
func WithUpdate ¶
func WithUpdate() Option
func WithoutBusinessLogic ¶
func WithoutBusinessLogic() Option
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
func (*Options) IsInsertOnly ¶ added in v0.10.0
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 (*Template) BuildTypeDef ¶
func (*Template) ColumnParameterNamer ¶
func (t *Template) ColumnParameterNamer(selector inference.Selector) inference.ColumnParameterNamer
func (*Template) EnsureImports ¶
func (*Template) FileMethodFragment ¶
func (*Template) FilePrefix ¶
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 (*Template) GenerateInput ¶
func (*Template) GenerateInputInit ¶ added in v0.10.0
func (*Template) GenerateInputValidate ¶ added in v0.10.0
func (*Template) GenerateOutput ¶
func (*Template) InputDataField ¶ added in v0.10.0
func (*Template) OutputDataField ¶ added in v0.10.0
func (*Template) ParamIndexName ¶
func (*Template) ParamPrefix ¶
func (*Template) RecordName ¶
func (*Template) RecordPrefix ¶
func (*Template) SetResource ¶
func (t *Template) SetResource(resource *translator.Resource)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.