domain

package
v0.8.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodeFileLoaded added in v0.6.0

func CodeFileLoaded(codeFile *CodeFile) bool

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) AddImport added in v0.6.0

func (codeFile *CodeFile) AddImport(importPath string, alias string) *CodeFile

AddImport to the loaded code file

func (*CodeFile) Code added in v0.6.0

func (codeFile *CodeFile) Code() *ast.File

func (*CodeFile) Fset added in v0.6.0

func (codeFile *CodeFile) Fset() *token.FileSet

func (*CodeFile) GetConst added in v0.6.0

func (codeFile *CodeFile) GetConst() *ast.GenDecl

GetConst declaration

func (*CodeFile) GetTokenIndexByKind added in v0.6.0

func (codeFile *CodeFile) GetTokenIndexByKind(kind token.Token) int

func (*CodeFile) Parse added in v0.6.0

func (codeFile *CodeFile) Parse() error

Parse the code file contained in the configured path

func (*CodeFile) ParseFromPath added in v0.6.0

func (codeFile *CodeFile) ParseFromPath(path string) *CodeFile

ParseFromPath provided as a parameter

func (*CodeFile) Save added in v0.6.0

func (codeFile *CodeFile) Save() error

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

Jump to

Keyboard shortcuts

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