common

package
v0.0.0-...-0137c81 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package common provides utilities to be used in multiple linter subpackages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrCollector

type ErrCollector struct {
	Errs []errors.StaticError
}

ErrCollector is a struct for accumulating warnings / errors from the linter. It is slightly more convenient and more clear than passing pointers to slices around.

func (*ErrCollector) Collect

func (ec *ErrCollector) Collect(err errors.StaticError)

Collect adds an error to the list

func (*ErrCollector) StaticErr

func (ec *ErrCollector) StaticErr(msg string, loc *ast.LocationRange)

StaticErr constructs a static error from msg and loc and adds it to the list.

type Variable

type Variable struct {
	Name         ast.Identifier
	BindNode     ast.Node
	Occurences   []ast.Node
	VariableKind VariableKind
	LocRange     ast.LocationRange
}

Variable is a representation of a variable somewhere in the code.

type VariableInfo

type VariableInfo struct {
	Variables []*Variable

	// Variable information at every use site.
	// More precisely it maps every *ast.Var to the variable.
	VarAt map[ast.Node]*Variable
}

VariableInfo holds information about a variables from one file

type VariableKind

type VariableKind int

VariableKind allows distinguishing various kinds of variables.

const (
	// VarRegular is a "normal" variable with a definition in the code.
	VarRegular VariableKind = iota
	// VarParam is a function parameter.
	VarParam
	// VarStdlib is a special `std` variable.
	VarStdlib
)

Jump to

Keyboard shortcuts

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