stat

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyFile = errors.New("empty file")

Functions

This section is empty.

Types

type Decls

type Decls struct {
	Func  int64
	Type  int64
	Const int64
	Var   int64
	Other int64
}

Decls stats about top-level declarations.

func DeclsFromAst

func DeclsFromAst(f *ast.File) Decls

func (*Decls) Add

func (s *Decls) Add(b Decls)

func (*Decls) Total

func (s *Decls) Total() int64

type Source

type Source struct {
	// Files count in this stat.
	Files int
	// Binary file count.
	Binary int
	// Size in bytes of all files.
	Size memory.Bytes
	// Count of non-empty lines.
	Lines int
	// Count of empty lines.
	Blank int
}

Source contains basic analysis of arbitrary source code.

func SourceFromBytes

func SourceFromBytes(data []byte) Source

func SourceFromPath

func SourceFromPath(path string) (Source, error)

func (*Source) Add

func (c *Source) Add(s Source)

type Stat

type Stat struct {
	PackageCount int64

	Go         Source
	OtherFiles Source

	Decls  Decls
	Tokens Tokens
}

func Package

func Package(p *packages.Package) (Stat, []error)

func (*Stat) Add

func (s *Stat) Add(b Stat)

func (*Stat) AllFiles

func (info *Stat) AllFiles() Source

type Tokens

type Tokens struct {
	Code    int64
	Comment int64
	Basic   int64
}

func TokensFromAst

func TokensFromAst(f *ast.File) Tokens

func (*Tokens) Add

func (stat *Tokens) Add(b Tokens)

Jump to

Keyboard shortcuts

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