Documentation
¶
Index ¶
- func CodeFileLoaded(codeFile *CodeFile) bool
- type CodeFile
- func (codeFile *CodeFile) AddAttributeToStruct(structTypeName string, attributeName string, attributeType string, ...) *CodeFile
- func (codeFile *CodeFile) AddCallToFunction(functionName string, newStatementCall string, newStatementArguments string, ...) *CodeFile
- func (codeFile *CodeFile) AddConstant(constantName string, constantKind token.Token, constantValue string) *CodeFile
- func (codeFile *CodeFile) AddImport(importPath string, alias string) *CodeFile
- func (codeFile *CodeFile) Code() *ast.File
- func (codeFile *CodeFile) Fset() *token.FileSet
- func (codeFile *CodeFile) GetConst() *ast.GenDecl
- func (codeFile *CodeFile) GetTokenIndexByKind(kind token.Token) int
- func (codeFile *CodeFile) Parse() error
- func (codeFile *CodeFile) ParseFromPath(path string) *CodeFile
- func (codeFile *CodeFile) Save() error
- type Renderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CodeFileLoaded ¶ added in v0.6.0
CodeFileLoaded is true if the code file is not nil and the file was parsed
Types ¶
type CodeFile ¶ added in v0.6.0
type CodeFile struct {
// contains filtered or unexported fields
}
CodeFile provides the features for parsing and editing
func (*CodeFile) AddAttributeToStruct ¶ added in v0.6.4
func (codeFile *CodeFile) AddAttributeToStruct(structTypeName string, attributeName string, attributeType string, attributeValue string) *CodeFile
AddAttributeToStruct adds a new attribute to an existing struct with the given name (e.g. "NewField"), type (e.g. "string") and value (e.g. "`json:\"new_field\"`")
func (*CodeFile) AddCallToFunction ¶ added in v0.6.5
func (codeFile *CodeFile) AddCallToFunction(functionName string, newStatementCall string, newStatementArguments string, matchStatement func(statementCode string) bool) *CodeFile
AddCallToFunction adds a new call statement (command to call a function with|without parameters) to the function with the given "functionName", under the statement found by the "matchStatement" parameter. If nil is provided as the parameter "matchStatement", the newStatement is added as the last line of the function
func (*CodeFile) AddConstant ¶ added in v0.6.0
func (codeFile *CodeFile) AddConstant(constantName string, constantKind token.Token, constantValue string) *CodeFile
AddConstant to the loaded code file
func (*CodeFile) GetTokenIndexByKind ¶ added in v0.6.0
func (*CodeFile) ParseFromPath ¶ added in v0.6.0
ParseFromPath provided as a parameter
type Renderer ¶
type Renderer interface { //RenderFile renders a template file RenderFile(sourcePath string, info os.FileInfo) error //RenderPath renders an object (file os directory) in the templates directory RenderPath(sourcePath string, info os.FileInfo, err error) error //BackupExistingCode make a copy of the changed file BackupExistingCode(sourcePath string) error //RenderString processing the provided template source file, using the provided variables RenderString(spell domain.Spell, commandName string, stringTemplateFileName string, variables map[string]interface{}) (string, error) //RenderTemplate renders all templates in the template directory providing the respective variables //commandName: specifies the name of the command for which the template will be rendered //globalVariables: defines the list of variables (value) which should be provided for rendering all files //specificVariables: defines the list of variables (value) which should be provided for rendering specific file names (key) RenderTemplate(spell tooldomain.Spell, commandName string, globalVariables map[string]interface{}, specificVariables map[string]map[string]interface{}) error }
Renderer defines the features delivered by the Code Template Renderer
func GetRenderer ¶
func GetRenderer() Renderer
GetRenderer returns the current component registered to provide the code rendering features