resolver

package
v0.0.0-...-99abfb9 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	PublicDecls  map[string][]*FuncData
	PrivateDecls map[string][]*FuncData
	Imports      []string
	Package      string
}

func Resolve

func Resolve(cache *parser.ObjectCache, target, library string) (*Data, error, []error)

type Derivation

type Derivation interface {
	// contains filtered or unexported methods
}

Derivation is a type that represents a derivation of a resolver.

type FieldDecl

type FieldDecl struct {
	Name string
	Type parser.Type
}

A FieldDecl is a type that represents a field of a resolver.

type FuncData

type FuncData struct {
	ImportPaths []string
	Pkg         string
	Receiver    string
	FuncName    string
	FuncReturn  string
	FuncImpl    string
}

type FuncDecl

type FuncDecl interface {
	FuncName() string
	FuncBody() string
	Imports() []string
	Pkg() string
	FuncReturn() string
	// contains filtered or unexported methods
}

A FuncDecl is a type that represents a function of a resolver.

type PrivateFuncDecl

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

A PrivateFuncDecl is a type that represents a private function of a resolver.

func (*PrivateFuncDecl) FuncBody

func (p *PrivateFuncDecl) FuncBody() string

func (*PrivateFuncDecl) FuncName

func (i *PrivateFuncDecl) FuncName() string

func (*PrivateFuncDecl) FuncReturn

func (i *PrivateFuncDecl) FuncReturn() string

func (*PrivateFuncDecl) Imports

func (i *PrivateFuncDecl) Imports() []string

func (*PrivateFuncDecl) Pkg

func (i *PrivateFuncDecl) Pkg() string

func (*PrivateFuncDecl) ReturnType

func (i *PrivateFuncDecl) ReturnType() parser.Type

type PublicFuncDecl

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

A PublicFuncDecl is a type that represents a public function of a resolver.

func (*PublicFuncDecl) FuncBody

func (p *PublicFuncDecl) FuncBody() string

func (*PublicFuncDecl) FuncName

func (p *PublicFuncDecl) FuncName() string

func (*PublicFuncDecl) FuncReturn

func (p *PublicFuncDecl) FuncReturn() string

func (*PublicFuncDecl) Imports

func (p *PublicFuncDecl) Imports() []string

func (*PublicFuncDecl) Pkg

func (p *PublicFuncDecl) Pkg() string

type Resolver

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

func NewResolver

func NewResolver(provider *parser.Struct, cache *parser.ObjectCache, library string) *Resolver

func (*Resolver) AddFunc

func (w *Resolver) AddFunc(fn *PrivateFuncDecl)

func (*Resolver) Resolve

func (r *Resolver) Resolve() ([]FuncDecl, []error)

Resolve feature searches for constructors within the ObjectCache that can resolve dependencies, and returns the resolved results as function declarations (FuncDecl). Here, a 'constructor' refers to a function that is not a method, has one or more arguments, and returns a single value.

'Resolution' means generating the necessary arguments for a constructor and making the function executable. 'Resolved result' refers to the declarations of the functions required to perform such processing.

The resolution process occurs in the following steps:

1. For all interfaces in the ObjectCache, determine a single constructor that will be bound to each. 2. Seek derivations for these interfaces. This involves checking if constructors bound to interface types can be derived using other methods. 3. For all functions in the ObjectCache, determine their resolution results.

Through this process, we can provide a simple and user-friendly interface with resolved dependencies.

Jump to

Keyboard shortcuts

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