Liking cljdoc? Tell your friends :D

eastwood.util


all-children-vectorsclj

(all-children-vectors asts)

allow-warningclj

(allow-warning w opt)

allow-warning-based-on-enclosing-macrosclj

(allow-warning-based-on-enclosing-macros w
                                         linter
                                         suppress-desc
                                         suppress-conditions
                                         opt)

assert-keysclj

(assert-keys m key-seq)

ast-expands-macroclj

(ast-expands-macro ast macro-fqsym-set)

ast-to-orderedclj

(ast-to-ordered ast)

Take an ast and return an identical one, except every map is replaced with an ordering-map. The sorting of keys in a specified order can make it significantly easier when printing them out, to see more interesting keys earlier.

Take an ast and return an identical one, except every map is
replaced with an ordering-map.  The sorting of keys in a specified
order can make it significantly easier when printing them out, to see
more interesting keys earlier.
raw docstring

builtin-config-to-resourceclj

(builtin-config-to-resource name)

butlast+lastclj

(butlast+last s)

Returns same value as (juxt butlast last), but slightly more efficient since it only traverses the input sequence s once, not twice.

Returns same value as (juxt butlast last), but slightly more
efficient since it only traverses the input sequence s once, not
twice.
raw docstring

clean-astclj

(clean-ast ast & kws)

clojure-1-6-or-laterclj

(clojure-1-6-or-later)

clojure-1-7-or-laterclj

(clojure-1-7-or-later)

clojure-1-8-or-laterclj

(clojure-1-8-or-later)

clojure-1-9-or-laterclj

(clojure-1-9-or-later)

contains-loc-info?clj

(contains-loc-info? x)

debug-warningclj

(debug-warning w ast opt extra-flags)
(debug-warning w ast opt extra-flags f)

debug?clj

(debug? debug-options opt)

deftype-for-fieldless-defrecordclj

(deftype-for-fieldless-defrecord ast)

disable-warningclj

(disable-warning m)

elide-defprotocol-varsclj

(elide-defprotocol-vars ast)

Motivation: pprint'ing a value containing a defprotocol Var, with all metadata included leads to an infinite loop. Why? The value of a defprotocol's Var is a map.

(1) The value of the key :var in this map is the defprotocol Var itself, and pprint'ing this recurses infinitely.

(2) The value of the key :method-builders in this map has metadata containing the defprotocol Var, so if metadata is being printed, this also leads to an infinite loop.

These problems are most simply avoided by removing these two keys from defprotocol maps.

Note: This can replace Vars in the AST with their values, so the resulting AST is not as it was originally, and will likely fail if you try to generate code from it. It is fine for pprint'ing.

There are cases where this function misses things. It seems like it may be simpler to detect protocol occurrences while doing pprint-meta instead.

Motivation: pprint'ing a value containing a defprotocol Var, with
all metadata included leads to an infinite loop.  Why?  The value of a
defprotocol's Var is a map.

(1) The value of the key :var in this map is the defprotocol Var
    itself, and pprint'ing this recurses infinitely.

(2) The value of the key :method-builders in this map has metadata
    containing the defprotocol Var, so if metadata is being printed, this
    also leads to an infinite loop.

These problems are most simply avoided by removing these two keys from
defprotocol maps.

Note: This can replace Vars in the AST with their values, so the
resulting AST is not as it was originally, and will likely fail if you
try to generate code from it.  It is fine for pprint'ing.

There are cases where this function misses things.  It seems like it
may be simpler to detect protocol occurrences while doing
pprint-meta instead.
raw docstring

elide-metaclj

(elide-meta form elide-key-set)

empty-enclosing-macro-mapclj


enclosing-macrosclj

(enclosing-macros ast)

enhance-extend-argsclj

(enhance-extend-args extend-args)

enhance-extend-invocationsclj

(enhance-extend-invocations ast)

enhance-extend-invocations-prewalkclj

(enhance-extend-invocations-prewalk ast)

expr-in-try-body?clj

(expr-in-try-body? ast)

extend-invocation-ast?clj

(extend-invocation-ast? ast)

filter-keysclj

(filter-keys f m)

filter-valsclj

(filter-vals f m)

fqsym-of-raw-formclj

(fqsym-of-raw-form raw-form)

get-fn-in-defclj

(get-fn-in-def expr)

get-in-astclj

(get-in-ast ast kvec-op-pairs)

get-val-in-map-astclj

(get-val-in-map-ast map-ast k)
(get-val-in-map-ast map-ast k not-found)

has-keys?clj

(has-keys? m key-seq)

init-warning-enable-configclj

(init-warning-enable-config opt)

inside-fieldless-defrecordclj

(inside-fieldless-defrecord ast)

interface?clj

(interface? obj)

invoke-expr?clj

(invoke-expr? ast-node)

keys-in-mapclj

(keys-in-map key-set m)

Return the subset of key-set that are keys of map m, or nil if no element of key-set is a key of m.

Return the subset of key-set that are keys of map m, or nil if no
element of key-set is a key of m.
raw docstring

longest-common-prefixclj

(longest-common-prefix s1 s2)

make-msg-cbclj

(make-msg-cb kind opt)

Tiny helper function to create a simple way to call the Eastwood callback function with only a message string.

Given an option map opt that should have a key :callback whose value is a callback function (which takes a certain kind of map as its only argument), return a function that takes only a string, and then calls the callback function with a proper kind of map, including that message string.

Tiny helper function to create a simple way to call the Eastwood callback function with only a message string.

Given an option map opt that should have a key :callback whose value
is a callback function (which takes a certain kind of map as its only
argument), return a function that takes only a string, and then calls
the callback function with a proper kind of map, including that
message string.
raw docstring

map-keysclj

(map-keys f m)

map-valsclj

(map-vals f m)

mark-exprs-in-try-bodyclj

(mark-exprs-in-try-body ast)

Return an ast that is identical to the argument, except that expressions 'directly' within try blocks will have one of two new keywords with value true.

Statements, i.e. expressions that are not the last one in the body, and thus their return value is discarded, will have the new keyword :eastwood/unused-ret-val-expr-in-try-body with value true. Use the fn statement-in-try-body? to check whether a node was so marked.

Return values, i.e. expressions that are the last one in the body, will have the new keyword :eastwood/used-ret-val-expr-in-try-body with value true. Use the fn ret-expr-in-try-body? to check whether a node was so marked.

Use fn expr-in-try-body? to check whether an expression was either one of these kind.

Return an ast that is identical to the argument, except that
expressions 'directly' within try blocks will have one of two new
keywords with value true.

Statements, i.e. expressions that are not the last one in the body,
and thus their return value is discarded, will have the new
keyword :eastwood/unused-ret-val-expr-in-try-body with value true.
Use the fn statement-in-try-body? to check whether a node was so
marked.

Return values, i.e. expressions that are the last one in the body,
will have the new keyword :eastwood/used-ret-val-expr-in-try-body with
value true.  Use the fn ret-expr-in-try-body? to check whether a node
was so marked.

Use fn expr-in-try-body? to check whether an expression was either one
of these kind.
raw docstring

meets-suppress-conditionclj

(meets-suppress-condition ast enclosing-macros condition)

min-clojure-versionclj

(min-clojure-version min-version-vector)

nil-safe-rseqclj

(nil-safe-rseq s)

ns-form-astsclj

(ns-form-asts asts)

nth-lastclj

(nth-last v n)

Return the nth-last element of a vector v, where n=1 means the last element, n=2 is the second-to-last, etc. Returns nil if there are fewer than n elements in the vector.

Return the nth-last element of a vector v, where n=1 means the last
element, n=2 is the second-to-last, etc.  Returns nil if there are
fewer than n elements in the vector.
raw docstring

op=clj

(op= op)

ordering-mapclj

(ordering-map key-order)
(ordering-map key-order default-comparator)

Create an empty map with a custom comparator that puts the given keys first, in the order specified. Other keys will be placed after the special keys, sorted by the default-comparator.

Create an empty map with a custom comparator that puts the given
keys first, in the order specified. Other keys will be placed after
the special keys, sorted by the default-comparator.
raw docstring

postwalkclj

(postwalk f form)

Performs a depth-first, post-order traversal of form. Calls f on each sub-form, uses f's return value in place of the original. Recognizes all Clojure data structures. Consumes seqs as with doall.

Performs a depth-first, post-order traversal of form.  Calls f on
each sub-form, uses f's return value in place of the original.
Recognizes all Clojure data structures. Consumes seqs as with doall.
raw docstring

pprint-ast-nodeclj

(pprint-ast-node ast & kws)

pprint-formclj

(pprint-form form)

pprint-metaclj

(pprint-meta obj)

A version of pprint that prints all metadata on the object, wherever it appears. (binding [print-meta true] (pprint obj)) prints metadata on symbols, but not on collection, at least with Clojure 1.6.0 and probably earlier versions. Clojure ticket CLJ-1445 may improve upon this in the future.

http://dev.clojure.org/jira/browse/CLJ-1445

A version of pprint that prints all metadata on the object,
wherever it appears.  (binding [*print-meta* true] (pprint obj))
prints metadata on symbols, but not on collection, at least with
Clojure 1.6.0 and probably earlier versions.  Clojure ticket CLJ-1445
may improve upon this in the future.

http://dev.clojure.org/jira/browse/CLJ-1445
raw docstring

pprint-meta-elidedclj

(pprint-meta-elided form)

prewalkclj

(prewalk f form)

Like postwalk, but does pre-order traversal.

Like postwalk, but does pre-order traversal.
raw docstring

(print-enclosing-macros ast)

(print-var-info-summary var-info-map opts)

process-configsclj

(process-configs warning-enable-config)

protocol?clj

(protocol? p)

Make a good guess as to whether p is an object created via defprotocol.

Make a good guess as to whether p is an object created via defprotocol.
raw docstring

pstclj

(pst e depth print-cb)

'Prints' a stack trace of the exception, to the depth requested (the entire stack trace if depth is nil). Does not print ex-data.

No actual printing is done in this function. The callback function print-cb is called once for each line of output.

'Prints' a stack trace of the exception,  to the depth requested (the
entire stack trace if depth is nil).  Does not print ex-data.

No actual printing is done in this function.  The callback function
print-cb is called once for each line of output.
raw docstring

regex?clj

(regex? x)

remove-longest-prefixclj

(remove-longest-prefix s prefixes)

If string s starts with any of the strings in the sequence prefixes, return s with the longest of these prefixes removed. Otherwise, return s.

If string s starts with any of the strings in the sequence
prefixes, return s with the longest of these prefixes removed.
Otherwise, return s.
raw docstring

remove-prefixclj

(remove-prefix s prefix)

If string s starts with the string prefix, return s with that prefix removed. Otherwise, return s.

If string s starts with the string prefix, return s with that
prefix removed.  Otherwise, return s.
raw docstring

replace-comments-and-quotes-with-nilclj

(replace-comments-and-quotes-with-nil form)

replace-subforms-with-first-in-setclj

(replace-subforms-with-first-in-set form sym-set replace-fn)

ret-expr-in-try-body?clj

(ret-expr-in-try-body? ast)

safe-firstclj

(safe-first f)

separate-suffixclj

(separate-suffix s suffixes)

Given a string s and a sequence of strings, suffixes, return a vector of 2 strings [x y] where y is the first element of suffixes that is a suffix of s, and (str x y)=s. If no string in suffixes is a suffix of s, return nil.

Given a string s and a sequence of strings, suffixes, return a
vector of 2 strings [x y] where y is the first element of suffixes
that is a suffix of s, and (str x y)=s.  If no string in suffixes is
a suffix of s, return nil.
raw docstring

sorted-map-with-non-keyword-keys?clj

(sorted-map-with-non-keyword-keys? x)

statement-in-try-body?clj

(statement-in-try-body? ast)

static-call?clj

(static-call? ast-node)

string->formsclj

(string->forms s ns include-line-col-metadata?)

Treat a string as a sequence of 0 or more Clojure forms, and read all of them. No line or column number metadata will be attached to the returned forms, but sometimes this is what you want.

Hack alert: In order to be able to correctly interpret keywords of the form ::name or ::ns-or-ns-alias/name, you should pass in a namespace to bind to the ns var during this function's reading of s. The assumption is that this namespace and those it requires are already loaded before this function is called, and any aliases used by keywords are already set up. It also assumes that the entire string is in that same namespace. Fortunately, this is pretty common for most Clojure code as written today.

Treat a string as a sequence of 0 or more Clojure forms, and read
all of them.  No line or column number metadata will be attached to
the returned forms, but sometimes this is what you want.

Hack alert: In order to be able to correctly interpret keywords of
the form ::name or ::ns-or-ns-alias/name, you should pass in a
namespace to bind to the *ns* var during this function's reading of
s.  The assumption is that this namespace and those it requires are
already loaded before this function is called, and any aliases used
by keywords are already set up.  It also assumes that the entire
string is in that same namespace.  Fortunately, this is pretty
common for most Clojure code as written today.
raw docstring

subforms-with-first-in-setclj

(subforms-with-first-in-set form sym-set)

timeitcljmacro

(timeit expr)

Evaluates expr and returns a vector containing the expression's return value followed by the time it took to evaluate in millisec.

Evaluates expr and returns a vector containing the expression's
return value followed by the time it took to evaluate in millisec.
raw docstring

trim-astclj

(trim-ast ast action key-set)

var-to-fqsymclj

(var-to-fqsym v)

walkclj

(walk inner outer form)

Traverses form, an arbitrary data structure. inner and outer are functions. Applies inner to each element of form, building up a data structure of the same type, then applies outer to the result. Recognizes all Clojure data structures. Consumes seqs as with doall.

walk was copied from Clojure 1.6.0, and then modified to preserve metadata on all sub-values of the input form that have them. Note that this metadata is 'put back on' after the function inner has already been called, but before outer, so only outer has a chance to change it.

Traverses form, an arbitrary data structure.  inner and outer are
functions.  Applies inner to each element of form, building up a
data structure of the same type, then applies outer to the result.
Recognizes all Clojure data structures. Consumes seqs as with doall.

walk was copied from Clojure 1.6.0, and then modified to preserve
metadata on all sub-values of the input form that have them.  Note
that this metadata is 'put back on' after the function inner has
already been called, but before outer, so only outer has a chance to
change it.
raw docstring

with-out-str2cljmacro

(with-out-str2 & body)

Like with-out-str, but returns a map m. (:val m) is the return value of the last expression in the body. (:out m) is the string normally returned by with-out-str. (:err m) is the string that would be returned by with-out-str if it bound err instead of out to a StringWriter.

Like with-out-str, but returns a map m.  (:val m) is the return
value of the last expression in the body.  (:out m) is the string
normally returned by with-out-str.  (:err m) is the string that would
be returned by with-out-str if it bound *err* instead of *out* to a
StringWriter.
raw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close