~/bend-docscommunity

bolt/rules/imports.bend checks

raw source on the hub · import 0x729eecea86ea5a2cdba3a2856a313bca/bolt/rules/imports.bend as Imports

bolt/rules/imports: paths and relative imports, as the project rules see them. A path is normalized (no ./, .. applied), an import resolves against the importing file's directory, and a file's closure is every file the linter read that it reaches by relative imports (import ./m.bend as M, import ../x/y.bend as Y). Imports of files that were not read are dropped: nothing is known of them.

4 imports
import Base
import ../src.bend as Src
import ../../syntax/outline.bend as Outline
import ../../lazy/lazy.bend as Lazy

Types

type Edge source · line 59 · raw

Data

a file (normalized) and the files it imports relatively (normalized)

Definitions

def norm.put source · line 16 · raw

@+s:String -> @acc:List<&2, String> -> List<&2, String>

a segment onto the reversed path: . and empty are dropped, .. pops

def norm.go source · line 25 · raw

@segs:List<&2, String> -> @acc:List<&2, String> -> List<&2, String>

def norm source · line 33 · raw

@path:String -> String

a path without ./, ../ and doubled slashes, so two spellings compare

def init source · line 37 · raw

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

the segments but the last

def dir_of source · line 47 · raw

@path:String -> String

a path's directory, with its slash (core/monoid/; `` at the root)

def resolve source · line 52 · raw

@+from:String -> @rel:String -> String

a path imported from a file, normalized

def targets source · line 63 · raw

@items:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/syntax/outline.Item> -> @+from:String -> List<&2, String>

the relative imports among a file's items, resolved against it

def graph source · line 74 · raw

@files:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/bolt/src.Src> -> List<&2, Edge>

every read file with what it imports

def has source · line 83 · raw

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

is the path among them?

def deps_of source · line 87 · raw

@es:List<&2, Edge> -> @+p:String -> List<&2, String>

what the file at p imports (nothing when it was not read)

def fresh source · line 96 · raw

@ds:List<&2, String> -> @+seen:List<&2, String> -> @+read:List<&2, String> -> List<&2, String>

the files of ds that were read and are not yet seen, each once

def paths source · line 106 · raw

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

the paths of the files

def reach source · line 115 · raw

@fuel:Nat -> @todo:List<&2, String> -> @+seen:List<&2, String> -> @+es:List<&2, Edge> -> @+read:List<&2, String> -> List<&2, String>

a worklist walk; each read file enters todo once, so fuel as many as the files never runs out

def closure.go source · line 127 · raw

@es:List<&2, Edge> -> @+read:List<&2, String> -> @+fuel:Nat -> @from:String -> List<&2, String>

def closure source · line 135 · raw

@+files:List<&2, 0x729eecea86ea5a2cdba3a2856a313bca/bolt/src.Src> -> @from:String -> List<&2, String>

every read file the file at from reaches by relative imports, itself first (normalized paths, in the order they are found). A caller that takes more than one closure builds the graph once and calls closure.go with it: rebuilding it per law file walked every file again.