Documentation ¶
Overview ¶
Package span implements utilities to resolve byte offsets within a file to line and column numbers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Normalizer ¶
type Normalizer struct {
// contains filtered or unexported fields
}
Normalizer fixes xref.Locations within a given source text so that each point has consistent byte_offset, line_number, and column_offset fields within the range of text's length and its line lengths.
func NewNormalizer ¶
func NewNormalizer(text []byte) *Normalizer
NewNormalizer returns a Normalizer for Locations within text.
func (*Normalizer) ByteOffset ¶
func (n *Normalizer) ByteOffset(offset int32) *cpb.Point
ByteOffset returns a normalized point based on the given offset within the Normalizer's text. A normalized point has all of its fields set consistently and clamped within the range [0,len(text)).
func (*Normalizer) Location ¶
Location returns a normalized location within the Normalizer's text. Normalized FILE locations have no start/end points. Normalized SPAN locations have fully populated start/end points clamped in the range [0, len(text)).
func (*Normalizer) Point ¶
func (n *Normalizer) Point(p *cpb.Point) *cpb.Point
Point returns a normalized point within the Normalizer's text. A normalized point has all of its fields set consistently and clamped within the range [0,len(text)).
func (*Normalizer) Span ¶
func (n *Normalizer) Span(s *cpb.Span) *cpb.Span
Span returns a Span with its start and end normalized.
func (*Normalizer) SpanOffsets ¶
func (n *Normalizer) SpanOffsets(start, end int32) *cpb.Span
SpanOffsets returns a Span based on normalized start and end byte offsets.
type Patcher ¶
type Patcher struct {
// contains filtered or unexported fields
}
Patcher uses a computed diff between two texts to map spans from the original text to the new text.
func NewPatcher ¶
NewPatcher returns a Patcher based on the diff between oldText and newText.