~/bend-docscommunity

syntax/outline.bend checks

raw source on the hub · import 0x729eecea86ea5a2cdba3a2856a313bca/syntax/outline.bend as Outline

syntax/outline: a source's top-level items, read line by line. A top-level item starts at column 0, so a line the outline does not understand costs nothing: it is skipped, and the items around it still stand. That tolerance is the point: an editor asks about files that are half-written.

2 imports
import Base
import ../lazy/lazy.bend as Lazy

Types

type ItemKind source · line 10 · raw

Data

what an item is; ILocal is not read from a source, it is how the server offers a binder as a candidate

type Item source · line 21 · raw

Data

line is 0-based; sig is the header text (a def's through its :, a law's whole block, a constructor's line); doc is the comment block right above; path is an import's target

type Cls source · line 25 · raw

Data

what a line is, by its first chars

type Mode source · line 36 · raw

Data

Pending: a def's header that has not reached its :, or a law's block

type St source · line 42 · raw

Data

doc and out are reversed

Definitions

def is_blank source · line 46 · raw

@s:String -> Bool

only whitespace?

def classify source · line 50 · raw

@+s:String -> Cls

a line's class

def name.go source · line 60 · raw

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

a name runs to the first of ( < : { or a space

def name source · line 78 · raw

@s:String -> String

the name that starts a header: up to (, <, :, { or a space

def lstrip.go source · line 81 · raw

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

def lstrip source · line 89 · raw

@s:String -> String

leading spaces dropped

def nonempty source · line 93 · raw

@s:String -> Bool

not ""?

def words source · line 97 · raw

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

the words of a line

def undoc source · line 101 · raw

@+s:String -> String

a comment line without its #

def undoc.all source · line 105 · raw

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

def doc_text source · line 113 · raw

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

the comment block (reversed) as text

def sig_text source · line 117 · raw

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

the pending header lines (reversed) as one text

def add source · line 121 · raw

@m:Maybe<&2, Item> -> @out:List<&2, Item> -> List<&2, Item>

an item, when there is one, onto the items

def import_item.of source · line 129 · raw

@ws:List<&2, String> -> @s:String -> @n:U32 -> @doc:String -> Maybe<&2, Item>

import <path> as <Alias> is named by its alias; import Base by its path

def import_item source · line 139 · raw

@+s:String -> @n:U32 -> @doc:String -> Maybe<&2, Item>

an import line as an item: import Base, or import <path> as <Alias>

def def_name source · line 143 · raw

@+s:String -> String

the name of a def or @unsafe def line

def starts_upper.of source · line 146 · raw

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

def starts_upper source · line 154 · raw

@s:String -> Bool

does the text start with a capital?

def ctor.of source · line 158 · raw

@+t:String -> @n:U32 -> Maybe<&2, Item>

an indented line of a type block: Ctor{..}

def ctor source · line 163 · raw

@text:String -> @n:U32 -> Maybe<&2, Item>

an indented line of a type block as a constructor item, when it is one

def is_def source · line 167 · raw

@k:ItemKind -> Bool

a def?

def flush source · line 175 · raw

@mode:Mode -> @out:List<&2, Item> -> List<&2, Item>

what was pending becomes an item

def pend_more source · line 183 · raw

@+k:ItemKind -> @+nm:String -> @+l:U32 -> @+d:String -> @+sig:List<&2, String> -> @+text:String -> @+n:U32 -> @+out:List<&2, Item> -> St

one more line of a pending header; a def's ends at the line that ends in :

def indent source · line 191 · raw

@mode:Mode -> @text:String -> @+n:U32 -> @out:List<&2, Item> -> St

an indented line: more of a pending header, a constructor of an open type, or nothing

def stray source · line 202 · raw

@+mode:Mode -> @text:String -> @+n:U32 -> @+out:List<&2, Item> -> St

a column-0 line that starts nothing: ) -> T: closing a def's header that broke across lines; anywhere else it is junk, and ends what was pending

def start_def source · line 210 · raw

@+s:String -> @+n:U32 -> @+doc:String -> @+out:List<&2, Item> -> St

a def line: an item at once when it ends in :, else a pending header

def doc_above source · line 217 · raw

@mode:Mode -> @doc:List<&2, String> -> List<&2, String>

a comment continues the block above it only at the top level

def step.go source · line 224 · raw

@cls:Cls -> @+mode:Mode -> @+s:String -> @+n:U32 -> @doc:List<&2, String> -> @out:List<&2, Item> -> St

def step source · line 245 · raw

@+s:String -> @st:St -> St

one line, by its class

def run source · line 250 · raw

@lines:List<&2, String> -> @st:St -> St

every line, in order

def finish source · line 258 · raw

@st:St -> List<&2, Item>

the items once the lines are over, a pending header flushed

def items source · line 263 · raw

@text:String -> List<&2, Item>

the top-level items of a source, in order

def is_import source · line 270 · raw

@k:ItemKind -> Bool

an import?

def find source · line 278 · raw

@items:List<&2, Item> -> @+name:String -> Maybe<&2, Item>

the item of that name; imports are not names of the module

def import_path source · line 287 · raw

@items:List<&2, Item> -> @+alias:String -> Maybe<&2, String>

the path behind an import alias

def has source · line 296 · raw

@names:List<&2, String> -> @+name:String -> Bool

is the name among these?

def starting.go source · line 303 · raw

@items:List<&2, Item> -> @+prefix:String -> @+qual:String -> @+seen:List<&2, String> -> List<&2, Item>

def starting source · line 316 · raw

@items:List<&2, Item> -> @prefix:String -> @qual:String -> List<&2, Item>

the named items whose name starts with prefix, each renamed qual ++ name (the text to insert). A law and the def that fills it share a name: the first stands for both.

def aliases source · line 320 · raw

@items:List<&2, Item> -> @+prefix:String -> List<&2, Item>

the import aliases that start with prefix (import Base has none)