parser

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package parser parses the cover profiles into statements.

Ref: https://github.com/axw/gocov

Index

Constants

View Source
const (
	Original State = "Original"
	Changed  State = "Changed"

	Keep   Mode = "Keep"
	Ignore Mode = "Ignore"
)

Variables

This section is empty.

Functions

func InFolder

func InFolder(parentDir, filepath string) bool

InFolder check whether specified filepath is a part of parent path.

Types

type FuncExtent

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

FuncExtent describes a function's extent in the source by file and position.

type FuncVisitor

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

FuncVisitor implements the visitor that builds the function position list for a file.

func (*FuncVisitor) Visit

func (v *FuncVisitor) Visit(node ast.Node) ast.Visitor

Visit implements the ast.Visitor interface.

type Function

type Function struct {
	// Name is the name of the function. If the function has a receiver, the
	// name will be of the form T.N, where T is the type and N is the name.
	Name string

	// File is the full path to the file in which the function is defined.
	File string

	// Start is the start offset of the function's signature.
	Start int

	// End is the end offset of the function.
	End int

	// StartLine is the start line number of the function.
	StartLine int

	// EndLine is the end line number of the function.
	EndLine int

	// statements registered with this function.
	Statements []*Statement
}

func (*Function) Accumulate

func (f *Function) Accumulate(f2 *Function) error

Accumulate will accumulate the coverage information from the provided Function into this Function.

type Mode

type Mode string

Mode represents statement's mode. "Keep" means it will be used in coverage calculation "Ignore" means it won't be used in coverage calculation

type Package

type Package struct {
	// Name is the canonical path of the package.
	Name string

	// Functions is a list of functions registered with this package.
	Functions []*Function

	// IgnoreProfiles is a list of ignore profiles that within this package.
	IgnoreProfiles []*annotation.IgnoreProfile
}

func (*Package) Accumulate

func (p *Package) Accumulate(p2 *Package) error

Accumulate will accumulate the coverage information from the provided Package into this Package.

type Packages

type Packages []*Package

Packages represents a set of Package structures. The "AddPackage" method may be used to merge package coverage results into the set.

func ReadPackages

func ReadPackages(filenames []string) (ps Packages, err error)

ReadPackages takes a list of filenames and parses their contents as a Packages object.

The special filename "-" may be used to indicate standard input. Duplicate filenames are ignored.

func (*Packages) AddPackage

func (ps *Packages) AddPackage(p *Package)

AddPackage adds a package's coverage information to the

type Parser

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

Parser wrapper for parsing

func NewParser

func NewParser(
	coverProfileFiles []string,
	logger logrus.FieldLogger,
) *Parser

func (*Parser) Parse

func (parser *Parser) Parse(changes []*gittool.Change) (Packages, error)

Parse parses cover profiles into statements, and modify their state based on git changes.

type State

type State string

State represents statement's state. "Original" means it hasn't changed compared with compare branch (master or main) "Changed" means it has been changed compared with compare branch (master or main)

type Statement

type Statement struct {
	// Start is the start offset of the statement.
	Start int

	// End is the end offset of the statement.
	End int

	// StartLine is the start line number of the statement.
	StartLine int

	// EndLine is the end line number of the statement.
	EndLine int

	// Reached is the number of times the statement was reached.
	Reached int64

	// State indicates whether current statement is changed or not.
	State State

	// Mode indicates whether current statement counts for coverage.
	Mode Mode
}

func (*Statement) Accumulate

func (s *Statement) Accumulate(s2 *Statement) error

Accumulate will accumulate the coverage information from the provided Statement into this Statement.

type StmtExtent

type StmtExtent extent

StmtExtent describes a statements's extent in the source by file and position.

type StmtVisitor

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

func (*StmtVisitor) VisitStmt

func (v *StmtVisitor) VisitStmt(s ast.Stmt)

Jump to

Keyboard shortcuts

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