Liking cljdoc? Tell your friends :D

eastwood.util


all-children-vectorsclj

(all-children-vectors asts)
source

allow-warningclj

(allow-warning w opt)
source

allow-warning-based-on-enclosing-macrosclj

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

assert-keysclj

(assert-keys m key-seq)
source

ast-expands-macroclj

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

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.
sourceraw docstring

builtin-config-to-resourceclj

(builtin-config-to-resource name)
source

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.
sourceraw docstring

clean-astclj

(clean-ast ast & kws)
source

clojure-1-6-or-laterclj

(clojure-1-6-or-later)
source

clojure-1-7-or-laterclj

(clojure-1-7-or-later)
source

clojure-1-8-or-laterclj

(clojure-1-8-or-later)
source

clojure-1-9-or-laterclj

(clojure-1-9-or-later)
source

contains-loc-info?clj

(contains-loc-info? x)
source

debug-warningclj

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

debug?clj

(debug? debug-options opt)
source

deftype-for-fieldless-defrecordclj

(deftype-for-fieldless-defrecord ast)
source

disable-warningclj

(disable-warning m)
source

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.
sourceraw docstring

elide-metaclj

(elide-meta form elide-key-set)
source

empty-enclosing-macro-mapclj

source

enclosing-macrosclj

(enclosing-macros ast)
source

enhance-extend-argsclj

(enhance-extend-args extend-args)
source

enhance-extend-invocationsclj

(enhance-extend-invocations ast)
source

enhance-extend-invocations-prewalkclj

(enhance-extend-invocations-prewalk ast)
source

expr-in-try-body?clj

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

extend-invocation-ast?clj

(extend-invocation-ast? ast)
source

filter-keysclj

(filter-keys f m)
source

filter-valsclj

(filter-vals f m)
source

fqsym-of-raw-formclj

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

get-fn-in-defclj

(get-fn-in-def expr)
source

get-in-astclj

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

get-val-in-map-astclj

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

has-keys?clj

(has-keys? m key-seq)
source

init-warning-enable-configclj

(init-warning-enable-config opt)
source

inside-fieldless-defrecordclj

(inside-fieldless-defrecord ast)
source

interface?clj

(interface? obj)
source

invoke-expr?clj

(invoke-expr? ast-node)
source

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.
sourceraw docstring

longest-common-prefixclj

(longest-common-prefix s1 s2)
source

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.
sourceraw docstring

map-keysclj

(map-keys f m)
source

map-valsclj

(map-vals f m)
source

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.
sourceraw docstring

meets-suppress-conditionclj

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

min-clojure-versionclj

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

nil-safe-rseqclj

(nil-safe-rseq s)
source

ns-form-astsclj

(ns-form-asts asts)
source

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.
sourceraw docstring

op=clj

(op= op)
source

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.
sourceraw 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.
sourceraw docstring

pprint-ast-nodeclj

(pprint-ast-node ast & kws)
source

pprint-formclj

(pprint-form form)
source

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
sourceraw docstring

pprint-meta-elidedclj

(pprint-meta-elided form)
source

prewalkclj

(prewalk f form)

Like postwalk, but does pre-order traversal.

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

(print-enclosing-macros ast)
source

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

process-configsclj

(process-configs warning-enable-config)
source

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.
sourceraw 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.
sourceraw docstring

regex?clj

(regex? x)
source

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.
sourceraw 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.
sourceraw docstring

replace-comments-and-quotes-with-nilclj

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

replace-subforms-with-first-in-setclj

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

ret-expr-in-try-body?clj

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

safe-firstclj

(safe-first f)
source

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.
sourceraw docstring

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

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

statement-in-try-body?clj

(statement-in-try-body? ast)
source

static-call?clj

(static-call? ast-node)
source

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.
sourceraw docstring

subforms-with-first-in-setclj

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

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.
sourceraw docstring

trim-astclj

(trim-ast ast action key-set)
source

var-to-fqsymclj

(var-to-fqsym v)
source

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.
sourceraw 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.
sourceraw docstring

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

× close