model

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateProviderIdentifiers = errors.New("duplicate provider identifiers found which were not overridden")

Functions

This section is empty.

Types

type EmbeddedComponent

type EmbeddedComponent struct {
	Identifier

	PackageAlias string
	ImportPath   string

	Imports    []string
	Functions  map[Identifier]struct{}
	Singletons []Identifier
	Providers  *ProviderCollection
}

func NewEmbeddedComponent

func NewEmbeddedComponent(identifier Identifier) *EmbeddedComponent

type File

type File struct {
	Source     string
	Package    string
	Imports    []string
	Providers  *ProviderCollection
	Components map[Identifier]*EmbeddedComponent
}

File is the model of a parsed file. It contains the imports used within the original file as well as a slice of all direct providers defined within the file.

func NewFile

func NewFile(source, pkg string) *File

func (File) MergeProviders

func (f File) MergeProviders() (*ProviderCollection, error)

type Identifier

type Identifier struct {
	Name string
	Type string
}

Identifier represents a dependency, including its name and type.

func DetermineIdentifier added in v2.0.2

func DetermineIdentifier(name string, typ ast.Expr) (Identifier, error)

func IdentifierFromField

func IdentifierFromField(field *ast.Field) (Identifier, error)

func (Identifier) ErrorString

func (i Identifier) ErrorString() string

func (Identifier) String

func (i Identifier) String() string

type Provider

type Provider struct {
	Identifier
	Package      string
	IsSingleton  bool
	IsComponent  bool
	Requirements []Identifier
}

Provider represents a function used to provide a dependency.

func (*Provider) WithRequirement

func (p *Provider) WithRequirement(name, kind string) *Provider

type ProviderCollection

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

func FromProviders

func FromProviders(providers []Provider) *ProviderCollection

func (*ProviderCollection) Add

func (p *ProviderCollection) Add(provider Provider)

func (*ProviderCollection) ByIdentifier

func (p *ProviderCollection) ByIdentifier(ident Identifier) Provider

func (*ProviderCollection) GetSortedIdentifiers

func (p *ProviderCollection) GetSortedIdentifiers() []Identifier

func (*ProviderCollection) Slice

func (p *ProviderCollection) Slice() []Provider

Jump to

Keyboard shortcuts

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