nsorg.zip

Functions for working with zippers.

ancestors

(ancestors zloc)
Return seq of zipper nodes that are ancestors of the given zipper node.

Parameters:
  zloc - zipper node

find-ns-form

(find-ns-form zloc)
Finds ns form in the subtree of given zipper node.

Parameters:
  zloc - zipper node

order-node-pairs

(order-node-pairs zlocs)
Order given zipper node pairs alphabetically by sexpr value of left element of the pair. If sexpr is sequential,
use the sexpr value of the first item for sorting.

Parameters:
zlocs - zipper node pairs to sort

order-nodes

(order-nodes zlocs)
Order given zipper nodes alphabetically by their sexpr value. If sexpr is sequential, use the sexpr value of the
first item for sorting.

Parameters:
zlocs - zipper nodes to sort

order-sexpr

(order-sexpr zloc)(order-sexpr zloc {:keys [exclude-first? map?], :as opts})
Order child zipper nodes of given collection zipper node.

Parameters:
  zloc           - collection zipper node
  exclude-first? - exclude first element of collection from sorting (default: false)
  map?           - collection is map and nodes should be ordered as pairs (default: false)

organize-ns-form

(organize-ns-form ns-zloc rules)
Organize ns form by applying given rules. A single rule a map with two keys:

  :predicate - function of zipper node decided if rule should be applied to this node
  :transform - modifies given zipper node

Parameters:
  ns-zloc - zipper node of ns form
  rules   - collection of rules to apply 

remove-duplicates-from-sexpr

(remove-duplicates-from-sexpr zloc)(remove-duplicates-from-sexpr zloc {:keys [exclude-first? map?]})
Remove duplicates from child zipper nodes of given collection zipper node.
Map entries are considered duplicates if they they have the same value (not key).

Parameters:
  zloc           - collection zipper node
  exclude-first? - exclude first element of collection from duplicate removal (default: false)
  map?           - collection is map and nodes should be treated as pairs (default: false)

right-nodes

(right-nodes zloc)
Return seq of zipper nodes that are right siblings of the given zipper node.

Parameters:
  zloc - zipper node

sexpr

(sexpr zloc)
Like `rewrite.clj.zip/sexpr but returns nil for nodes that are printable-only.