parser

package
v0.0.0-...-e7a43b6 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2018 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Datastore = iota + 1
	Handler
	Router
)

Categories for output generated files

Variables

This section is empty.

Functions

func AddMethod

func AddMethod(iface *ast.InterfaceType, method *ast.Field)

AddMethod modyfies iface by adding method

func GetFuncDecls

func GetFuncDecls(file *ast.File) []*ast.FuncDecl

GetFuncDecls returns the list of func declarations

func GetInterface

func GetInterface(file *ast.File, name string) *ast.InterfaceType

GetInterface returns certain interface identified by name

func GetInterfaceMethods

func GetInterfaceMethods(iface *ast.InterfaceType) []*ast.Field

GetInterfaceMethods returns the list of methods in a declared interface

func HasMethod

func HasMethod(iface *ast.InterfaceType, methodName string) bool

HasMethod returns true if found method into iface

Types

type TypeField

type TypeField struct {
	Name string
	Type string
}

TypeField holds a field in a type

type TypeHolder

type TypeHolder struct {
	Name   string
	Source *io.GoFile
	Fields []TypeField
	Decl   *ast.GenDecl
}

TypeHolder holds a type previously read from file

func ComposeTypeHolders

func ComposeTypeHolders(source *io.GoFile) ([]*TypeHolder, error)

ComposeTypeHolders composes the type holders for the types in source file

func (*TypeHolder) FieldsAsDMLParams

func (holder *TypeHolder) FieldsAsDMLParams() string

FieldsAsDMLParams returns something like "field1=$1, field2=$2, field3=$3"

func (*TypeHolder) FieldsEnum

func (holder *TypeHolder) FieldsEnum() string

FieldsEnum returns enum of the fields including type indentifier and field name: "theType.Field1, theType.Field2, theType.FieldN"

func (*TypeHolder) FieldsEnumRef

func (holder *TypeHolder) FieldsEnumRef() string

FieldsEnumRef returns enum of type fields, including type identifiera and field name reference: "&theType.Field1, &theType.Field2, &theType.FieldN"

func (*TypeHolder) FieldsInDDL

func (holder *TypeHolder) FieldsInDDL() string

FieldsInDDL returns the type fields as they are used for SQL DDL operations, like: "Field1 varchar(200), Field2 int, FieldN varchar(200)"

func (*TypeHolder) FieldsInDML

func (holder *TypeHolder) FieldsInDML() string

FieldsInDML returns "field1, field2, field3"

func (*TypeHolder) FindFieldName

func (holder *TypeHolder) FindFieldName() string

FindFieldName return the name of the field used for searches

func (*TypeHolder) IDFieldAsDMLParam

func (holder *TypeHolder) IDFieldAsDMLParam() string

IDFieldAsDMLParam returns something like "id=$4"

func (*TypeHolder) IDFieldInDDL

func (holder *TypeHolder) IDFieldInDDL() string

IDFieldInDDL returns the IDField as seen in SQL DDL operations

func (*TypeHolder) IDFieldName

func (holder *TypeHolder) IDFieldName() string

IDFieldName returns the name of the first field, taken as ID

func (*TypeHolder) IDFieldPattern

func (holder *TypeHolder) IDFieldPattern() string

IDFieldPattern returns the pattern associated with id field type, to be used when routing REST paths

func (*TypeHolder) IDFieldType

func (holder *TypeHolder) IDFieldType() string

IDFieldType returns the type of the first field, taken as ID

func (*TypeHolder) IDFieldTypeFormat

func (holder *TypeHolder) IDFieldTypeFormat() string

IDFieldTypeFormat returns the type formatting instruction to have ID as string

func (*TypeHolder) IDFieldTypeParse

func (holder *TypeHolder) IDFieldTypeParse() string

IDFieldTypeParse returns the type parsing instruction for ID field

func (*TypeHolder) Identifier

func (holder *TypeHolder) Identifier() string

Identifier returns type name in camel case, except first letter, which is lower case: "theType"

func (*TypeHolder) ReplaceInTemplate

func (holder *TypeHolder) ReplaceInTemplate(templateContent string) string

ReplaceInTemplate replaces template marks with holder data

func (*TypeHolder) ValuesInDMLParams

func (holder *TypeHolder) ValuesInDMLParams() string

ValuesInDMLParams returns something like "$1, $2, $3"

Jump to

Keyboard shortcuts

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