gnofmt

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadWalkPackage

func ReadWalkPackage(pkg Package, fn PackageReadWalkFunc) error

Types

type FSResolver

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

func NewFSResolver

func NewFSResolver() *FSResolver

func (*FSResolver) LoadPackages

func (r *FSResolver) LoadPackages(root string, pkgHandler PackageHandler) error

LoadPackages lists all packages in the directory (excluding those which can't be processed).

func (*FSResolver) ResolveName

func (r *FSResolver) ResolveName(pkgname string) []Package

func (*FSResolver) ResolvePath

func (r *FSResolver) ResolvePath(pkgpath string) Package

type Package

type Package interface {
	// Should return the package path
	Path() string
	// Should return the name of the package as defined at the top level of each file
	Name() string
	// Should return all gno filenames inside the package
	Files() []string
	// Should return a content reader for the given filename within the package
	Read(filename string) (io.ReadCloser, error)
}

func ParsePackage

func ParsePackage(fset *token.FileSet, root string, dir string) (Package, error)

ParsePackage parses package from the given directory. It will return a nil package if no gno files are found. If a gno.mod is found, it will be used to determine the pkg path. If root is specified, it will be trimmed from the actual given dir to create the pkgpath if no gno.mod is found.

type PackageHandler

type PackageHandler func(path string, err error) error

PackageHandler is a callback passed to the resolver during package loading. PackageHandler will be called on each package. If no error is passed, that means that the package has been fully loaded. If any handled error is returned from the handler, the package process will immediately stop.

type PackageReadWalkFunc

type PackageReadWalkFunc func(filename string, r io.Reader, err error) error

type Processor

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

func NewProcessor

func NewProcessor(r Resolver) *Processor

func (*Processor) FormatFile

func (p *Processor) FormatFile(file string) ([]byte, error)

FormatFile processes a single Gno file from the given file path.

func (*Processor) FormatImportFromSource

func (p *Processor) FormatImportFromSource(filename string, src any) ([]byte, error)

FormatImportFromSource parse and format the source from src. The type of the argument for the src parameter must be string, []byte, or io.Reader.

func (*Processor) FormatPackageFile

func (p *Processor) FormatPackageFile(pkg Package, filename string) ([]byte, error)

FormatFile processes a single Gno file from the given Package and filename.

type Resolver

type Resolver interface {
	// ResolveName should resolve the given package name by returning a list
	// of packages matching the given name
	ResolveName(pkgname string) []Package
	// ResolvePath should resolve the given package path by returning a
	// single package
	ResolvePath(pkgpath string) Package
}

Jump to

Keyboard shortcuts

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