parse

package
v0.528.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var StopOnError bool

Functions

func DirExists added in v0.504.0

func DirExists(name string) bool

func FileExists added in v0.504.0

func FileExists(name string) bool

func ListOfGoFilesInDir added in v0.202.0

func ListOfGoFilesInDir(path string) (gofiles []string, err error)

func TranslateToGreenSchema added in v0.360.0

func TranslateToGreenSchema(path string, fs *FileSet) (*green.Schema, error)

TranslateToGreenSchema takes the FileSet already in `fs`, assumes it was generated by parsing `path` (to Go source file), and returns a Greenpack specified schema; i.e. a *green.Schema. TODO: handled top-level arrays/other types besides structs. Currently we only record structs.

Types

type ComplexityThenNameSorter added in v0.509.0

type ComplexityThenNameSorter struct {
	Name    string
	Plexity int
}

type FileSet

type FileSet struct {
	Package    string              // package name
	Specs      map[string]ast.Expr // type specs in file
	Identities map[string]gen.Elem // processed from specs
	Directives []string            // raw preprocessor directives
	Imports    []*ast.ImportSpec   // imports
	Cfg        *cfg.GreenConfig

	ZebraSchemaId int64
	PackageInfo   *loader.PackageInfo
	LoadedProg    *loader.Program
	QuickPack     map[string]*loader.PackageInfo
	Fset          *token.FileSet

	InterfaceTypeNames map[string]bool // so we can heuristically identify interfaces.
}

A FileSet is the in-memory representation of a parsed file.

func File

func File(c *cfg.GreenConfig) (*FileSet, error)

File parses a file at the relative path provided and produces a new *FileSet. If you pass in a path to a directory, the entire directory will be parsed. If unexport is false, only exported identifiers are included in the FileSet. If the resulting FileSet would be empty, an error is returned.

func FileNoLoad added in v0.340.0

func FileNoLoad(c *cfg.GreenConfig) (*FileSet, error)

FileNoLoad parses a file at the relative path provided and produces a new *FileSet. If you pass in a path to a directory, the entire directory will be parsed. If unexport is false, only exported identifiers are included in the FileSet. If the resulting FileSet would be empty, an error is returned.

FileNoLoad(), in noload.go, is the original msgp version of File() that doesn't require full compilability/avialability of all dependencies. Although this doesn't support resolution of named constants like the loader version does, this can be useful when reading a partial completed source file or otherwise in a situation where it is inconvient to have to meet the compiler's demands just yet.

func (*FileSet) PrintTo

func (f *FileSet) PrintTo(p *gen.Printer) error

func (*FileSet) SaveMsgpackFile added in v0.120.0

func (fs *FileSet) SaveMsgpackFile(parsedPath, path string) error

type PlexSorterSlice added in v0.509.0

type PlexSorterSlice []*ComplexityThenNameSorter

func (PlexSorterSlice) Len added in v0.509.0

func (p PlexSorterSlice) Len() int

func (PlexSorterSlice) Less added in v0.509.0

func (p PlexSorterSlice) Less(i, j int) bool

func (PlexSorterSlice) Swap added in v0.509.0

func (p PlexSorterSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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