parsers

package
v0.0.0-...-22f12f9 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: GPL-3.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTypes

func FindTypes(v ast.Node) ast.Visitor

func GetAllSubDirs

func GetAllSubDirs(base string) (s []string)

Recursively go to all sub-directories that are not starting with . and return back an array of string with the location of the folders

func GetFlags

func GetFlags()

func GetLocalRepos

func GetLocalRepos() (s []string)

Recursively go to all sub-directories that are not starting with . and return back an array of string with the location of the folders

func InitLocalDB

func InitLocalDB()

func SetDefaults

func SetDefaults()

func SortReturnImports

func SortReturnImports(imports map[string]struct{}) (ret []string)

Types

type Application

type Application struct {
	Name       string `boltholdKey:"name"`
	BaseFolder string
	SubFolders []string

	LinesInApp    int
	UniqueImports map[string]interface{}
	AllImports    []string
	ImportCounts  map[string]int

	ChildPackages   []*PackageInfo
	ChildFiles      []*FileInfo
	ChildStructs    []*StructInfo
	ChildMethods    []*MethodInfo
	ChildInterfaces []*InterfaceInfo
	ChildFuncs      []*FuncInfo

	GraphData PkgImports
}

func FetchApp

func FetchApp(dir string) (RetApp Application)

Main function that reads the whole application

func NewApplication

func NewApplication(baseFolder string) (RetApp Application)

func (*Application) CountUniqueImports

func (a *Application) CountUniqueImports() int

func (*Application) GetUniqueImports

func (a *Application) GetUniqueImports() (uImports []string)

func (*Application) ReadApp

func (a *Application) ReadApp() (err error)

func (*Application) SortPackages

func (a *Application) SortPackages()

Sort the packages based on the line size of the package

type FileInfo

type FileInfo struct {
	Name         string
	PathAndName  string
	FileLocation string
	AstFile      *ast.File
	NumberLines  int
	Size         int

	Structs    []*StructInfo
	Methods    []*MethodInfo
	Funcs      []*FuncInfo
	Interfaces []*InterfaceInfo
	Imports    []string

	HasMainFunc   bool
	InitFuncCount int

	Lines       []string
	PackageInfo *PackageInfo
	AstPackage  *ast.Package
	Application *Application
}

func LoadFile

func LoadFile(pkgInfo *PackageInfo, f *ast.File) (file *FileInfo)

func (*FileInfo) Parse

func (f *FileInfo) Parse()

type FuncInfo

type FuncInfo struct {
	Name    string
	Content string
	//Role    ComponentType
	NumberLines int

	Application *Application
	Package     *PackageInfo
	File        *FileInfo
}

type InterfaceInfo

type InterfaceInfo struct {
	Name       string
	Content    string
	StructName string

	NumberLines int
	Application *Application
	Package     *PackageInfo
	Stuct       *StructInfo
	File        *FileInfo
}
type Links struct {
	From   int    `json:"from"`
	To     int    `json:"to"`
	Arrows string `json:"arrows"`
}

type MethodInfo

type MethodInfo struct {
	Name       string
	Content    string
	StructName string

	NumberLines int
	Application *Application
	Package     *PackageInfo
	Stuct       *StructInfo
	File        *FileInfo
}

type PackageInfo

type PackageInfo struct {
	Name           string
	FolderLocation string
	PackageRef     *ast.Package
	AstFiles       map[string]*ast.File
	ParentApp      *Application
	FileSet        *token.FileSet

	ChildImports    []string
	ChildFiles      []*FileInfo
	ChildTests      []*FileInfo
	ChildStructs    []*StructInfo
	ChildMethods    []*MethodInfo
	ChildInterfaces []*InterfaceInfo
	ChildFuncs      []*FuncInfo

	Structs       []string
	StructMethods []*PkgStructInfo `json:"package_struct_details"`
}

func ParsePackage

func ParsePackage(a *Application, fileSet *token.FileSet, folder string, pkg *ast.Package) (retPkg *PackageInfo)

Make a package - Loop over each file of the package and call LoadFile on the file

func (*PackageInfo) GetLinesInPkg

func (p *PackageInfo) GetLinesInPkg() (lns int)

func (*PackageInfo) GetUniqueImports

func (p *PackageInfo) GetUniqueImports() (uImports []string)

func (*PackageInfo) SortFiles

func (p *PackageInfo) SortFiles()

func (*PackageInfo) TrackMethod

func (p *PackageInfo) TrackMethod(info *MethodInfo)

func (*PackageInfo) UniqueImports

func (p *PackageInfo) UniqueImports() int

type PkgImports

type PkgImports struct {
	Data  []PkgNames `json:"data"`
	Links []Links    `json:"links"`
}

type PkgNames

type PkgNames struct {
	ID    int    `json:"id"`
	Value int    `json:"value"`
	Label string `json:"label"`

	CountFiles      int `json:"files_count"`
	CountFuncs      int `json:"funcs_count"`
	CountInterfaces int `json:"interface_count"`
	CountStructs    int `json:"structs_count"`
	CountMethods    int `json:"methods_count"`
	CountImports    int `json:"imports_count"`
}

type PkgStructInfo

type PkgStructInfo struct {
	StructName     string                 `json:"struct_name"`
	MethodsCount   int                    `json:"methods_count"`
	LinesInMethods int                    `json:"loc_struct_methods"`
	UniqueMethods  map[string]interface{} `json:"unique_methods"`
	MethodToLoc    map[string]int         `json:"methods_loc"`
	MethodInfo     []*MethodInfo          `json:"-"`
}

type StructInfo

type StructInfo struct {
	Name    string
	Content string
	//Role    ComponentType
	NumberLines int

	Application *Application
	Package     *PackageInfo
	File        *FileInfo

	ChildMethods []*MethodInfo
}

type VisitorFunc

type VisitorFunc func(ast.Node) ast.Visitor

func (VisitorFunc) Visit

func (f VisitorFunc) Visit(n ast.Node) ast.Visitor

Jump to

Keyboard shortcuts

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