~/bend-docscommunity

src/fmt/plan.bend checks

raw source on the hub · import bolt@1.65.0.0/src/fmt/plan.bend as Plan

src/fmt/plan: what bolt format does, decided from a World of answers (src/lint/world.bend). Pure: it reads no file and writes none. The files are the ones bolt would lint, the files named or every .bend file under the working directory (src/lint/plan.bend's inputs; a bolt.bend is not among them), and the World is filled by the same questions the lint asks. For each file the World read, formatting (src/fmt.bend) either leaves its text as it is or gives another; a file that changes is an edit, its path and its new text. bolt format plans every edit and prints formatted <path> for each; bolt format --check plans none, prints would format <path> for each, and exits 1 when there is one. A path the World could not read is cannot read <path> and exit 1 either way. A file formatting would change whose text holds U+FFFD is skipped (not UTF-8) <path> and is never written: the character is what a byte that is not UTF-8 reads as, so writing the text back could change the file beyond its blank space. With nothing to say the one line is clean.

5 imports
import Base
import ../fmt.bend as Fmt
import ../lazy/lazy.bend as Lazy
import ../lint/world.bend as W
import ../lint/plan.bend as Lint

Types

type Edit source · line 23 · raw

Data

a file to write: its path and its new text

type Plan source · line 27 · raw

Data

what the run does: the files to write, the lines to print, the exit status

type Fate source · line 32 · raw

Data

what formatting makes of a file: nothing, another text, or another text that must not be written

type Fated source · line 38 · raw

Data

a path the World read, and what formatting makes of its file

Definitions

def safe source · line 44 · raw

@text:String -> Bool

can a text be written back as it was read? A byte that is not UTF-8 reads as U+FFFD (src/lsp/files/disk.bend), so a text holding that character may not be the file's own bytes: writing it would change them

def fate.changed source · line 49 · raw

@ok:Bool -> @new:String -> Fate

a text formatting changes: an edit when it can be written back, else skipped

def fate source · line 58 · raw

@+text:String -> Fate

what formatting makes of a text. Whether it can be written back is read only when formatting changes it

def fates source · line 64 · raw

@gs:List<&2, 0xdaa3743e782ddca8ff3f355948b1d747/src/lint/plan.Got> -> List<&2, Fated>

each path the World read with what formatting makes of it, in order; each file is formatted once

def edits.of source · line 74 · raw

@fs:List<&2, Fated> -> List<&2, Edit>

the edits among them, in order

def edits source · line 85 · raw

@gs:List<&2, 0xdaa3743e782ddca8ff3f355948b1d747/src/lint/plan.Got> -> List<&2, Edit>

every file formatting changes and can write back, in order, each with its new text

def skipped.of source · line 89 · raw

@fs:List<&2, Fated> -> List<&2, String>

the paths skipped among them, in order

def skipped source · line 99 · raw

@gs:List<&2, 0xdaa3743e782ddca8ff3f355948b1d747/src/lint/plan.Got> -> List<&2, String>

every file formatting would change but cannot write back, in order

def unread source · line 103 · raw

@gs:List<&2, 0xdaa3743e782ddca8ff3f355948b1d747/src/lint/plan.Got> -> List<&2, String>

the paths the World could not read, in order

def said source · line 113 · raw

@+word:String -> @ps:List<&2, String> -> List<&2, String>

a line for each path, the word before it

def paths source · line 121 · raw

@es:List<&2, Edit> -> List<&2, String>

the paths of the edits, in order

def word source · line 129 · raw

@check:Bool -> String

what is said of the files that change

def lines.or source · line 137 · raw

@ls:List<&2, String> -> List<&2, String>

the lines, or clean when there are none

def some source · line 145 · raw

@-A:Data -> @xs:List<&2, A> -> U32

1 when the list holds anything

def exit source · line 154 · raw

@check:Bool -> @+es:List<&2, Edit> -> @bad:List<&2, String> -> U32

the exit status: 1 when a path could not be read, and, when only checking, when a file would change

def written source · line 162 · raw

@check:Bool -> @es:List<&2, Edit> -> List<&2, Edit>

the edits a run writes: none when it only checks

def plan.at source · line 170 · raw

@+check:Bool -> @+gs:List<&2, 0xdaa3743e782ddca8ff3f355948b1d747/src/lint/plan.Got> -> Plan

the plan over the files the World answered for

def plan source · line 180 · raw

@check:Bool -> @+world:0xdaa3743e782ddca8ff3f355948b1d747/src/lint/world.World -> Plan

what bolt format does in a World: check says whether it only checks