extractors

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractStringLiteral added in v0.6.0

func ExtractStringLiteral(expr ast.Expr) (string, ast.Node)

Types

type Context

type Context struct {
	Config *config.Config
	Log    *log.Entry

	OriginalPackages []*packages.Package

	Packages    map[string]*packages.Package
	Inspector   *inspector.Inspector
	CommentMaps map[string]map[string]ast.CommentMap // pkg -> file -> node -> comments

	Definitions Definitions

	Templates []*tmpl.Template
}

func (*Context) BuildPackages

func (c *Context) BuildPackages()

func (*Context) GetComments

func (c *Context) GetComments(pkg *packages.Package, nodes ...ast.Node) []string

GetComments extracts the Go comments for a list of nodes.

func (*Context) GetLocalizeTypeToken

func (c *Context) GetLocalizeTypeToken(expr ast.Expr) etype.Token

func (*Context) GetPosition

func (c *Context) GetPosition(pos token.Pos) token.Position

func (*Context) GetType

func (c *Context) GetType(ident *ast.Ident) (*packages.Package, types.Object)

func (*Context) SearchIdent added in v0.3.0

func (c *Context) SearchIdent(start ast.Node) *ast.Ident

func (*Context) SearchIdentAndToken

func (c *Context) SearchIdentAndToken(start ast.Node) (etype.Token, *ast.Ident)

func (*Context) SearchStrings added in v0.6.0

func (c *Context) SearchStrings(startExpr ast.Expr) []*SearchResult

type Definition

type Definition struct {
	Type  DefinitionType
	Token etype.Token
	Pck   *packages.Package
	Ident *ast.Ident
	Path  string // github.com/name/repo/package/pack
	ID    string // github.com/name/repo/package/pack.StructName
	Obj   types.Object

	// only for functions and structs
	FieldIdent *ast.Ident
	FieldName  string
	IsVariadic bool

	// functions only
	FieldPos int
}

func (*Definition) Key

func (d *Definition) Key() string

type DefinitionType

type DefinitionType int
const (
	VarSingular DefinitionType = iota
	Array
	FunctionReturn
	FunctionParam
	StructField
)

type Definitions

type Definitions map[string]map[string]*Definition // path.name -> field || "" -> Definition

func (Definitions) Get

func (defs Definitions) Get(key, fieldName string) *Definition

func (Definitions) GetFields

func (defs Definitions) GetFields(key string) map[string]*Definition

type Extractor

type Extractor interface {
	Run(ctx context.Context, extractCtx *Context) ([]result.Issue, error)
	Name() string
}

type SearchResult added in v0.6.0

type SearchResult struct {
	Raw  string
	Node ast.Node
}

Jump to

Keyboard shortcuts

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