walkers

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(config *linter.Config, globalCtx *GlobalContext, pal *palette.Palette, colorTag string)

Register registers custom walkers to collect information about functions.

Types

type BlockChecker

type BlockChecker struct {
	linter.BlockCheckerDefaults
	// contains filtered or unexported fields
}

BlockChecker is a walker that handles function calls, method calls, class creation, and file imports in block context (inside functions).

func NewBlockChecker

func NewBlockChecker(ctx *linter.BlockContext, root *RootChecker) *BlockChecker

NewBlockChecker creates a new BlockChecker walker.

func (*BlockChecker) BeforeEnterNode

func (b *BlockChecker) BeforeEnterNode(n ir.Node)

BeforeEnterNode is the main method for processing AST nodes.

func (*BlockChecker) EnterNode

func (b *BlockChecker) EnterNode(n ir.Node) bool

EnterNode is method to use BlockChecker in the Walk method of AST nodes.

func (*BlockChecker) LeaveNode

func (b *BlockChecker) LeaveNode(n ir.Node)

LeaveNode is method to use BlockChecker in the Walk method of AST nodes.

type BlockIndexer

type BlockIndexer struct {
	linter.BlockCheckerDefaults
}

BlockIndexer is a dummy walker.

type FileMeta

type FileMeta struct {
	Functions *symbols.Functions
}

FileMeta describes the data to be cached.

func NewFileMeta

func NewFileMeta() FileMeta

NewFileMeta returns a new FileMeta instance with pre-allocated fields.

type GlobalContext

type GlobalContext struct {
	Info *meta.Info

	Functions *symbols.Functions
}

GlobalContext is a structure for storing cache.

func NewGlobalContext

func NewGlobalContext(info *meta.Info) *GlobalContext

NewGlobalContext creates a new context.

func (*GlobalContext) Decode

func (ctx *GlobalContext) Decode(r io.Reader, filename string) error

Decode recovers data from cache.

func (*GlobalContext) Encode

func (ctx *GlobalContext) Encode(writer io.Writer, checker linter.RootChecker) error

Encode caches the data of one rootWalker of one file.

func (*GlobalContext) UpdateMeta

func (ctx *GlobalContext) UpdateMeta(f *FileMeta, filename string)

UpdateMeta recovers data by collecting it from each file.

func (*GlobalContext) Version

func (ctx *GlobalContext) Version() string

Version returns the current version of the cache.

type RootChecker

type RootChecker struct {
	linter.RootCheckerDefaults
	// contains filtered or unexported fields
}

RootChecker is a walker that collects information about the colors of functions and checks them for correctness.

func NewRootChecker

func NewRootChecker(palette *palette.Palette, globalCtx *GlobalContext, ctx *linter.RootContext, colorTag string) *RootChecker

NewRootChecker returns a new walker.

func (*RootChecker) AfterEnterNode

func (r *RootChecker) AfterEnterNode(n ir.Node)

AfterEnterNode

func (*RootChecker) BeforeEnterFile

func (r *RootChecker) BeforeEnterFile()

BeforeEnterFile sets the current function of the file.

func (*RootChecker) BeforeEnterNode

func (r *RootChecker) BeforeEnterNode(n ir.Node)

BeforeEnterNode

func (*RootChecker) EnterNode

func (r *RootChecker) EnterNode(n ir.Node) bool

EnterNode is method to use RootChecker in the Walk method of AST nodes.

func (*RootChecker) LeaveNode

func (r *RootChecker) LeaveNode(ir.Node)

LeaveNode is method to use RootChecker in the Walk method of AST nodes.

type RootIndexer

type RootIndexer struct {
	linter.RootCheckerDefaults
	// contains filtered or unexported fields
}

RootIndexer is a walker that collects information about function definitions, as well as about the files where they are defined.

func NewRootIndexer

func NewRootIndexer(globalCtx *GlobalContext, ctx *linter.RootContext) *RootIndexer

NewRootIndexer creates a new walker.

func (*RootIndexer) AfterLeaveFile

func (r *RootIndexer) AfterLeaveFile()

AfterLeaveFile updates the cache.

func (*RootIndexer) BeforeEnterFile

func (r *RootIndexer) BeforeEnterFile()

BeforeEnterFile processes all files, creating a new function for each with an autogenerated name.

func (*RootIndexer) BeforeEnterNode

func (r *RootIndexer) BeforeEnterNode(n ir.Node)

BeforeEnterNode collects information about functions and methods.

Jump to

Keyboard shortcuts

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