ast

package
v0.0.0-...-6c5040b Latest Latest
Warning

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

Go to latest
Published: May 10, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ast ... TODO package overview docs

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGoPathUndefined       = fmt.Errorf("%s $GOPATH is undefined", errorPrefix)
	ErrNonExistantSearchPath = func(path string) error {
		return fmt.Errorf("%s Search path '%s' does not exist", errorPrefix, path)
	}
	ErrNonExistantJSONStruct = func(importPath string, structName string) error {
		return fmt.Errorf("%s Could not find JSON struct spec for %s.%s{}", errorPrefix, importPath, structName)
	}
)

Functions

This section is empty.

Types

type FileSystemWalker

type FileSystemWalker interface {
	Walk(string, filepath.WalkFunc) error
}

type WalkFunc func(path string, info os.FileInfo, err error) error

type JSONStructFinder

type JSONStructFinder struct {
	// FileSystemWalker implements a Walk method which recursively traverses
	// directories looking for structs
	FileSystemWalker
	// WalkFunc is the callback which is passed every file discovered by the
	// FileSystemWalker
	filepath.WalkFunc

	*token.FileSet
	// contains filtered or unexported fields
}

JSONStructFinder recursively scans all directories starting at RootDir looking for go files and then traversing their AST in search of structs with json tags eligible for generating json encoders

func NewJSONStructFinder

func NewJSONStructFinder() *JSONStructFinder

func (*JSONStructFinder) FindInAST

func (s *JSONStructFinder) FindInAST(fileNode *ast.File) []StructTypeSpec

func (*JSONStructFinder) FindInDir

func (s *JSONStructFinder) FindInDir(rootDir string) error

func (*JSONStructFinder) StructDirectories

func (s *JSONStructFinder) StructDirectories() []StructDirectory

func (*JSONStructFinder) StructTypeSpecs

func (s *JSONStructFinder) StructTypeSpecs() []StructTypeSpec

type StructDirectory

type StructDirectory struct {
	ProjectRoot string
	PackageRoot string
	Package     string
	Directory   string
	ImportPath  string
	Specs       []StructTypeSpec
}

type StructTypeSpec

type StructTypeSpec struct {
	PackageName string
	Directory   string
	*ast.TypeSpec
}

func FindJSONStructFor

func FindJSONStructFor(importPath string, name string) (*StructTypeSpec, error)

func (*StructTypeSpec) Name

func (s *StructTypeSpec) Name() string

Jump to

Keyboard shortcuts

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