packages

package
v0.0.0-...-7c0f2aa Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommentPrefix = "+typewriter"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func NewCache

func NewCache(init ...*packages.Package) *Cache

func (*Cache) GetPackage

func (pc *Cache) GetPackage(absolutePath string) (*packages.Package, error)

GetPackage accepts absolute local path or Go module path and returns a single package. It caches by Go module path in both cases.

func (*Cache) GetType

func (pc *Cache) GetType(packagePath, name string) (*types.Named, error)

GetType returns the type information of the type in given path. The expected format is "<package path>.<type name>".

func (*Cache) GetTypeWithFullPath

func (pc *Cache) GetTypeWithFullPath(fullPath string) (*types.Named, error)

GetTypeWithFullPath returns the type information of the type in given path. The expected format is "<package path>.<type name>".

type CommentCache

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

CommentCache serves as the cache for accessing comments in packages. Indexed by package path.

func NewCommentCache

func NewCommentCache(cache *Cache) *CommentCache

func (*CommentCache) GetPackageComments

func (cc *CommentCache) GetPackageComments(pkgPath string) (Comments, error)

type CommentMarkers

type CommentMarkers struct {
	// SectionContents holds the equality pairs and indexed by the string until
	// the last ":".
	// For example, the following two lines:
	// +typewriter:types:key1=val1
	// +typewriter:types:key2=val2
	// would be indexed as following:
	// {
	//    "types": {"key1":"val1", "key2":"val2"}
	// }
	SectionContents map[string]map[string]string

	// Comment is the original comment string.
	Comment string
}

func NewCommentMarkers

func NewCommentMarkers(c string) CommentMarkers

func NewCommentMarkersFromText

func NewCommentMarkersFromText(c string, prefix string) CommentMarkers

func (CommentMarkers) Print

func (ct CommentMarkers) Print(prefix string) string

type Comments

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

Comments lets you fetch comment of an object.

func LoadComments

func LoadComments(p *packages.Package) Comments

func (Comments) CommentOf

func (c Comments) CommentOf(o types.Object) string

type Imports

type Imports struct {
	PackagePath string
	PackageName string
	Imports     map[string]string
}

func NewImports

func NewImports(pkgPath, pkgName string) *Imports

func (*Imports) UsePackage

func (m *Imports) UsePackage(pkgPath string) string

UsePackage adds the package to the import map and returns the alias you can use in that Go file. The returned package name will have "." as suffix if it is from a different package than the current one.

func (*Imports) UseType

func (m *Imports) UseType(in string) string

UseType adds the package of given type to the import map and returns the alias you can use in that Go file.

Jump to

Keyboard shortcuts

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