~/bend-docscommunity

src/lsp/enc.bend checks

raw source on the hub · import bolt@1.23.0.0/src/lsp/enc.bend as Enc

lsp/enc: position encodings (LSP 3.17 positionEncoding), the one place a character offset crosses the protocol boundary. Pure. bolt counts columns in code points (a Bend String is a list of them); a client that offers utf-32 gets exactly those, and any other gets UTF-16 code units, where a char outside the Basic Multilingual Plane counts 2. Every position the server reads goes through into, and every one it sends through out (proto.bend's position, semantic.bend's tokens). ezjson v1.2.0, pinned by hash, is trusted to parse and print JSON correctly; it proves that itself.

4 imports
import Base
import ../lazy/lazy.bend as Lazy
import 0xa81e161008ecc2f297c0a3065cb9b188/main.bend as Ezjson
import 0xa81e161008ecc2f297c0a3065cb9b188/src/value.bend as J

Types

type Enc source · line 15 · raw

Data

the encodings the server speaks

type Cols source · line 151 · raw

Data

a document as the boundary sees it: the encoding its columns convert by and the text's lines

Definitions

def name source · line 20 · raw

@ee:Enc -> String

an encoding's name on the wire

def offers source · line 29 · raw

@cells:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> Bool

does a list of encodings (JSON cells) offer utf-32? A cell that is not a string offers nothing

def cells source · line 38 · raw

@jj:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> 0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json

the cells of an array, JNil when it is not one

def chosen source · line 46 · raw

@yes:Bool -> Enc

the encoding for utf-32 offered or not

def negotiate source · line 55 · raw

@params:0xa81e161008ecc2f297c0a3065cb9b188/src/value.Json -> Enc

the encoding initialize settles on: utf-32 when the client's general.positionEncodings offers it, else UTF-16, LSP's default

def wide source · line 62 · raw

@cc:Char -> Bool

does a char take two UTF-16 code units (it lies past U+FFFF)?

def units.step source · line 66 · raw

@isw:Bool -> @rest:Nat -> Nat

the units a char and the ones after it take: two for a wide char, else one

def units source · line 75 · raw

@cs:List<&2, Char> -> @nn:Nat -> Nat

the UTF-16 code units the first n chars of a line take; a column past the line's end counts one unit a column

def points.skip source · line 86 · raw

@isw:Bool -> @pp:Nat -> Nat

the units left after a char, from 1+p units: p after a narrow one, one fewer after a wide one (none when the offset falls inside its pair)

def points source · line 98 · raw

@cs:List<&2, Char> -> @uu:Nat -> Nat

the chars the first u UTF-16 code units of a line cover; an offset inside a pair covers its char, and one past the line's end counts one column a unit

def out.of source · line 108 · raw

@ee:Enc -> @cs:List<&2, Char> -> @nn:Nat -> Nat

a code-point column of a line in an encoding

def into.of source · line 116 · raw

@ee:Enc -> @cs:List<&2, Char> -> @uu:Nat -> Nat

an encoding's column of a line as a code-point column

def wide_in source · line 124 · raw

@cs:List<&2, Char> -> Bool

does a line hold a char past U+FFFF? Stops at the first

def wide_any source · line 132 · raw

@lines:List<&2, String> -> Bool

does any line hold one? Stops at the first

def narrowed source · line 142 · raw

@ee:Enc -> @wide:Bool -> Enc

the encoding a document's columns convert by: UTF-16 on lines with no wide char counts exactly as utf-32 does (LAWS.bend's enc_narrow), so such a document converts as utf-32 and never looks a line up

def cols.of source · line 155 · raw

@ee:Enc -> @+lines:List<&2, String> -> Cols

a document's lines under an encoding

def cols source · line 159 · raw

@ee:Enc -> @text:String -> Cols

a document's text under an encoding

def chars source · line 163 · raw

@lines:List<&2, String> -> @line:U32 -> List<&2, Char>

a line's chars, none past the end

def out.col source · line 167 · raw

@ee:Enc -> @cs:List<&2, Char> -> @col:U32 -> U32

a code-point column of a line's chars, sent in an encoding

def out.at source · line 176 · raw

@ee:Enc -> @lines:List<&2, String> -> @line:U32 -> @col:U32 -> U32

a code-point column of a document's line, sent in an encoding; utf-32 never looks the line up

def out source · line 184 · raw

@cc:Cols -> @line:U32 -> @col:U32 -> U32

a code-point column sent in the negotiated encoding

def into.col source · line 189 · raw

@ee:Enc -> @cs:List<&2, Char> -> @col:U32 -> U32

a column of a line's chars read in an encoding, as a code-point column

def into.at source · line 198 · raw

@ee:Enc -> @lines:List<&2, String> -> @line:U32 -> @col:U32 -> U32

a column of a document's line read in an encoding; utf-32 never looks the line up

def into source · line 206 · raw

@cc:Cols -> @line:U32 -> @col:U32 -> U32

a column read in the negotiated encoding, as a code-point column