API for cljs.analyzer - clojurescript


Full namespace name: cljs.analyzer

Overview





Public Variables and Functions



aliasable-clj-ns?

function
Usage: (aliasable-clj-ns? sym)
Predicate for testing with a symbol represents an aliasable clojure namespace.

    
    
    
  


analyze

function
Usage: (analyze env form)
       (analyze env form name)
       (analyze env form name opts)
Given an environment, a map containing {:locals (mapping of names to bindings), :context
(one of :statement, :expr, :return), :ns (a symbol naming the
compilation ns)}, and form, returns an expression object (a map
containing at least :form, :op and :env keys). If expr has any (immediately)
nested exprs, must have :children [exprs...] entry. This will
facilitate code walking without knowing the details of the op set.

    
    
    
  


analyze-deps

function
Usage: (analyze-deps lib deps env)
       (analyze-deps lib deps env opts)
Given a lib, a namespace, deps, its dependencies, env, an analysis environment
and opts, compiler options - analyze all of the dependencies. Required to
correctly analyze usage of other namespaces.

    
    
    
  


analyze-file

function
Usage: (analyze-file f)
       (analyze-file f opts)
       (analyze-file f skip-cache opts)
Given a java.io.File, java.net.URL or a string identifying a resource on the
classpath attempt to analyze it.

This function side-effects the ambient compilation environment
`cljs.env/*compiler*` to aggregate analysis information. opts argument is
compiler options, if :cache-analysis true will cache analysis to
":output-dir/some/ns/foo.cljs.cache.edn". This function does not return a
meaningful value.

    
    
    
  


analyze-symbol

function
Usage: (analyze-symbol env sym)
Finds the var associated with sym

    
    
    
  


cache-file

function
Usage: (cache-file src)
       (cache-file src output-dir)
       (cache-file src ns-info output-dir)
       (cache-file src ns-info output-dir mode)
Given a ClojureScript source file returns the read/write path to the analysis
cache file. Defaults to the read path which is usually also the write path.

    
    
    
  


clj-ns->cljs-ns

function
Usage: (clj-ns->cljs-ns sym)
Given a symbol that starts with clojure as the first segment return the
same symbol with the first segment replaced with cljs

    
    
    
  


confirm-bindings

function
Usage: (confirm-bindings env names)
Given env, an analysis environment env, and names, a list of symbols, confirm
that all correspond to declared dynamic vars.

    
    
    
  


confirm-ns

function
Usage: (confirm-ns env ns-sym)
Given env, an analysis environment, and ns-sym, a symbol identifying a
namespace, confirm that the namespace exists. Warn if not found.

    
    
    
  


core-name?

function
Usage: (core-name? env sym)
Is sym visible from core in the current compilation namespace?

    
    
    
  


desugar-ns-specs

function
Usage: (desugar-ns-specs args)
Given an original set of ns specs desugar :include-macros and :refer-macros
usage into only primitive spec forms - :use, :require, :use-macros,
:require-macros. If a library includes a macro file of with the same name
as the namespace will also be desugared.

    
    
    
  


empty-env

function
Usage: (empty-env)
Construct an empty analysis environment. Required to analyze forms.

    
    
    
  


forms-seq

function
Usage: (forms-seq f)
       (forms-seq f filename)
       (forms-seq f filename return-reader?)
DEPRECATED: Seq of Clojure/ClojureScript forms from [f], which can be anything
for which `clojure.java.io/reader` can produce a `java.io.Reader`. Optionally
accepts a [filename] argument, which the reader will use in any emitted errors.

    
    
    
  


forms-seq*

function
Usage: (forms-seq* rdr)
       (forms-seq* rdr filename)
Seq of Clojure/ClojureScript forms from rdr, a java.io.Reader. Optionally
accepts a filename argument which will be used in any emitted errors.

    
    
    
  


get-expander

function
Usage: (get-expander sym env)
Given a sym, a symbol identifying a macro, and env, an analysis environment
return the corresponding Clojure macroexpander.

    
    
    
  


infer-tag

function
Usage: (infer-tag env e)
Given env, an analysis environment, and e, an AST node, return the inferred
type of the node

    
    
    
  


intern-macros

function
Usage: (intern-macros ns)
       (intern-macros ns reload)
Given a Clojure namespace intern all macros into the ambient ClojureScript
analysis environment.

    
    
    
  


loaded-js-ns?

function
Usage: (loaded-js-ns? env prefix)
Check if a JavaScript namespace has been loaded. JavaScript vars are
not currently checked.

    
    
    
  


locate-src

function
Usage: (locate-src ns)
Given a namespace return the corresponding ClojureScript (.cljs or .cljc)
resource on the classpath or file from the root of the build.

    
    
    
  


macro-autoload-ns?

function
Usage: (macro-autoload-ns? form)
Given a spec form check whether the spec namespace requires a macro file
of the same name. If so return true.

    
    
    
  


macroexpand-1

function
Usage: (macroexpand-1 env form)
Given a env, an analysis environment, and form, a ClojureScript form,
macroexpand the form once.

    
    
    
  


parse-ns

function
Usage: (parse-ns src)
       (parse-ns src opts)
       (parse-ns src dest opts)
Helper for parsing only the essential namespace information from a
ClojureScript source file and returning a cljs.closure/IJavaScript compatible
map _not_ a namespace AST node.

By default does not load macros or perform any analysis of dependencies. If
opts parameter provided :analyze-deps and :load-macros keys their values will
be used for *analyze-deps* and *load-macros* bindings respectively. This
function does _not_ side-effect the ambient compilation environment unless
requested via opts where :restore is false.

    
    
    
  


requires-analysis?

function
Usage: (requires-analysis? src)
       (requires-analysis? src output-dir)
       (requires-analysis? src cache output-dir)
Given a src, a resource, and output-dir, a compilation output directory
return true or false depending on whether src needs to be (re-)analyzed.
Can optionally pass cache, the analysis cache file.

    
    
    
  


resolve-existing-var

function
Usage: (resolve-existing-var env sym)
Given env, an analysis environment, and sym, a symbol, resolve an existing var.
Emits a warning if no such var exists.

    
    
    
  


resolve-macro-var

function
Usage: (resolve-macro-var env sym)
Given env, an analysis environment, and sym, a symbol, resolve a macro.

    
    
    
  


resolve-var

function
Usage: (resolve-var env sym)
       (resolve-var env sym confirm)
Resolve a var. Accepts a side-effecting confirm fn for producing
warnings about unresolved vars.

    
    
    
  


rewrite-cljs-aliases

function
Usage: (rewrite-cljs-aliases args)
Alias non-existing clojure.* namespaces to existing cljs.* namespaces if
possible.

    
    
    
  

cljs.analyzer.api

This is intended to be a stable api for those who need programmatic access
to the analyzer.

Public Variables and Functions



all-ns

function
Usage: (all-ns)
       (all-ns state)
Return all namespaces. Analagous to clojure.core/all-ns but
returns symbols identifying namespaces not Namespace instances.

    
    
    
  


analyze

function
Usage: (analyze env form)
       (analyze env form name)
       (analyze env form name opts)
       (analyze state env form name opts)
Given an environment, a map containing {:locals (mapping of names to bindings), :context
(one of :statement, :expr, :return), :ns (a symbol naming the
compilation ns)}, and form, returns an expression object (a map
containing at least :form, :op and :env keys). If expr has any (immediately)
nested exprs, must have :children [exprs...] entry. This will
facilitate code walking without knowing the details of the op set.

    
    
    
  


analyze-file

function
Usage: (analyze-file f)
       (analyze-file f opts)
       (analyze-file state f opts)
Given a java.io.File, java.net.URL or a string identifying a resource on the
   classpath attempt to analyze it.

   This function side-effects the ambient compilation environment
   `cljs.env/*compiler*` to aggregate analysis information. opts argument is
   compiler options, if :cache-analysis true will cache analysis to
   ":output-dir/some/ns/foo.cljs.cache.edn". This function does not return a
   meaningful value.

    
    
    
  


default-warning-handler

function
Usage: (default-warning-handler warning-type env extra)
The default warning handler.

Outputs the warning messages to *err*.

    
    
    
  


empty-env

function
Usage: (empty-env)
Creates an empty analysis environment.

    
    
    
  


empty-state

function
Usage: (empty-state)
Creates an empty compilation state Atom<Map>.

    
    
    
  


find-ns

function
Usage: (find-ns sym)
       (find-ns state sym)
Given a namespace return the corresponding namespace analysis map. Analagous
to clojure.core/find-ns.

    
    
    
  


forms-seq

function
Usage: (forms-seq rdr)
       (forms-seq rdr filename)
Seq of Clojure/ClojureScript forms from rdr, a java.io.Reader. Optionally
accepts a filename argument which will be used in any emitted errors.

    
    
    
  


get-js-index

function
Usage: (get-js-index)
       (get-js-index state)
Return the currently computed Google Closure js dependency index from the
compiler state.

    
    
    
  


get-options

function
Usage: (get-options)
       (get-options state)
Return the compiler options from compiler state.

    
    
    
  


in-cljs-user

macro
Usage: (in-cljs-user env & body)
Binds cljs.analyzer/*cljs-ns* to 'cljs.user and uses the given compilation
environment atom and runs body.

    
    
    
  


no-warn

macro
Usage: (no-warn & body)
Disable analyzer warnings for any analysis executed in body.

    
    
    
  


ns-interns

function
Usage: (ns-interns ns)
       (ns-interns state ns)
Given a namespace return all the var analysis maps. Analagous to
clojure.core/ns-interns but returns var analysis maps not vars.

    
    
    
  


ns-publics

function
Usage: (ns-publics ns)
       (ns-publics state ns)
Given a namespace return all the public var analysis maps. Analagous to
clojure.core/ns-publics but returns var analysis maps not vars.

    
    
    
  


ns-resolve

function
Usage: (ns-resolve ns sym)
       (ns-resolve state ns sym)
Given a namespace and a symbol return the corresponding var analysis map.
Analagous to clojure.core/ns-resolve but returns var analysis map not Var.

    
    
    
  


parse-ns

function
Usage: (parse-ns src)
       (parse-ns src opts)
       (parse-ns src dest opts)
       (parse-ns state src dest opts)
Helper for parsing only the essential namespace information from a
   ClojureScript source file and returning a cljs.closure/IJavaScript compatible
   map _not_ a namespace AST node.

   By default does not load macros or perform any analysis of dependencies. If
   opts parameter provided :analyze-deps and :load-macros keys their values will
   be used for *analyze-deps* and *load-macros* bindings respectively. This
   function does _not_ side-effect the ambient compilation environment unless
   requested via opts where :restore is false.

    
    
    
  


remove-ns

function
Usage: (remove-ns ns)
       (remove-ns state ns)
Removes the namespace named by the symbol.

    
    
    
  


resolve

function
Usage: (resolve env sym)
Given an analysis environment resolve a var. Analogous to
clojure.core/resolve

    
    
    
  


warning-enabled?

function
Usage: (warning-enabled? warning-type)
Test if the given warning-type is enabled.

    
    
    
  


with-state

macro
Usage: (with-state state body)
Run the body with the given compilation state Atom<Map>.

    
    
    
  
Logo & site design by Tom Hickey.
Clojure auto-documentation system by Tom Faulhaber.