ast

package
v0.0.0-...-4f71f7c Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Currently this code is unused I still don't know to use my own decls data type here but I created this file

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractCode

type AbstractCode interface {
	GetCode() string
	GetPackageName() string
	AddImport(importSpec ImportSpec)
	AddInterfaces(interfaceSpecs InterfaceSpecList)
	AddInterfaceFuncDecl() error
	AddStructs(structSpecs StructSpecList)
	AddStructVarDecl(structArgs StructArgList)
	AddWireDependencyInjection(wireDependency WireDependencyInjection)
	AddGlobalVariables()
	AddFunction(functionSpecs FunctionSpecList)
	AddFunctionArgs(functionSpec FunctionSpec)
	AddFunctionCaller(funcName string, callerSpec CallerSpec)
	AddArgsToCallExpr(funcName null.String, callerSpec CallerSpec)
	AddFunctionArgsToReturn(functionReturnArgs FunctionReturnArgsSpec)
	AddCommentOutsideFunction(commentSpec Comment)
	RebuildCode() error
}

func NewAbstractCode

func NewAbstractCode(code string, parserMode parser.Mode) AbstractCode

type AbstractCodeImpl

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

func (*AbstractCodeImpl) AddArgsToCallExpr

func (a *AbstractCodeImpl) AddArgsToCallExpr(funcName null.String, callerSpec CallerSpec)

func (*AbstractCodeImpl) AddCommentOutsideFunction

func (a *AbstractCodeImpl) AddCommentOutsideFunction(commentSpec Comment)

func (*AbstractCodeImpl) AddFuncWireBuild

func (a *AbstractCodeImpl) AddFuncWireBuild(funcName string)

func (*AbstractCodeImpl) AddFunction

func (a *AbstractCodeImpl) AddFunction(functionSpecs FunctionSpecList)

func (*AbstractCodeImpl) AddFunctionArgs

func (a *AbstractCodeImpl) AddFunctionArgs(functionSpec FunctionSpec)

func (*AbstractCodeImpl) AddFunctionArgsToReturn

func (a *AbstractCodeImpl) AddFunctionArgsToReturn(functionReturnArgs FunctionReturnArgsSpec)

func (*AbstractCodeImpl) AddFunctionCaller

func (a *AbstractCodeImpl) AddFunctionCaller(funcName string, callerSpec CallerSpec)

func (*AbstractCodeImpl) AddGlobalVariables

func (a *AbstractCodeImpl) AddGlobalVariables()

func (*AbstractCodeImpl) AddImport

func (a *AbstractCodeImpl) AddImport(importSpec ImportSpec)

func (*AbstractCodeImpl) AddInterfaceFuncDecl

func (a *AbstractCodeImpl) AddInterfaceFuncDecl() error

func (*AbstractCodeImpl) AddInterfaces

func (a *AbstractCodeImpl) AddInterfaces(interfaceSpecs InterfaceSpecList)

func (*AbstractCodeImpl) AddStructVarDecl

func (a *AbstractCodeImpl) AddStructVarDecl(structArgs StructArgList)

func (*AbstractCodeImpl) AddStructs

func (a *AbstractCodeImpl) AddStructs(structSpecs StructSpecList)

func (*AbstractCodeImpl) AddWireDependencyInjection

func (a *AbstractCodeImpl) AddWireDependencyInjection(wireDependency WireDependencyInjection)

AddWireDependencyInjection add this thing like this var productRepo = wire.NewSet(

productrepo.NewRepository,
wire.Bind(
	new(productrepo.Repositories),
	new(*productrepo.RepositoriesImpl),
),

)

func InitHttpProtocol() *http.HttpImpl {
	wire.Build(
		productRepo, <-- and append to here
	)
	return &http.HttpImpl{}
}

TODO: should make the function more globaly

func (*AbstractCodeImpl) GetCode

func (a *AbstractCodeImpl) GetCode() string

func (AbstractCodeImpl) GetPackageName

func (a AbstractCodeImpl) GetPackageName() string

func (*AbstractCodeImpl) RebuildCode

func (a *AbstractCodeImpl) RebuildCode() error

type CallerArg

type CallerArg struct {
	SelectorStmt *CallerArgSelectorStmt
	BasicLit     *CallerArgBasicLit
	Ident        *CallerArgIdent
}

type CallerArgBasicLit

type CallerArgBasicLit struct {
	Kind  token.Token
	Value string
}

type CallerArgIdent

type CallerArgIdent struct {
	Name string
}

type CallerArgList

type CallerArgList []*CallerArg

type CallerArgSelectorStmt

type CallerArgSelectorStmt struct {
	LibName  string
	DataType string
}

type CallerFunc

type CallerFunc struct {
	// Func here has 2 object
	// first is name and the second is selector
	// the Name means the name of the library and the selector is the function
	// example we have fmt.Println. the fmt means the Name and the Println means the selector
	Name     CallerSelecterExpr
	Selector string
}

type CallerSelecterExpr

type CallerSelecterExpr struct {
	Name     string
	Selector string
}

type CallerSpec

type CallerSpec struct {
	Func CallerFunc
	Args CallerArgList
}

type Comment

type Comment struct {
	// FunctionName indicates that the comment is before the function
	FunctionName string
	// Value indicates the comment value
	Value string
}

type CustomDtypes

type CustomDtypes CustomDtypesProp

type CustomDtypesProp

type CustomDtypesProp struct {
	Name      string
	Path      string
	PathAlias string
}

type DataTypes

type DataTypes int
const (
	INT DataTypes = iota + 1
	INT8
	INT16
	INT32
	INT64
	UINT
	UINT8
	UINT16
	UINT32
	UINT64
	UINTPTR
	FLOAT
	FLOAT32
	FLOAT64
	BYTE
	STRING
	BOOL
	RUNE
	COMPLEX64
	COMPLEX128
)

func (DataTypes) String

func (d DataTypes) String() string

type FunctionArg

type FunctionArg struct {
	IsPointer bool
	Name      string
	LibName   string
	DataType  string
}

type FunctionArgList

type FunctionArgList []*FunctionArg

type FunctionBodySpec

type FunctionBodySpec struct {
}

type FunctionReturnArgsSpec

type FunctionReturnArgsSpec struct {
	IsPointer bool
	// FuncName means the name of the function
	// example
	// func NewHttp(), so the FuncName = NewHttp
	FuncName string
	// ReturnName means the name of return
	// example
	// return &Http{}, so the return name is Http
	ReturnName string
	// DataTypeKey name of the data type that we want to inject
	DataTypeKey string
	// DataTypeValue name of the data type that we want to inject
	DataTypeValue string
}

type FunctionReturnSpec

type FunctionReturnSpec struct {
	IsPointer bool
	// IsStruct define that the return is a struct, if the IsStruct is false
	// so it define it an error
	IsStruct bool
	LibName  string
	DataType string
	// Return define the variable name that will be returned
	// example
	//	func a() interface{} {
	//		var a := interface{}
	// 		return a <- a here means Return name
	//	}
	Return string
}

FunctionReturnSpec currently only be able to return a custom struct and an error. it cannot return a number or anythink

type FunctionReturnSpecList

type FunctionReturnSpecList []*FunctionReturnSpec

type FunctionSpec

type FunctionSpec struct {
	Name string
	// StructName define that the function is a method of an object
	StructSpec *FunctionStructSpec
	Args       FunctionArgList
	Returns    *FunctionReturnSpecList
	Body       FunctionBodySpec
}

type FunctionSpecList

type FunctionSpecList []*FunctionSpec

type FunctionStructSpec

type FunctionStructSpec struct {
	// Name means as the struct alias
	Name string
	// DataTypes means the struct name
	DataTypes string
	IsPointer bool
	// IsConstruct define that the function is a construct of an object
	IsConstruct bool
}

type ImportSpec

type ImportSpec struct {
	Name string
	Path string
}

type ImportSpecList

type ImportSpecList []*ImportSpec

type InterfaceDtypes

type InterfaceDtypes string

func (InterfaceDtypes) String

func (i InterfaceDtypes) String() string

type InterfaceMethod

type InterfaceMethod struct {
	Name string
	Args InterfaceMethodArgList
}

type InterfaceMethodArg

type InterfaceMethodArg struct {
	Name      string
	IsPointer bool
}

type InterfaceMethodArgList

type InterfaceMethodArgList []*InterfaceMethodArg

type InterfaceMethodList

type InterfaceMethodList []*InterfaceMethod

type InterfaceSpec

type InterfaceSpec struct {
	Name       string
	StructName string
}

type InterfaceSpecList

type InterfaceSpecList []*InterfaceSpec

type StructArg

type StructArg struct {
	StructName string
	Name       string
	DataType   StructDtypes
	IsPointer  bool
}

type StructArgList

type StructArgList []*StructArg

type StructDtypes

type StructDtypes struct {
	// LibName example in fmt library
	LibName string
	// TypeName example in fmt library have type Scanner
	TypeName string
}

type StructSpec

type StructSpec struct {
	Name          string
	InterfaceName string
}

type StructSpecList

type StructSpecList []*StructSpec

type WireDependencyInjection

type WireDependencyInjection struct {
	VarName                   string
	TargetInjectName          string
	TargetInjectConstructName string
	InterfaceLib              string
	InterfaceName             string
	StructLib                 string
	StructName                string
}

GlobDecl here actually uses to create a dependency injector for wire

Jump to

Keyboard shortcuts

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