configen2

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ac application.Context, args []string) error

Types

type BuildingContext

type BuildingContext struct {
	DOM       *Dom2root
	Component *Dom2component
	Injection *Dom2injection
}

func (*BuildingContext) NewChild

func (inst *BuildingContext) NewChild() *BuildingContext

type CodeBuilder

type CodeBuilder interface {
	Build(dom *Dom2root) (string, error)
}

type CodeTemplate

type CodeTemplate interface {
	Build(ctx *BuildingContext) (string, error)
}

type CodeTemplateFactory

type CodeTemplateFactory interface {
	Create(ctx application.Context) (CodeTemplate, error)
}

type Com1

type Com1 struct {
	markup.Component `id:"foo" class:"bar"`

	// 约定:大写开头的字段为直接(自动)注入字段
	Pool lang.Disposable `inject:"#pool"`
	Name string          `inject:"${abc}"`
	// contains filtered or unexported fields
}

func (*Com1) Com1injector

func (inst *Com1) Com1injector(ctx application.Context) error

type ComExample

type ComExample struct {
	Name    string
	Pool    lang.Disposable ` a:"x" b:"y" `
	Context application.Context
}

type ComplexTypeBuilder

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

func (*ComplexTypeBuilder) FindPackageAliases

func (inst *ComplexTypeBuilder) FindPackageAliases() []int

func (*ComplexTypeBuilder) GetPart

func (inst *ComplexTypeBuilder) GetPart(index int) string

func (*ComplexTypeBuilder) Init

func (inst *ComplexTypeBuilder) Init(typeStr string)

func (*ComplexTypeBuilder) SetPart

func (inst *ComplexTypeBuilder) SetPart(index int, value string)

func (*ComplexTypeBuilder) String

func (inst *ComplexTypeBuilder) String() string

type ComponentInfo

type ComponentInfo struct {
	ID      string
	Classes []string
}

type ComponentInfoTable

type ComponentInfoTable interface {
	Add(com *ComponentInfo)
	All() []*ComponentInfo
}

type Context

type Context struct {
	PWD             fs.Path
	InputFile       fs.Path // the 'configen.properties'
	OutputFile      fs.Path // the 'auto_generated_by_starter_configen.go'
	ConfigenVersion string  // 'configen.version'='v2'
	DryRun          bool
	AppContext      application.Context

	Dom2Builder       Dom2Builder
	CodeBuilder       CodeBuilder
	DirectoryScanner  DirectoryScanner
	SourceFileScanner SourceFileScanner
	ComTable          ComponentInfoTable
	Imports           ImportManager

	DOM1             Dom1root
	DOM2             Dom2root
	OutputSourceCode string
}

type DirectoryScanner

type DirectoryScanner interface {
	Scan(dir fs.Path) error
}

type Dom1builder

type Dom1builder interface {
	SetPackageName(string)
	AddImport(*Dom1import)
	AddStruct(*Dom1struct)
}

type Dom1doc

type Dom1doc struct {
	PackageName string
	ImportList  []*Dom1import
	ComList     []*Dom1struct
}

type Dom1field

type Dom1field struct {
	Name string
	Type string
	Tag  string
}

type Dom1import

type Dom1import struct {
	Alias string
	Path  string
}

type Dom1root

type Dom1root struct {
	PackageName string
	Documents   map[string]*Dom1doc
	Imports     map[string]bool // map[path] yes
}

type Dom1struct

type Dom1struct struct {
	Name   string
	Fields []*Dom1field
}

type Dom2Builder

type Dom2Builder interface {
	Build(ctx *Context) error
}

type Dom2component

type Dom2component struct {
	StructName   string
	Attributes   map[string]string
	InjectionMap map[string]*Dom2injection

	ID      string
	Class   string
	Scope   string
	Aliases string
	ComType string

	// do://inject@injection
	InjectionMainMethod string

	// do://inject@instance (optional)
	InjectMethod string

	InitMethod    string
	DestroyMethod string
}

type Dom2injection

type Dom2injection struct {
	FieldName string
	FieldType string
	FieldTag  string

	Auto     bool
	Selector string

	// do://inject@injection
	InjectionGetterMethod string

	Attributes map[string]string
}

type Dom2root

type Dom2root struct {
	PackageName string
	Imports     map[string]string         // map[ path ] alias
	Components  map[string]*Dom2component // map[com_name] com
}

type FieldTagReader

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

type ImportManager

type ImportManager interface {
	AddImport(path string)
	AddImportWithAlias(alias string, path string)
	AddImportWithoutHash(path string)
	FindAliasByPath(path string) (string, error)
}

type Runner

type Runner interface {
	Run() error
}

type SourceCodeBuilder

type SourceCodeBuilder interface {
	Build() (string, error)
}

type SourceFileScanner

type SourceFileScanner interface {
	Scan(file fs.Path) (*Dom1doc, error)
}

type TemplateCodeBuilderBase

type TemplateCodeBuilderBase struct {
	Context application.Context
	// contains filtered or unexported fields
}

func (*TemplateCodeBuilderBase) AddChild

func (inst *TemplateCodeBuilderBase) AddChild(name string, child CodeTemplate)

func (*TemplateCodeBuilderBase) AddComputed

func (inst *TemplateCodeBuilderBase) AddComputed(name string, fn func(ctx *BuildingContext) (string, error))

func (*TemplateCodeBuilderBase) BuildFromTemplate

func (inst *TemplateCodeBuilderBase) BuildFromTemplate(ctx *BuildingContext) (string, error)

func (*TemplateCodeBuilderBase) Init

func (*TemplateCodeBuilderBase) LoadTemplate

func (inst *TemplateCodeBuilderBase) LoadTemplate(ctx application.Context, path string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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