Create and evaluate nodes.
All nodes represent Clojure/ClojureScript/EDN.
Create and evaluate nodes. All nodes represent Clojure/ClojureScript/EDN.
The Clojure reader can add positional metadata.
This metadata is not in the original source, and therefore assumed to be uninteresting to users of rewrite-cljc.
Clojure will add :line
and :column
to quoted lists.
Sci, and therefore Babashka does the same for all elements that accept metadata and adds :end-line
and :end-column
The Clojure reader can add positional metadata. This metadata is not in the original source, and therefore assumed to be uninteresting to users of rewrite-cljc. Clojure will add `:line` and `:column` to quoted lists. Sci, and therefore Babashka does the same for all elements that accept metadata and adds `:end-line` and `:end-column`
(child-sexprs node)
(child-sexprs node opts)
Returns children for node
converted to Clojure forms.
Optional opts
can specify:
:auto-resolve
specify a function to customize namespaced element auto-resolve behavior, see docs on namespaced elementsReturns children for `node` converted to Clojure forms. Optional `opts` can specify: - `:auto-resolve` specify a function to customize namespaced element auto-resolve behavior, see [docs on namespaced elements](/doc/01-introduction.adoc#namespaced-elements)
(children node)
Returns child nodes for node
.
Returns child nodes for `node`.
(comma-node s)
Create comma node of string s
, where s
is one or more comma characters.
Create comma node of string `s`, where `s` is one or more comma characters.
(comma-separated nodes)
Interleave nodes
with ", "
nodes.
Interleave `nodes` with `", "` nodes.
(comma? node)
Returns true if node
represents one or more commas.
Returns true if `node` represents one or more commas.
(comment-node s)
Create node representing a comment with text s
.
Create node representing a comment with text `s`.
(comment? node)
Returns true if node
is a comment.
Returns true if `node` is a comment.
(deref-node children)
Create node representing the dereferencing of a form (i.e. @...
)
where children
is either a sequence of nodes or a single node.
Create node representing the dereferencing of a form (i.e. `@...`) where `children` is either a sequence of nodes or a single node.
(eval-node children)
Create node representing an inline evaluation (i.e. #=...
)
where children
is either a sequence of nodes or a single node.
Create node representing an inline evaluation (i.e. `#=...`) where `children` is either a sequence of nodes or a single node.
(fn-node children)
Create node representing an anonymous function with children
.
Create node representing an anonymous function with `children`.
(form-meta form)
Same as clojure.core/meta
but respects [[rewrite-cljc/elide-metadata]].
Use when you want to omit reader generated metadata on forms.
Same as `clojure.core/meta` but respects [[rewrite-cljc/*elide-metadata*]]. Use when you want to omit reader generated metadata on forms.
(forms-node children)
Create top-level node wrapping multiple children
(equivalent to an implicit do
at the top-level).
Create top-level node wrapping multiple `children` (equivalent to an implicit `do` at the top-level).
(inner? node)
Returns true if node
can have children.
Returns true if `node` can have children.
(integer-node value)
(integer-node value base)
Create node representing an integer value
in base
.
base
defaults to 10.
Note: the parser does not currently parse to integer-nodes, but the write can handle them just fine.
Create node representing an integer `value` in `base`. `base` defaults to 10. Note: the parser does not currently parse to integer-nodes, but the write can handle them just fine.
(keyword-node k & [auto-resolved?])
Create a node representing a keyword k
.
Examples usages:
(keyword-node :kw)
- unqualified(keyword-node :my-prefix/kw)
- qualifiedYou can pass true
for the optional auto-resolved?
parameter:
(keyword-node :kw true)
- auto-resolved to current ns, equivalent to code ::kw
(keyword-node :ns-alias/kw true)
- auto-resolved to namespace with alias ns-alias, equivalent to code ::ns-alias/kw
Create a node representing a keyword `k`. Examples usages: * `(keyword-node :kw)` - unqualified * `(keyword-node :my-prefix/kw)` - qualified You can pass `true` for the optional `auto-resolved?` parameter: * `(keyword-node :kw true)` - auto-resolved to current ns, equivalent to code `::kw` * `(keyword-node :ns-alias/kw true)` - auto-resolved to namespace with alias ns-alias, equivalent to code `::ns-alias/kw`
(leader-length node)
Returns number of characters before children for node
.
Returns number of characters before children for `node`.
(length node)
Return number of characters for the string version of node
.
Return number of characters for the string version of `node`.
(line-separated nodes)
Interleave nodes
with newline nodes.
Interleave `nodes` with newline nodes.
(linebreak? node)
Returns true if node
represents one or more linebreaks.
Returns true if `node` represents one or more linebreaks.
(list-node children)
Create a node representing a list with children
.
Create a node representing a list with `children`.
(map-context-apply node map-qualifier)
Applies map-qualifier
context to node
Applies `map-qualifier` context to `node`
(map-context-clear node)
Removes map-qualifier context for node
Removes map-qualifier context for `node`
(map-node children)
Create a node representing an map with children
.
Create a node representing an map with `children`.
(map-qualifier-node auto-resolved? prefix)
Create a map qualifier node.
(map-qualifier-node false "my-prefix")
-> #:my-prefix
- qualified(map-qualifier-node true "my-ns-alias")
-> #::my-ns-alias
- auto-resolved namespace alias(map-qualifier-node true nil)
-> #::
- auto-resolved current namespaceThe above are the only supported variations, use rewrite-cljc.node/map-node
for unqualified maps.
Create a map qualifier node. - `(map-qualifier-node false "my-prefix")` -> `#:my-prefix` - qualified - `(map-qualifier-node true "my-ns-alias")` -> `#::my-ns-alias` - auto-resolved namespace alias - `(map-qualifier-node true nil)` -> `#::` - auto-resolved current namespace The above are the only supported variations, use [[rewrite-cljc.node/map-node]] for unqualified maps.
(meta-node children)
(meta-node metadata data)
Create node representing a form data
and its metadata
.
Create node representing a form `data` and its `metadata`.
(namespaced-map-node children)
Create a namespaced map node with children
.
rewrite-cljc.node/map-qualifier-node
rewrite-cljc.node/map-node
Create a namespaced map node with `children`. - first child must be a map-qualifier node, see [[rewrite-cljc.node/map-qualifier-node]] - optionally followed by whitespace node(s), - followed by a map node, see [[rewrite-cljc.node/map-node]]
(newline-node s)
Create newline node of string s
, where s
is one or more linebreak characters.
Create newline node of string `s`, where `s` is one or more linebreak characters.
(newlines n)
Create node representing n
newline characters.
Create node representing `n` newline characters.
(node? x)
Returns true if x
is a rewrite-cljc created node.
Returns true if `x` is a rewrite-cljc created node.
(printable-only? node)
Return true if node
cannot be converted to an s-expression element.
Return true if `node` cannot be converted to an s-expression element.
(quote-node children)
Create node representing a quoted form where children
is either a sequence of nodes or a single node.
Create node representing a quoted form where `children` is either a sequence of nodes or a single node.
(raw-meta-node children)
(raw-meta-node metadata data)
Create node representing a form data
and its metadata
using the
#^
prefix.
Create node representing a form `data` and its `metadata` using the `#^` prefix.
(reader-macro-node children)
(reader-macro-node macro-node form-node)
Create node representing a reader macro (i.e. #... ...
) with children
.
Create node representing a reader macro (i.e. `#... ...`) with `children`.
(regex-node pattern-string)
Create node representing a regex with pattern-string
Create node representing a regex with `pattern-string`
(replace-children node children)
Returns node
replacing current children with children
.
Returns `node` replacing current children with `children`.
(set-node children)
Create a node representing a set with children
.
Create a node representing a set with `children`.
(sexpr node)
(sexpr node opts)
Return node
converted to form.
Optional opts
can specify:
:auto-resolve
specify a function to customize namespaced element auto-resolve behavior, see docs on namespaced elementsReturn `node` converted to form. Optional `opts` can specify: - `:auto-resolve` specify a function to customize namespaced element auto-resolve behavior, see [docs on namespaced elements](/doc/01-introduction.adoc#namespaced-elements)
(sexprs nodes)
(sexprs nodes opts)
Return forms for nodes
. Nodes that do not represent s-expression are skipped.
Optional opts
can specify:
:auto-resolve
specify a function to customize namespaced element auto-resolve behavior, see docs on namespaced elementsReturn forms for `nodes`. Nodes that do not represent s-expression are skipped. Optional `opts` can specify: - `:auto-resolve` specify a function to customize namespaced element auto-resolve behavior, see [docs on namespaced elements](/doc/01-introduction.adoc#namespaced-elements)
(spaces n)
Create node representing n
spaces.
Create node representing `n` spaces.
(string node)
Return the string version of node
.
Return the string version of `node`.
(string-node lines)
Create node representing a string value where lines
can be a sequence of strings or a single string.
Create node representing a string value where `lines` can be a sequence of strings or a single string.
(syntax-quote-node children)
Create node representing a syntax-quoted form where children
is either a sequence of nodes or a single node.
Create node representing a syntax-quoted form where `children` is either a sequence of nodes or a single node.
(tag node)
Returns keyword representing type of node
.
Returns keyword representing type of `node`.
(token-node value)
(token-node value string-value)
Create node for an unspecified token of value
.
Create node for an unspecified token of `value`.
(uneval-node children)
Create node representing an uneval #_
form with children
.
Create node representing an uneval `#_` form with `children`.
(unquote-node children)
Create node representing an unquoted form (i.e. ~...
) where children
.
is either a sequence of nodes or a single node.
Create node representing an unquoted form (i.e. `~...`) where `children`. is either a sequence of nodes or a single node.
(unquote-splicing-node children)
Create node representing an unquote-spliced form (i.e. ~@...
) where children
.
is either a sequence of nodes or a single node.
Create node representing an unquote-spliced form (i.e. `~@...`) where `children`. is either a sequence of nodes or a single node.
(value node)
DEPRECATED: Get first child as a pair of tag/sexpr (if inner node),
or just the node's own sexpr. (use explicit analysis of children
child-sexprs
instead)
DEPRECATED: Get first child as a pair of tag/sexpr (if inner node), or just the node's own sexpr. (use explicit analysis of `children` `child-sexprs` instead)
(var-node children)
Create node representing a var
where children
is either a sequence of nodes or a single node.
Create node representing a var where `children` is either a sequence of nodes or a single node.
(vector-node children)
Create a node representing a vector with children
.
Create a node representing a vector with `children`.
(whitespace-node s)
Create whitespace node of string s
, where s
is one or more space characters.
Create whitespace node of string `s`, where `s` is one or more space characters.
(whitespace-nodes s)
Convert string s
of whitespace to whitespace/newline nodes.
Convert string `s` of whitespace to whitespace/newline nodes.
(whitespace-or-comment? node)
Return true when node
represents whitespace or comment.
Return true when `node` represents whitespace or comment.
(whitespace? node)
Returns true if node
represents Clojure whitespace.
Returns true if `node` represents Clojure whitespace.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close