Gets the LSP range from a String.Range
.
Equations
- Lean.FileMap.utf8RangeToLspRange text range = { start := Lean.FileMap.utf8PosToLspPos text range.start, end := Lean.FileMap.utf8PosToLspPos text range.stop }
Instances For
Gets the LSP range of syntax stx
.
Equations
- Lean.FileMap.rangeOfStx? text stx = Lean.FileMap.utf8RangeToLspRange text <$> Lean.Syntax.getRange? stx
Instances For
Convert a Lean.Position
to a String.Pos
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Return the beginning of the line contatining character pos
.
Equations
- Lean.findLineStart s pos = match String.revFindAux s (fun x => decide (x = Char.ofNat 10)) pos with | none => 0 | some n => { byteIdx := n.byteIdx + 1 }
Instances For
Return the indentation (number of leading spaces) of the line containing pos
,
and whether pos
is the first non-whitespace character in the line.
Equations
- Lean.findIndentAndIsStart s pos = let start := Lean.findLineStart s pos; let body := String.findAux s (fun x => decide (x ≠ Char.ofNat 32)) pos start; ((body - start).byteIdx, body == pos)
Instances For
Returns a synthetic Syntax which has the specified String.Range
.
Equations
- Lean.Syntax.ofRange range canonical = Lean.Syntax.atom (Lean.SourceInfo.synthetic range.start range.stop canonical) ""
Instances For
Returns the position of the start of (1-based) line line
.
Equations
- Lean.FileMap.lineStart map line = if h : line - 1 < Array.size map.positions then Array.get map.positions { val := line - 1, isLt := h } else Option.getD (Array.back? map.positions) 0