def separator.of

bend-lint-rules@0.2.0.0 · layout/format.bend:1363

import bend-lint-rules@0.2.0.0/layout/format.bend as Format
import Base

1363# What goes between x and the tree b that y starts. A constructor's brace
1364# is glued to its name; a brace after a space can instead be the next
1365# (annotated) argument of a call without commas, so the space stays. Other
1366# atoms need a space.
1367def separator.of(+x: Token, +y: Token, +group: Bool, b: Tree) -> Doc:
1368  Bool.pick(
1369    Doc,
1370    is_comment(y),
1371    space("  ", 2),
1372    Bool.pick(
1373      Doc,
1374      is_tight(Token.sym(y)),
1375      nothing(),
1376      Bool.pick(
1377        Doc,
1378        is_punct(Token.sym(x)),
1379        space(" ", 1),
1380        Bool.pick(
1381          Doc,
1382          is_sigil(Token.sym(x)),
1383          nothing(),
1384          Bool.pick(
1385            Doc,
1386            is_glued_prefix(x, Some{b}),
1387            nothing(),
1388            Bool.pick(
1389              Doc,
1390              is_inc(Token.sym(x)),
1391              nothing(),
1392              Bool.pick(
1393                Doc,
1394                group && is_sym(Token.sym(y), Lbrc{}) && U32.is_ne(Token.end(x), Token.beg(y)),
1395                space(" ", 1),
1396                Bool.pick(
1397                  Doc,
1398                  group && is_opener(Token.sym(y)) && is_callee(x),
1399                  nothing(),
1400                  space(" ", 1)
1401                )
1402              )
1403            )
1404          )
1405        )
1406      )
1407    )
1408  )

Uses (23)

Used by (1)