Documentation
¶
Overview ¶
package model provides *core* representations for different code structures. There should have no dependencies other than stdlib, so users of this package can freely import this without extra worry. This package should remain as minimal and substantial as possible.
Index ¶
- Variables
- func SortIBlocks(blocks interface{})
- type AnnotationType
- type Block
- type BlockAnnotation
- type BlockAnnotationMapping
- type BlockID
- type CodeAnnotation
- type CodeComment
- type CodeSuggestion
- type Comment
- type CommentLabel
- type ExcludeReason
- type FileAnnotation
- type FileAnnotationMapping
- type FuncAnnotation
- type FuncAnnotationMapping
- type FuncID
- type FuncInfoMapping
- type IBlockData
- type LineAnnotation
- type LineAnnotationMapping
- type LineNum
- type ProjectAnnotation
- func (c *ProjectAnnotation) Clone() *ProjectAnnotation
- func (c *ProjectAnnotation) Has(annotationType AnnotationType) bool
- func (c *ProjectAnnotation) MustHave(reason string, annotationTypes ...AnnotationType)
- func (c *ProjectAnnotation) Set(annotationType AnnotationType)
- func (c *ProjectAnnotation) ShouldHave(reason string, annotationTypes ...AnnotationType) error
- func (c *ProjectAnnotation) Simplified() *ProjectAnnotation
- func (c *ProjectAnnotation) Simplify()
- type RelativeFile
- type RemapRequest
- type RemapResponse
- type Remark
- type StringSet
Constants ¶
This section is empty.
Variables ¶
View Source
var MergeAnnotationsInto func(res *ProjectAnnotation, annotations ...*ProjectAnnotation)
clone impl
Functions ¶
Types ¶
type AnnotationType ¶
type AnnotationType string
const ( AnnotationType_Blocks AnnotationType = "blocks" // the File.Blocks AnnotationType_ChangeDetail AnnotationType = "change_detail" // the File.ChangeDetail // lines AnnotationType_LineEmpty AnnotationType = "line_empty" // the Line.Empty AnnotationType_LineBlockID AnnotationType = "line_block_id" // the Line.BlockID AnnotationType_LineFuncID AnnotationType = "line_func_id" // the Line.BlockID AnnotationType_LineChanges AnnotationType = "line_changes" // the Line.LineChanges AnnotationType_LineChanged AnnotationType = "line_changed" // the Line.Changed AnnotationType_LineOldLine AnnotationType = "line_old_line" // the Line.OldLine AnnotationType_LineLabels AnnotationType = "line_labels" // the Line.Labels AnnotationType_LineExecLabels AnnotationType = "line_exec_labels" // the Line.ExecLabels AnnotationType_LineCoverageLabels AnnotationType = "line_coverage_labels" // the Line.CoverageLabels AnnotationType_LineUncoverable AnnotationType = "line_uncoverable" // the Line.Uncoverable AnnotationType_LineCodeExcluded AnnotationType = "line_code_excluded" // the Line.Code.Excluded AnnotationType_LineRemark AnnotationType = "line_remark" // the Line.Remark // funcs AnnotationType_FileFuncs AnnotationType = "funcs" // the File.Funcs AnnotationType_FuncLabels AnnotationType = "func_labels" // the Line.ExecLabels AnnotationType_FuncExecLabels AnnotationType = "func_exec_labels" // the Line.ExecLabels AnnotationType_FuncCoverageLabels AnnotationType = "func_coverage_labels" // the Func.CoverageLabels AnnotationType_FuncChanged AnnotationType = "func_changed" // the Func.Changed AnnotationType_FuncCodeComments AnnotationType = "func_code_comments" // the Func.Code.Comments // Func.Code.Excluded is the exclude-flag by comment, there are some other // flags that can indicate whether a func is excluded: // func excluded = headLineExcluded || allLineExcluded || excludedByComment AnnotationType_FuncCodeExcluded AnnotationType = "func_code_excluded" // the Func.Code.Excluded // first line excluded AnnotationType_FirstLineExcluded AnnotationType = "func_first_line_excluded" )
type Block ¶
type Block struct { StartLine int `json:"startLine"` StartCol int `json:"startCol"` EndLine int `json:"endLine"` EndCol int `json:"endCol"` }
Block can be used as a unique key across one file
type BlockAnnotation ¶
type BlockAnnotation struct { Block *Block `json:"block,omitempty"` FuncID FuncID `json:"funcID,omitempty"` // ExecLabels is the set of labels collected by runtime execution ExecLabels StringSet `json:"execLabels,omitempty"` BlockDataType string `json:"blockDataType,omitempty"` BlockData interface{} `json:"blockData,omitempty"` // extra block data }
func (*BlockAnnotation) Simplify ¶
func (c *BlockAnnotation) Simplify()
type BlockAnnotationMapping ¶
type BlockAnnotationMapping map[BlockID]*BlockAnnotation
type CodeAnnotation ¶
type CodeAnnotation struct { // Labels StringSet `json:"labels,omitempty"` // ExecLabels StringSet `json:"execLabels,omitempty"` Comments map[CommentLabel]*CodeComment `json:"comments,omitempty"` // example: {labels: ["a","b","c"], "unreachable":true} Excluded bool `json:"excluded,omitempty"` }
type CodeComment ¶
type CodeComment struct { Author string `json:"author,omitempty"` Values []string `json:"values,omitempty"` }
func (*CodeComment) Clone ¶
func (c *CodeComment) Clone() *CodeComment
type CodeSuggestion ¶
type CodeSuggestion string
const (
Suggestion_Other CodeSuggestion = "other"
)
type CommentLabel ¶
type CommentLabel string
const ( CommentLabels_Labels CommentLabel = "labels" CommentLabels_Unreachable CommentLabel = "unreachable" CommentLabels_NoCov CommentLabel = "nocov" CommentLabels_Deprecated CommentLabel = "deprecated" )
type ExcludeReason ¶
type ExcludeReason string
const (
ExcludeReason_Other ExcludeReason = "other"
)
type FileAnnotation ¶
type FileAnnotation struct { ChangeDetail *git.FileDetail `json:"changeDetail,omitempty"` Lines LineAnnotationMapping `json:"lines,omitempty"` // 1-based mapping LineChanges *model.LineChanges `json:"lineChanges,omitempty"` // optional DeletedLines map[int64]bool `json:"deletedLines,omitempty"` Blocks BlockAnnotationMapping `json:"blocks,omitempty"` Funcs FuncAnnotationMapping `json:"funcs,omitempty"` // by func id FileDataType string `json:"fileDataType,omitempty"` FileData interface{} `json:"fileData,omitempty"` // extra file data }
func (*FileAnnotation) Simplify ¶
func (c *FileAnnotation) Simplify()
type FileAnnotationMapping ¶
type FileAnnotationMapping map[RelativeFile]*FileAnnotation
type FuncAnnotation ¶
type FuncAnnotation struct { Block *Block `json:"block,omitempty"` Name string `json:"name,omitempty"` OwnerTypeName string `json:"ownerTypeName,omitempty"` Closure bool `json:"closure"` // a closure, without name Changed bool `json:"changed"` // derived from line changed Ptr bool `json:"ptr,omitempty"` // Labels inerited from lines Labels StringSet `json:"labels,omitempty"` // ExecLabels inherited from lines ExecLabels StringSet `json:"execLabels,omitempty"` CoverageLabels map[string]bool `json:"coverageLabels,omitempty"` Code *CodeAnnotation `json:"code,omitempty"` FirstLineExcluded bool `json:"firstLineExcluded,omitempty"` }
func (*FuncAnnotation) Simplify ¶
func (c *FuncAnnotation) Simplify()
type FuncAnnotationMapping ¶
type FuncAnnotationMapping map[FuncID]*FuncAnnotation
type FuncID ¶
type FuncID = BlockID
FuncID and BlockID are globally unique within a file and a commit
type FuncInfoMapping ¶ added in v0.0.4
type FuncInfoMapping map[RelativeFile][]*FuncAnnotation
type IBlockData ¶
type IBlockData interface {
GetBlock() *Block
}
type LineAnnotation ¶
type LineAnnotation struct { OldLine int64 `json:"oldLine,omitempty"` // if 0 or undefined, no oldLine. only effective when not changed Changed bool `json:"changed,omitempty"` // is this line changed BlockID BlockID `json:"blockID,omitempty"` // related blockID, can not be zero Empty bool `json:"empty,omitempty"` // is this an empty line // Labels tells what code sets this line matches // a map to make merge easier Labels StringSet `json:"labels,omitempty"` // ExecLabels is the set of labels collected by runtime execution ExecLabels StringSet `json:"execLabels,omitempty"` // CoverageLabels true->has cover, false->has no cover // examples: ALL:true, RC:true|false // NOTE: it's not a StringSet, its just a map derived from Labels & ExecLabels and other options CoverageLabels map[string]bool `json:"coverageLabels,omitempty"` FuncID FuncID `json:"funcID,omitempty"` // Uncoverable empty or non-block or just a simple "}", or it has been marked unreachable Uncoverable bool `json:"uncoverable,omitempty"` Code *CodeAnnotation `json:"code,omitempty"` Remark *Remark `json:"remark,omitempty"` LineDataType string `json:"lineDataType,omitempty"` LineData interface{} `json:"lineData,omitempty"` // extra line data }
func (*LineAnnotation) Simplify ¶
func (c *LineAnnotation) Simplify()
type LineAnnotationMapping ¶
type LineAnnotationMapping map[LineNum]*LineAnnotation
type ProjectAnnotation ¶
type ProjectAnnotation struct { // short file -> annotations Files FileAnnotationMapping `json:"files,omitempty"` Types map[AnnotationType]bool `json:"types,omitempty"` // types indicator CommitHash string `json:"commitHash,omitempty"` ProjectDataType string `json:"projectDataType,omitempty"` ProjectData interface{} `json:"projectData,omitempty"` // extra project data }
func (*ProjectAnnotation) Clone ¶
func (c *ProjectAnnotation) Clone() *ProjectAnnotation
func (*ProjectAnnotation) Has ¶
func (c *ProjectAnnotation) Has(annotationType AnnotationType) bool
func (*ProjectAnnotation) MustHave ¶
func (c *ProjectAnnotation) MustHave(reason string, annotationTypes ...AnnotationType)
func (*ProjectAnnotation) Set ¶
func (c *ProjectAnnotation) Set(annotationType AnnotationType)
func (*ProjectAnnotation) ShouldHave ¶ added in v0.0.2
func (c *ProjectAnnotation) ShouldHave(reason string, annotationTypes ...AnnotationType) error
func (*ProjectAnnotation) Simplified ¶
func (c *ProjectAnnotation) Simplified() *ProjectAnnotation
func (*ProjectAnnotation) Simplify ¶
func (c *ProjectAnnotation) Simplify()
type RelativeFile ¶
type RelativeFile string
type RemapRequest ¶
type RemapResponse ¶
type RemapResponse struct {
Annotation *ProjectAnnotation `json:"annotation"`
}
type Remark ¶
type Remark struct { Excluded bool `json:"excluded,omitempty"` Reason ExcludeReason `json:"reason,omitempty"` Suggestion CodeSuggestion `json:"suggestion,omitempty"` Comments []*Comment `json:"comments,omitempty"` CreateTime string `json:"createTime,omitempty"` Creator string `json:"creator,omitempty"` UpdateTime string `json:"updateTime,omitempty"` Updater string `json:"updater,omitempty"` }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.