parser

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: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignableTo

func AssignableTo(t1, t2 Type) bool

func Identical

func Identical(t1, t2 Type) bool

func IsEmpty

func IsEmpty(typ Type) bool

func QualifiedTypeName

func QualifiedTypeName(t Type) string

QualifiedTypeName returns a string like: 'github_com_owner_repo_pkg.TypeName' see: https://go.dev/ref/spec#Qualified_identifiers

func TypeNamePrefixedByImportPath

func TypeNamePrefixedByImportPath(t Type) string

TypeNamePrefixedByImportPath returns a string like: 'github_com_owner_repo_pkg.TypeName'

Types

type Func

type Func struct {
	*Object
}

func (*Func) Exported

func (f *Func) Exported() bool

func (*Func) IsBindable

func (f *Func) IsBindable() bool

func (*Func) IsConstructor

func (f *Func) IsConstructor() bool

func (*Func) MustBeResolved

func (f *Func) MustBeResolved() bool

MustBeResolved returns true if the object has `provider:must_resolve` comment.

func (*Func) Params

func (f *Func) Params() *types.Tuple

func (*Func) Results

func (f *Func) Results() *types.Tuple

func (*Func) ShouldTryToResolve

func (f *Func) ShouldTryToResolve() bool

type Iface

type Iface struct {
	*Object
}

Iface is a wrapper of types.Interface.

func (*Iface) Interface

func (i *Iface) Interface() *types.Interface

Interface returns the underlying types.Interface.

type Object

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

A Object is a wrapper of types.Object.

func (*Object) Comment

func (o *Object) Comment() string

Comment returns the comment of the object.

func (*Object) Exported

func (o *Object) Exported() bool

Exported returns true if the object is exported.

func (*Object) FullImportPath

func (o *Object) FullImportPath() string

FullImportPath returns a string like: 'github_com_owner_repo_pkg "github.com/owner/repo/pkg"'

func (*Object) FullPkg

func (o *Object) FullPkg() string

FullPkg returns a string like: 'github_com_owner_repo_pkg' This string generated from o.ImportPath() by replacing '.', '/', '-' to '_'.

func (*Object) Func

func (o *Object) Func() (*Func, bool)

Func returns the underlying Func.

func (*Object) ImportPath

func (o *Object) ImportPath() string

ImportPath returns the import path of the object.

func (*Object) Interface

func (o *Object) Interface() (*Iface, bool)

Interface returns the underlying Interface.

func (*Object) IsExcluded

func (o *Object) IsExcluded() bool

IsExcluded returns true if the object has `provider:exclude` comment.

func (*Object) IsMarkedAsBindable

func (o *Object) IsMarkedAsBindable() bool

func (*Object) IsResolve

func (o *Object) IsResolve() bool

func (*Object) Name

func (o *Object) Name() string

Name returns the name of the object.

func (*Object) Pkg

func (o *Object) Pkg() string

Pkg returns the package name of the object.

func (*Object) ResolvedPkgAndFuncName

func (o *Object) ResolvedPkgAndFuncName() (string, string, error)

Resolve returns the package path and the function name to be resolved. The format of the comment must be `provider:resolve path/to/package FuncName` or `provider:resolve FuncName`. If the object has no `provider:resolve` comment, this function returns false.

func (*Object) String

func (o *Object) String() string

String returns a string like: 'github_com_owner_repo_pkg.ObjectName'

func (*Object) Struct

func (o *Object) Struct() (*Struct, bool)

Struct returns the underlying Struct.

func (*Object) Type

func (o *Object) Type() types.Type

Type returns the underlying type.

type ObjectCache

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

func Parse

func Parse(ctx context.Context, dir string, env, globs, ignores []string) (*ObjectCache, []error)

Parse is a wrapper of packages.Load.

func (*ObjectCache) Add

func (c *ObjectCache) Add(obj *Object)

func (*ObjectCache) All

func (c *ObjectCache) All() []*Object

func (*ObjectCache) Funcs

func (c *ObjectCache) Funcs() []*Func

func (*ObjectCache) Get

func (c *ObjectCache) Get(pkg, name string) (*Object, bool)

func (*ObjectCache) Ifaces

func (c *ObjectCache) Ifaces() []*Iface

func (*ObjectCache) Implementations

func (c *ObjectCache) Implementations(iface *Iface) []Type

type Struct

type Struct struct {
	*Object
}

func (*Struct) Type

func (s *Struct) Type() *types.Struct

type Type

type Type types.Type

Jump to

Keyboard shortcuts

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