acn

package module
v0.0.0-...-c67744c Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: Unlicense Imports: 15 Imported by: 0

README

acn

AST code navigator

Documentation

Index

Constants

View Source
const (
	ErrGuruAmbiguous guruErr = "ambiguous selection within source file"
)
View Source
const (
	// ErrNodeNotFound is returned whenever a node was not found
	ErrNotFound acnErr = "could not find matching ast node"
)

Variables

This section is empty.

Functions

func RunGuruDescribeQuery

func RunGuruDescribeQuery(filepath string, position int, resp *GuruDescribeResponse) error

Types

type ASTFuncDeclContext

type ASTFuncDeclContext struct {
	// contains filtered or unexported fields
}

ASTFuncDeclContext is a function declaration in the ast

type Config

type Config struct {
	// Folder is the folder of the Go project
	Folder       string
	MainFileName *regexp.Regexp
	Blacklist    []*regexp.Regexp
}

Config is the Navigator config

type GoProject

type GoProject struct {
	// contains filtered or unexported fields
}

GoProject

func AnalizeGoProject

func AnalizeGoProject(rootDir string, explorePackages []string) (GoProject, error)

AnalizeGoProject analizes a go project and extract all selected packages metadata

func (*GoProject) FindFunction

func (g *GoProject) FindFunction(funcName string, funcDeclFound *ast.FuncDecl) bool

type GuruDescribeResponse

type GuruDescribeResponse struct {
	Desc   string             `json:"identifier"`
	Pos    string             `json:"pos"`
	Detail string             `json:"detail"`
	Value  *GuruDescribeValue `json:"value"`
	Type   *GuruDescribeType  `json:"type"`
}

type GuruDescribeType

type GuruDescribeType struct {
	Type    string                   `json:"type"`
	NamePos string                   `json:"namepos"`
	NameDef string                   `json:"namedef"`
	Methods []GuruDescribeTypeMethod `json:"methods"`
}

type GuruDescribeTypeMethod

type GuruDescribeTypeMethod struct {
	Name string `json:"name"`
	Pos  string `json:"pos"`
}

type GuruDescribeValue

type GuruDescribeValue struct {
	Type     string                     `json:"type"`
	ObjPos   string                     `json:"objpos"`
	Typespos []GuruDescribeValueTypePos `json:"typespos"`
}

type GuruDescribeValueTypePos

type GuruDescribeValueTypePos struct {
	ObjPos string `json:"objpos"`
	Desc   string `json:"desc"`
}
type Navigator struct {
	// contains filtered or unexported fields
}

Navigator is a stateful code navigator that will feed matching AST lines to the caller

func NewNavigator

func NewNavigator(logger *log.Logger, conf Config) Navigator

NewNavigator creates a new Navigator

func (n *Navigator) FindFunctionCallFromFunc(funcDecl *ast.FuncDecl) (*ast.CallExpr, error)

FindFunctionCallFromFunc funds a function call using a function declaration as node starting point. If funcDecl is nil, this function will assume that the main function is the starting point

func (n *Navigator) FindStructCompositeLiteral() ([]*ast.CompositeLit, error)

FindStructCompositeLiteral finds all struct values

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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