View Source Styler.Style behaviour (Styler v0.3.0)
A Style takes AST and returns a transformed version of that AST.
Because these transformations involve traversing trees (the "T" in "AST"), we wrap the AST in a structure called a Zipper to facilitate walking the trees.
Link to this section Summary
Callbacks
run
will be used with Zipper.traverse_while/3
, meaning it will be executed on every node of the AST.
Functions
Set the line of all comments with line
in range_start..range_end
to instead have line range_start
Change the line
of all comments with line
in range
by adding delta
to it.
A positive delta will move the lines further down a file, while a negative delta will move them up.
Link to this section Types
Link to this section Callbacks
@callback run(Styler.Zipper.zipper(), context()) :: {Styler.Zipper.command(), Styler.Zipper.zipper(), context()}
run
will be used with Zipper.traverse_while/3
, meaning it will be executed on every node of the AST.
You can skip traversing parts of the tree by returning a Zipper that's further along in the traversal, for example
by calling Zipper.skip(zipper)
to skip an entire subtree you know is of no interest to your Style.
Link to this section Functions
Set the line of all comments with line
in range_start..range_end
to instead have line range_start
Change the line
of all comments with line
in range
by adding delta
to it.
A positive delta will move the lines further down a file, while a negative delta will move them up.