source

package module
v0.0.1-beta.13 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 12 Imported by: 0

README

Source

Source is used to parse go source files, it represents the files using go-services/code and is used to modify the source code.

Still a work in progress

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildContext

type BuildContext interface {
	Import(path string) (*ImportInfo, error)
	Cwd() (string, error)
}

type DefaultBuildContext

type DefaultBuildContext struct{}

func (DefaultBuildContext) Cwd

func (d DefaultBuildContext) Cwd() (string, error)

func (DefaultBuildContext) Import

func (d DefaultBuildContext) Import(path string) (*ImportInfo, error)

type Function

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

func (Function) Begin

func (f Function) Begin() int

func (Function) Code

func (f Function) Code() code.Code

func (Function) End

func (f Function) End() int

func (Function) Exported

func (f Function) Exported() bool

func (Function) Func

func (f Function) Func() code.Function

func (Function) InnerBegin

func (f Function) InnerBegin() int

func (Function) InnerEnd

func (f Function) InnerEnd() int

func (Function) Name

func (f Function) Name() string

func (Function) ParamBegin

func (f Function) ParamBegin() int

func (Function) ParamEnd

func (f Function) ParamEnd() int

func (Function) Params

func (f Function) Params() []code.Parameter

func (Function) Receiver

func (f Function) Receiver() *code.Parameter

func (Function) Results

func (f Function) Results() []code.Parameter

func (Function) String

func (f Function) String() string

type Import

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

Import represents an import

type ImportInfo

type ImportInfo struct {
	Dir  string
	Name string
}

type Interface

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

Interface represents a parsed interface

func (Interface) Begin

func (i Interface) Begin() int

func (Interface) Code

func (i Interface) Code() code.Code

func (Interface) End

func (i Interface) End() int

func (Interface) Exported

func (i Interface) Exported() bool

func (Interface) InnerBegin

func (i Interface) InnerBegin() int

func (Interface) InnerEnd

func (i Interface) InnerEnd() int

func (Interface) Interface

func (i Interface) Interface() code.Interface

func (Interface) Methods

func (i Interface) Methods() []InterfaceMethod

func (Interface) Name

func (i Interface) Name() string

func (Interface) String

func (i Interface) String() string

type InterfaceMethod

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

func (InterfaceMethod) Begin

func (f InterfaceMethod) Begin() int

func (InterfaceMethod) Code

func (f InterfaceMethod) Code() code.Code

func (InterfaceMethod) End

func (f InterfaceMethod) End() int

func (InterfaceMethod) Exported

func (f InterfaceMethod) Exported() bool

func (InterfaceMethod) InterfaceMethod

func (f InterfaceMethod) InterfaceMethod() code.InterfaceMethod

func (InterfaceMethod) Name

func (f InterfaceMethod) Name() string

func (InterfaceMethod) Params

func (f InterfaceMethod) Params() []code.Parameter

func (InterfaceMethod) Results

func (f InterfaceMethod) Results() []code.Parameter

func (InterfaceMethod) String

func (f InterfaceMethod) String() string

type Node

type Node interface {
	Exported() bool
	Code() code.Code
	String() string
	Name() string
	Begin() int
	End() int
}

type NodeWithInner

type NodeWithInner interface {
	Node

	InnerBegin() int
	InnerEnd() int
}

type Option

type Option func(*Options)

func WithBuildContext

func WithBuildContext(buildContext BuildContext) Option

type Options

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

type Source

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

func New

func New(src string, opts ...Option) (*Source, error)

func (*Source) AppendCodeToFunction

func (s *Source) AppendCodeToFunction(name string, method *code.RawCode) error

func (*Source) AppendFieldToStruct

func (s *Source) AppendFieldToStruct(name string, field *code.StructField) error

func (*Source) AppendFunction

func (s *Source) AppendFunction(fn code.Function) error

func (*Source) AppendImport

func (s *Source) AppendImport(imp code.Import) error

func (*Source) AppendInterface

func (s *Source) AppendInterface(inf code.Interface) error

func (*Source) AppendMethodToInterface

func (s *Source) AppendMethodToInterface(name string, method code.InterfaceMethod) error

func (*Source) AppendParameterToFunction

func (s *Source) AppendParameterToFunction(name string, param *code.Parameter) error

func (*Source) AppendStructure

func (s *Source) AppendStructure(structure code.Struct) error

func (*Source) CommentInterface

func (s *Source) CommentInterface(inf, comment string) error

func (*Source) CommentInterfaceMethod

func (s *Source) CommentInterfaceMethod(inf, method string, comment string) error

func (*Source) Functions

func (s *Source) Functions() (functions []Function)

func (*Source) GetFunction

func (s *Source) GetFunction(name string) (*Function, error)

func (*Source) GetInterface

func (s *Source) GetInterface(name string) (*Interface, error)

func (*Source) GetStructure

func (s *Source) GetStructure(name string) (*Structure, error)

func (*Source) Imports

func (s *Source) Imports() []Import

func (*Source) Interfaces

func (s *Source) Interfaces() (interfaces []Interface)

func (*Source) Package

func (s *Source) Package() string

func (*Source) String

func (s *Source) String() (string, error)

func (*Source) Structures

func (s *Source) Structures() (structures []Structure)

type Structure

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

Structure represents a parsed structure

func (Structure) Begin

func (s Structure) Begin() int

func (Structure) Code

func (s Structure) Code() code.Code

func (Structure) End

func (s Structure) End() int

func (Structure) Exported

func (s Structure) Exported() bool

func (Structure) Fields

func (s Structure) Fields() []StructureField

func (Structure) InnerBegin

func (s Structure) InnerBegin() int

func (Structure) InnerEnd

func (s Structure) InnerEnd() int

func (Structure) Name

func (s Structure) Name() string

func (Structure) String

func (s Structure) String() string

func (Structure) Struct

func (s Structure) Struct() *code.Struct

type StructureField

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

func (StructureField) Begin

func (f StructureField) Begin() int

func (StructureField) Code

func (f StructureField) Code() code.Code

func (StructureField) End

func (f StructureField) End() int

func (StructureField) Exported

func (f StructureField) Exported() bool

func (StructureField) Field

func (f StructureField) Field() code.StructField

func (StructureField) Name

func (f StructureField) Name() string

func (StructureField) String

func (f StructureField) String() string

func (StructureField) Tags

func (f StructureField) Tags() map[string]string

Jump to

Keyboard shortcuts

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