type Mapper … // NewMapper creates a new mapper for the given URI and content. func NewMapper(uri DocumentURI, content []byte) *Mapper { … } // initLines populates the lineStart table. func (m *Mapper) initLines() { … } // LineCol8Position converts a valid line and UTF-8 column number, // both 1-based, to a protocol (UTF-16) position. func (m *Mapper) LineCol8Position(line, col8 int) (Position, error) { … } // OffsetLocation converts a byte-offset interval to a protocol (UTF-16) location. func (m *Mapper) OffsetLocation(start, end int) (Location, error) { … } // OffsetRange converts a byte-offset interval to a protocol (UTF-16) range. func (m *Mapper) OffsetRange(start, end int) (Range, error) { … } // OffsetPosition converts a byte offset to a protocol (UTF-16) position. func (m *Mapper) OffsetPosition(offset int) (Position, error) { … } // lineCol16 converts a valid byte offset to line and UTF-16 column numbers, both 0-based. func (m *Mapper) lineCol16(offset int) (int, int) { … } // OffsetLineCol8 converts a valid byte offset to line and UTF-8 column numbers, both 1-based. func (m *Mapper) OffsetLineCol8(offset int) (int, int) { … } // line returns: // - the 0-based index of the line that encloses the (valid) byte offset; // - the start offset of that line; and // - whether the offset denotes a carriage return (\r) at line end. func (m *Mapper) line(offset int) (int, int, bool) { … } // OffsetMappedRange returns a MappedRange for the given byte offsets. // A MappedRange can be converted to any other form. func (m *Mapper) OffsetMappedRange(start, end int) (MappedRange, error) { … } // RangeOffsets converts a protocol (UTF-16) range to start/end byte offsets. func (m *Mapper) RangeOffsets(r Range) (int, int, error) { … } // PositionOffset converts a protocol (UTF-16) position to a byte offset. func (m *Mapper) PositionOffset(p Position) (int, error) { … } // PosPosition converts a token pos to a protocol (UTF-16) position. func (m *Mapper) PosPosition(tf *token.File, pos token.Pos) (Position, error) { … } // PosLocation converts a token range to a protocol (UTF-16) location. func (m *Mapper) PosLocation(tf *token.File, start, end token.Pos) (Location, error) { … } // PosRange converts a token range to a protocol (UTF-16) range. func (m *Mapper) PosRange(tf *token.File, start, end token.Pos) (Range, error) { … } // NodeRange converts a syntax node range to a protocol (UTF-16) range. func (m *Mapper) NodeRange(tf *token.File, node ast.Node) (Range, error) { … } // RangeLocation pairs a protocol Range with its URI, in a Location. func (m *Mapper) RangeLocation(rng Range) Location { … } // PosMappedRange returns a MappedRange for the given token.Pos range. func (m *Mapper) PosMappedRange(tf *token.File, start, end token.Pos) (MappedRange, error) { … } // NodeMappedRange returns a MappedRange for the given node range. func (m *Mapper) NodeMappedRange(tf *token.File, node ast.Node) (MappedRange, error) { … } type MappedRange … // Offsets returns the (start, end) byte offsets of this range. func (mr MappedRange) Offsets() (start, end int) { … } // URI returns the URI of the range's file. func (mr MappedRange) URI() DocumentURI { … } // Range returns the range in protocol (UTF-16) form. func (mr MappedRange) Range() Range { … } // Location returns the range in protocol location (UTF-16) form. func (mr MappedRange) Location() Location { … } // String formats the range in UTF-8 notation. func (mr MappedRange) String() string { … } // LocationTextDocumentPositionParams converts its argument to its result. func LocationTextDocumentPositionParams(loc Location) TextDocumentPositionParams { … }