Documentation ¶
Overview ¶
Package ann defines types that represent source code annotations.
Index ¶
Constants ¶
View Source
const ( // Link is a type of annotation that refers to an arbitrary URL // (typically pointing to an external web page). Link = "link" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ann ¶
type Ann struct { // Repo is the URI of the repository that contains this annotation. Repo string `json:",omitempty"` // CommitID refers to the commit that contains this annotation. CommitID string `db:"commit_id" json:",omitempty"` // UnitType is the source unit type that the annotation exists // on. It is either the source unit type during whose processing // the annotation was detected/created. Multiple annotations may // exist on the same file from different source unit types if a // file is contained in multiple source units. UnitType string `db:"unit_type" json:",omitempty"` // Unit is the source unit name that the annotation exists on. See // UnitType for more information. Unit string `json:",omitempty"` // Type is the type of the annotation. See this package's type // constants for a list of possible types. Type string // File is the filename that contains this annotation. File string // Start is the byte offset of the first byte in the file. Start int // End is the byte offset of the last byte in the annotation. End int `json:",omitempty"` // Data contains arbitrary JSON data that is specific to this // annotation type (e.g., the link URL for Link annotations). Data sqltypes.JSON `json:",omitempty"` }
An Ann is a source code annotation.
Annotations are unique on (Repo, CommitID, UnitType, Unit, File, Start, End, Type).
func (*Ann) LinkURL ¶
LinkURL parses and returns a's link URL, if a's type is Link and if its Data contains a valid URL (encoded as a JSON string).
func (*Ann) SetLinkURL ¶
SetLinkURL sets a's Type to Link and Data to the JSON representation of the URL string. If the URL is invalid, an error is returned.
type ErrType ¶
type ErrType struct {
Expected, Actual string // Expected and actual types
Op string // The name of the operation or method that was called
}
ErrType indicates that an operation performed on an annotation expected the annotation to be a different type (e.g., calling LinkURL on a non-link annotation).
Click to show internal directories.
Click to hide internal directories.