importer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportPathFromSelector

func ImportPathFromSelector(it *ast.SelectorExpr) (path string, name string, err error)

ImportPathFromSelector gives us a path and a selector like for some pkg.SomeStruct

Types

type Importer

type Importer func(path string) (PackageInfo, error)

Importer retrieves an object representing a package

func NewImporter

func NewImporter(path string) (Importer, error)

NewImporter creates a memoizing function for importing packages

func (Importer) FindImportedTypeSpec

func (importer Importer) FindImportedTypeSpec(it *ast.SelectorExpr) (importPath, typeName string, _ *ast.TypeSpec, _ error)

FindImportedTypeSpec takes a SelectorExpr `pkg.Struct` where `pkg` refers to an import and finds the corresponding TypeSpec

func (Importer) SearchEntryPackageForObj

func (importer Importer) SearchEntryPackageForObj(typeName string) (*ast.Object, bool)

SearchEntryPackageForObj takes a name like SomeStruct and looks in the starting package

func (Importer) SearchPackageForObj

func (importer Importer) SearchPackageForObj(pkg, typeName string) (*ast.Object, bool)

SearchPackageForObj takes a name like SomeStruct and looks in the starting package

type PackageInfo

type PackageInfo struct {
	Pkg      *ast.Object
	Variants VariantMap
}

PackageInfo holds all of the information we can understand about a package

type VariantMap

type VariantMap map[string]Variants

VariantMap groups constants together under a name

type Variants

type Variants []*ast.ValueSpec

Variants is a list of values

Jump to

Keyboard shortcuts

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