Skip to main content

statement_glue

Function statement_glue 

Source
pub fn statement_glue(elements: &[SyntaxElement]) -> Vec<bool>
Expand description

Per-element glue verdicts for a STATEMENT’s top-level element stream.

glue_before[i] is true when the authored gap immediately before elements[i] is unit-internal: the formatter renders it as a single space and never breaks there. Entries for trivia elements, and for elements with no gap before them (glued in the source — adjacency already forms one atom), are false and meaningless.

The rules, each backed by the corpus survey:

  • a path operator binds forward (-- (1,1) is one unit; the break point is before the operator);
  • at binds both sides (at is essentially never split from its coordinate in the wild);
  • an operation keyword binds forward to its argument (circle (1), node {A}, controls (a));
  • a coordinate binds to a following operation keyword ((6,6) circle (3) — the split the model exists to forbid);
  • inside a loose bracket run (a statement-level [], an options list) a gap glues unless it follows a comma: edge [loop above] never splits an option mid-phrase, while a long keyval run still breaks at its entry boundaries — the comma convention every keyval layout here uses.

A comment on either side of a gap suppresses every rule.