extractors

package
v0.0.0-...-1cd9283 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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
}

func (*Context) BuildPackages

func (c *Context) BuildPackages()

func (*Context) GetComments

func (c *Context) GetComments(pkg *packages.Package, node ast.Node, stack []ast.Node) []*ast.CommentGroup

func (*Context) GetLocalizeTypeToken

func (c *Context) GetLocalizeTypeToken(expr ast.Expr) TypeToken

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) SearchIdentAndToken

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

type Definition

type Definition struct {
	Type  DefinitionType
	Token TypeToken
	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

	// 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 TypeToken

type TypeToken string
const (
	TypeNone     TypeToken = ""
	TypeSingular TypeToken = "Singular"
	TypePlural   TypeToken = "Plural"
	TypeDomain   TypeToken = "Domain"
	TypeContext  TypeToken = "Context"
	TypeMessage  TypeToken = "Message"
)

Jump to

Keyboard shortcuts

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