source

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

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 14 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

func FindAnnotations

func FindAnnotations(name string, annotated Annotated) (annotations []annotation.Annotation)

FindAnnotations finds an annotation by name given an annotated node.

Types

type Annotated

type Annotated interface {
	Annotate(force bool) error
	Annotations() []annotation.Annotation
}

Annotated is the interface all the annotated nodes need to satisfy

type Function

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

func (*Function) Annotate

func (f *Function) Annotate(force bool) error

func (Function) Annotations

func (f Function) Annotations() []annotation.Annotation

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 Interface

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

Interface represents a parsed interface

func (*Interface) Annotate

func (i *Interface) Annotate(force bool) error

func (Interface) Annotations

func (i Interface) Annotations() []annotation.Annotation

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) Annotate

func (f *InterfaceMethod) Annotate(force bool) error

func (InterfaceMethod) Annotations

func (f InterfaceMethod) Annotations() []annotation.Annotation

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 Source

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

func New

func New(src string) (*Source, error)

func (*Source) AnnotateFunction

func (s *Source) AnnotateFunction(name string, ann annotation.Annotation) error

func (*Source) AnnotateInterface

func (s *Source) AnnotateInterface(name string, ann annotation.Annotation) error

func (*Source) AnnotateInterfaceMethod

func (s *Source) AnnotateInterfaceMethod(inf, method string, ann annotation.Annotation) error

func (*Source) AnnotateStructure

func (s *Source) AnnotateStructure(name string, ann annotation.Annotation) error

func (*Source) AnnotateStructureField

func (s *Source) AnnotateStructureField(structure, field string, ann annotation.Annotation) 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) Annotate

func (s *Structure) Annotate(force bool) error

func (Structure) Annotations

func (s Structure) Annotations() []annotation.Annotation

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) Annotate

func (f *StructureField) Annotate(force bool) error

func (StructureField) Annotations

func (f StructureField) Annotations() []annotation.Annotation

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