ClojureScript admission for Plumatic Schema declarations.
Mirrors skeptic.schema.collect/ns-schema-results for cljs source files.
Operates on per-form analyzed ASTs from skeptic.cljs.analyzer-driver.
Reads alias requires from the parsed ns AST (output of
cljs.analyzer.api/parse-ns). The cljs analyzer does not attach the
s/defn :schema/:arglists Var-metadata to the :def AST node, so the
schema forms are read directly from the macroexpansion's :let binding
init forms (output-schema* / input-schema*); the single-arity arglist is
reconstructed from the s/one arg-name labels in the input-schema form. No
cenv reads, no caller-managed compiler state.
Three top-level shapes are recognized:
s/def :op :let, single binding output-schema__*__auto__,
inner :def at [:body :ret].s/defschema :op :def, :init :form starts with vary-meta.s/defn :op :let, multi-binding outer let with output-schema*
and input-schema* gensyms.Each output-schema* / input-schema* binding init is a symbolic schema
form (the cljs analyzer does not evaluate JVM-side); resolution to a real
Schema record goes through skeptic.cljs.schema-interpreter, which
interprets the form in a sci-sandboxed context that exposes only
schema.core.
ClojureScript admission for Plumatic Schema declarations.
Mirrors `skeptic.schema.collect/ns-schema-results` for cljs source files.
Operates on per-form analyzed ASTs from `skeptic.cljs.analyzer-driver`.
Reads alias requires from the parsed ns AST (output of
`cljs.analyzer.api/parse-ns`). The cljs analyzer does not attach the
`s/defn` `:schema`/`:arglists` Var-metadata to the `:def` AST node, so the
schema forms are read directly from the macroexpansion's `:let` binding
init forms (`output-schema*` / `input-schema*`); the single-arity arglist is
reconstructed from the `s/one` arg-name labels in the input-schema form. No
cenv reads, no caller-managed compiler state.
Three top-level shapes are recognized:
- `s/def` :op :let, single binding `output-schema__*__auto__`,
inner :def at [:body :ret].
- `s/defschema` :op :def, :init :form starts with vary-meta.
- `s/defn` :op :let, multi-binding outer let with `output-schema*`
and `input-schema*` gensyms.
Each `output-schema*` / `input-schema*` binding init is a symbolic schema
form (the cljs analyzer does not evaluate JVM-side); resolution to a real
Schema record goes through `skeptic.cljs.schema-interpreter`, which
interprets the form in a sci-sandboxed context that exposes only
`schema.core`.Bound to the active cljs namespace's :requires map (alias-sym → ns-sym)
for the duration of ns-schema-results-cljs. Used by resolve-aliases
to rewrite s/Int → schema.core/Int before JVM eval.
Bound to the active cljs namespace's `:requires` map (alias-sym → ns-sym) for the duration of `ns-schema-results-cljs`. Used by `resolve-aliases` to rewrite `s/Int` → `schema.core/Int` before JVM eval.
(ns-schema-results-cljs ns-ast source-file ns-sym top-level-asts)Inputs: [ns-ast :- aas/AnnotatedNode source-file :- s/Any ns-sym :- s/Symbol top-level-asts :- [aas/AnnotatedNode]] Returns: scs/SchemaAdmissionResult
Per-namespace Plumatic Schema admission for cljs sources.
Inputs:
ns-ast: the parsed ns AST produced on the worker by
skeptic.worker.analyzer-cljs/analyze-source-file (the :ns-ast of the
analyze-cljs-namespace reply). Provides :requires
(alias→target map) for alias rewriting before JVM eval of schema forms.source-file: the cljs source file, attached to error results.ns-sym: the namespace symbol.top-level-asts: per-form analyzed ASTs for the file's top-level
forms (from analyzer-driver/analyze-form).Inputs: [ns-ast :- aas/AnnotatedNode source-file :- s/Any ns-sym :- s/Symbol top-level-asts :- [aas/AnnotatedNode]] Returns: scs/SchemaAdmissionResult Per-namespace Plumatic Schema admission for cljs sources. Inputs: - `ns-ast`: the parsed ns AST produced on the worker by `skeptic.worker.analyzer-cljs/analyze-source-file` (the `:ns-ast` of the `analyze-cljs-namespace` reply). Provides `:requires` (alias→target map) for alias rewriting before JVM eval of schema forms. - `source-file`: the cljs source file, attached to error results. - `ns-sym`: the namespace symbol. - `top-level-asts`: per-form analyzed ASTs for the file's top-level forms (from `analyzer-driver/analyze-form`).
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |