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) and Var metadata directly from each
:def AST node's [:var :info :meta] slot — 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.The cljs :meta :schema value is a symbolic 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`) and Var metadata directly from each
`:def` AST node's `[:var :info :meta]` slot — 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.
The cljs `:meta :schema` value is a symbolic 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 from
skeptic.cljs.analyzer-driver/parse-source-ns. 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 from `skeptic.cljs.analyzer-driver/parse-source-ns`. 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 |