~/bend-docscommunity

lib/text/main.bend checks

raw source on the hub · import bend-lint-rules@0.1.1.0/lib/text/main.bend as Main

Edits to texts, and places in them: the edits to make, spans that must not touch, and the lines and columns of offsets.

4 imports
import Base
import bend-lint-api@0.1.1.0/shared/lists.bend as Lists
import bend-lint-api@0.1.1.0/shared/names.bend as Names
import bend-lint-api@0.1.1.0/shared/strings.bend as Strings

Types

type Edit source · line 12 · raw

Data

The text from beg to end in the file at path, replaced by text.

type Spans source · line 48 · raw

Data

Spans that never touch (Spans.touches), by place: a balanced (AVL) tree, by start, then end; height counts its levels. As spans never touch, their ends rise with their starts.

type Position source · line 220 · raw

Data

A place in a text: its line and its column, from 1. A column counts UTF-16 units, as editors do.

type Place source · line 224 · raw

Data

An offset in the file at path.

type Placed source · line 228 · raw

Data

An offset to place, by its place among the offsets asked; and a place found, by the same.

type Located source · line 231 · raw

Data

type Walk source · line 235 · raw

Data

The offsets left to place, in offset order, and the places found, last first.

Definitions

def Edit.path source · line 15 · raw

@edit:Edit -> String

def Edit.is_le source · line 20 · raw

@a:Edit -> @b:Edit -> Bool

def apply.go source · line 27 · raw

@edits:List<&2, Edit> -> @+rest:String -> @+at:U32 -> @out:List<&2, String> -> String

rest, the text from at on, with edits (in order) made, after the pieces of out (last first). The pieces join once, at the end, so the text is copied once, whatever the number of edits.

def apply source · line 40 · raw

@edits:List<&2, Edit> -> @text:String -> String

text with edits made. Edits must not overlap.

def Spans.height source · line 52 · raw

@t:Spans -> U32

def Spans.node source · line 60 · raw

@+l:Spans -> @b:U32 -> @e:U32 -> @+r:Spans -> Spans

The node over l and r, whose heights differ by one at most.

def Spans.lean_left.if source · line 65 · raw

@outer:Bool -> @ll:Spans -> @lb:U32 -> @le:U32 -> @lr:Spans -> @b:U32 -> @e:U32 -> @r:Spans -> Spans

def Spans.lean_left source · line 83 · raw

@l:Spans -> @b:U32 -> @e:U32 -> @r:Spans -> Spans

The node over l and r, where l is two levels higher: turned right, after its left turns left if its inner side is the higher.

def Spans.lean_right.if source · line 90 · raw

@outer:Bool -> @l:Spans -> @b:U32 -> @e:U32 -> @rl:Spans -> @rb:U32 -> @re:U32 -> @rr:Spans -> Spans

def Spans.lean_right source · line 107 · raw

@l:Spans -> @b:U32 -> @e:U32 -> @r:Spans -> Spans

The node over l and r, where r is two levels higher: the mirror of lean_left.

def Spans.balance.if source · line 114 · raw

@left:Bool -> @right:Bool -> @l:Spans -> @b:U32 -> @e:U32 -> @r:Spans -> Spans

def Spans.balance source · line 124 · raw

@+l:Spans -> @b:U32 -> @e:U32 -> @+r:Spans -> Spans

The node over l and r, balanced: their heights may differ by two.

def Spans.cmp.of source · line 129 · raw

@starts:Cmp -> @e:U32 -> @y:U32 -> Cmp

def Spans.cmp source · line 139 · raw

@t:Spans -> @b:U32 -> @e:U32 -> Cmp

How the span from b to e compares with the root's of t, by start, then end; GT past a leaf.

def Spans.add source · line 147 · raw

@t:Spans -> @+b:U32 -> @+e:U32 -> @side:Cmp -> Spans

t with the span from b to e; side is how it compares with the root's.

def Spans.has source · line 157 · raw

@t:Spans -> @+b:U32 -> @+e:U32 -> @side:Cmp -> Bool

Whether t holds the span from b to e; side is how it compares with the root's.

def Spans.starts_before source · line 168 · raw

@t:Spans -> @e:U32 -> Bool

def Spans.last source · line 177 · raw

@t:Spans -> @+e:U32 -> @found:Maybe<&2, U32> -> @before:Bool -> Maybe<&2, U32>

The end of the last span of t (by start, then end) that starts before e, or found. before says whether the root's does. Its end is the furthest of theirs, as ends rise with starts.

def Spans.ends_after source · line 186 · raw

@last:Maybe<&2, U32> -> @b:U32 -> Bool

def Spans.touches.insertion source · line 194 · raw

@insertion:Bool -> @+t:Spans -> @+b:U32 -> @+e:U32 -> Bool

Whether the span from b to e touches one of t: they share a character, or two insertions are at one place.

def Spans.touches.of source · line 201 · raw

@shares:Bool -> @t:Spans -> @+b:U32 -> @+e:U32 -> Bool

def Spans.touches source · line 208 · raw

@+t:Spans -> @+b:U32 -> @+e:U32 -> Bool

def Placed.is_le source · line 238 · raw

@a:Placed -> @b:Placed -> Bool

def Located.is_le source · line 243 · raw

@a:Located -> @b:Located -> Bool

def Placed.of source · line 248 · raw

@offsets:List<&2, U32> -> @+index:U32 -> @out:List<&2, Placed> -> List<&2, Placed>

def Walk.is_due source · line 255 · raw

@pending:List<&2, Placed> -> @at:U32 -> Bool

def Walk.emit source · line 263 · raw

@pending:List<&2, Placed> -> @due:Bool -> @+at:U32 -> @+line:U32 -> @+column:U32 -> @out:List<&2, Located> -> Walk

The offsets due at at, placed at line and column.

def Walk.done source · line 284 · raw

@w:Walk -> List<&2, Located>

def Walk.go source · line 290 · raw

@text:String -> @+at:U32 -> @+line:U32 -> @column:U32 -> @w:Walk -> List<&2, Located>

The offsets placed, one character of text at a time; offsets past its end are placed at its end.

def Walk.positions source · line 313 · raw

@located:List<&2, Located> -> @out:List<&2, Position> -> List<&2, Position>

def Walk.locate source · line 321 · raw

@+sorted:List<&2, Placed> -> @text:String -> List<&2, Located>

The offsets of sorted (in offset order) placed in text, in no order.

def positions source · line 325 · raw

@text:String -> @offsets:List<&2, U32> -> List<&2, Position>

Where each offset of offsets is in text, in order: one pass over the text, whatever the number of offsets.

def Place.key source · line 335 · raw

@path:String -> @offset:U32 -> String

def Place.at source · line 339 · raw

@places:Map<&2, Position> -> @path:String -> @offset:U32 -> Position

Where the offset offset of the file at path is, among places (what places gives); 1:1 if it is not there.

def places.group source · line 347 · raw

@requests:List<&2, Place> -> @groups:Map<&2, List<&2, Placed>> -> Map<&2, List<&2, Placed>>

The requests by file, each offset numbered by itself, onto groups.

def places.keep source · line 358 · raw

@located:List<&2, Located> -> @+path:String -> @out:Map<&2, Position> -> Map<&2, Position>

The places found in the file at path, by key, onto out.

def places.walk source · line 370 · raw

@paths:List<&2, String> -> @+groups:Map<&2, List<&2, Placed>> -> @+texts:Map<&2, String> -> @out:Map<&2, Position> -> Map<&2, Position>

The requests of each file of paths placed in its text, onto out; a file texts lacks places them at its start.

def places source · line 396 · raw

@texts:Map<&2, String> -> @requests:List<&2, Place> -> Map<&2, Position>

Where each requested offset is, by key (read with Place.at): one pass over each file asked about, whatever the number of requests. texts holds the files' texts, by path.