code

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2022 License: BSD-3-Clause Imports: 0 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Position

type Position struct {

	//Line position in a document (zero-based).
	Line int64 `json:"line"`

	//Character offset on a line in a document (zero-based). Assuming that the line is
	//represented as a string, the `character` value represents the gap between the
	//`character` and `character + 1`.
	//If the character value is greater than the line length it defaults back to the
	//line length.
	Character int64 `json:"character"`
}

Position in a text document is a zero-based line and zero-based character offset. A position is between two characters like an ‘insert’ cursor in a editor.

func (Position) LessOrEqual

func (thisPos Position) LessOrEqual(thatPos Position) bool

LessOrEqual returns whether `thisPosition` is chronologically "before" `thatPosition`

type Range

type Range struct {
	Start Position `json:"start"`
	End   Position `json:"end"`
}

Range in a text document expressed as (zero-based) start and end positions. A range is comparable to a selection in an editor. Therefore the end position is exclusive. If you want to specify a range that contains a line including the line ending character(s) then use an end position denoting the start of the next line.

func (Range) Contains

func (thisRange Range) Contains(thatRange Range) bool

Contains checks whether `thisRange` completely overlaps `thatRange` i.e. `thatRange` = `thisRange` intersect `thatRange`

func (Range) Intersect

func (thisRange Range) Intersect(thatRange Range) Range

Intersect calculates the overlap between `thisRange` and `thatRange` and returns the overlapping range, otherwise it returns a range with -1 in all position coordinates

Jump to

Keyboard shortcuts

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