(analyze-file source-path & {:keys [reader opt]})
Takes a file path and optionally a pushback reader. Returns a map with at least the following keys:
:forms - a sequence of forms as read in, with any forms within a top-level do, or do forms nested within a top-level do, 'flattened' to the top level themselves. This sequence will include all forms in the file, as far as the file could be successfully read, even if an exception was thrown earlier than that during analysis or evaluation of the forms.
:asts - a sequence of ASTs of the forms that were successfully analyzed without exception. They correspond one-to-one with forms in the :forms sequence.
:exception - nil if no exception occurred. An Exception object if an exception was thrown during analysis, emit-form, or eval.
If :exception is not nil, then the following keys will also be part of the returned map:
:exception-phase - If an exception was thrown, this is a keyword indicating in what portion of analyze-file's operation this exception occurred. Always :analyze+eval or :eval
:exception-form - If an exception was thrown, the current form being processed when the exception occurred.
Options:
eg. (analyze-file "my/ns.clj" :opt {:debug-all true})
Takes a file path and optionally a pushback reader. Returns a map with at least the following keys: :forms - a sequence of forms as read in, with any forms within a top-level do, or do forms nested within a top-level do, 'flattened' to the top level themselves. This sequence will include all forms in the file, as far as the file could be successfully read, even if an exception was thrown earlier than that during analysis or evaluation of the forms. :asts - a sequence of ASTs of the forms that were successfully analyzed without exception. They correspond one-to-one with forms in the :forms sequence. :exception - nil if no exception occurred. An Exception object if an exception was thrown during analysis, emit-form, or eval. If :exception is not nil, then the following keys will also be part of the returned map: :exception-phase - If an exception was thrown, this is a keyword indicating in what portion of analyze-file's operation this exception occurred. Always :analyze+eval or :eval :exception-form - If an exception was thrown, the current form being processed when the exception occurred. Options: - :reader a pushback reader to use to read the namespace forms - :opt a map of analyzer options - :debug A set of keywords. - :all Enable all of the following debug messages. - :progress Print simple progress messages as analysis proceeds. - :ns Print all namespaces that exist according to (all-ns) before analysis begins, and then only when that set of namespaces changes after each form is analyzed. - :forms Print forms just before analysis, both before and after macroexpanding them. - :forms-pprint Pretty-print forms just before analysis, both before and after macroexpanding them. - :ast Print complete ASTs just after analysis of each form. eg. (analyze-file "my/ns.clj" :opt {:debug-all true})
(analyze-ns source-nsym
&
{:keys [reader opt] :or {reader (pb-reader-for-ns source-nsym)}})
Takes an IndexingReader and a namespace symbol. Returns a map of results of analyzing the namespace. The map contains these keys:
:analyze-results - The value associated with this key is itself a map with the following keys: :namespace - The source-nsym argument to this fn :source - A string containing the source read in from the namespace's source file. :forms - See analyze-file docs for details :asts - See analyze-file :exception, :exception-phase, :exception-form - See analyze-file
Options:
eg. (analyze-ns 'my-ns :opt {} :reader (pb-reader-for-ns 'my.ns))
Takes an IndexingReader and a namespace symbol. Returns a map of results of analyzing the namespace. The map contains these keys: :analyze-results - The value associated with this key is itself a map with the following keys: :namespace - The source-nsym argument to this fn :source - A string containing the source read in from the namespace's source file. :forms - See analyze-file docs for details :asts - See analyze-file :exception, :exception-phase, :exception-form - See analyze-file Options: - :reader a pushback reader to use to read the namespace forms - :opt a map of analyzer options - same as analyze-file. See there. eg. (analyze-ns 'my-ns :opt {} :reader (pb-reader-for-ns 'my.ns))
(asts-with-eval-exception ast)
tools.analyzer.jvm/analyze+eval returns an AST with a :result key being a specific class of Exception object, if an exception occurred while eval'ing the corresponding expression. This is easy to check at the top level of an AST, but since analyze+eval recurses into top-level do forms, analyzing and eval'ing each independently, checking whether any of them threw an exception during eval requires recursing into ASTs with :op equal to :do
tools.analyzer.jvm/analyze+eval returns an AST with a :result key being a specific class of Exception object, if an exception occurred while eval'ing the corresponding expression. This is easy to check at the top level of an AST, but since analyze+eval recurses into top-level do forms, analyzing and eval'ing each independently, checking whether any of them threw an exception during eval requires recursing into ASTs with :op equal to :do
Set of passes that will be run by default on the AST by #'run-passes
Set of passes that will be run by default on the AST by #'run-passes
(pb-reader-for-ns ns-sym)
Returns an IndexingReader for namespace ns-sym
Returns an IndexingReader for namespace ns-sym
(run-passes ast)
Function that will be invoked on the AST tree immediately after it has been constructed, by default set-ups and runs the default passes declared in #'default-passes
Function that will be invoked on the AST tree immediately after it has been constructed, by default set-ups and runs the default passes declared in #'default-passes
(uri-for-ns ns-sym)
Returns a URI representing the namespace. Throws an exception if URI not found.
Returns a URI representing the namespace. Throws an exception if URI not found.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close