Provides main parsing and conversion functions.
For parsing java sources, see read-java
. For generating java sources,
see ->ast
and ->ast*
.
If you want to extend the library to handle your data, see Ast
for
parsing and new-ast
, fill-ast!
and ast-default
for generating.
Provides main parsing and conversion functions. For parsing java sources, see `read-java`. For generating java sources, see `->ast` and `->ast*`. If you want to extend the library to handle your data, see `Ast` for parsing and `new-ast`, `fill-ast!` and `ast-default` for generating.
(->ast data hint & type-parameters)
Convert a clojure data structure to a javaparser object.
Arguments:
data
: the data to convert.
hint
: the type to convert to. In case you want an entire java file,
it's :compilation-unit
.
type-parameters
: information about generic arguments of the output.
Consider this an implementation detail, you probably
don't need it.
Convert a clojure data structure to a javaparser object. Arguments: `data` : the data to convert. `hint` : the type to convert to. In case you want an entire java file, it's `:compilation-unit`. `type-parameters` : information about generic arguments of the output. Consider this an implementation detail, you probably don't need it.
(->ast* data)
Convert a clojure data structure to a javaparser object.
Unlike ->ast
, the type information must be embedded in data
, under
:node/kind
. If you've obtained data
from read-java
, it will be present
on most nodes.
Convert a clojure data structure to a javaparser object. Unlike `->ast`, the type information must be embedded in `data`, under `:node/kind`. If you've obtained `data` from `read-java`, it will be present on most nodes.
Conversion from a javaparser's AST representation to a clojure data structure.
Javaparser's classes are aggressively mutable, but it is expected that this protocol will not change the inputs in any way.
Conversion from a javaparser's AST representation to a clojure data structure. Javaparser's classes are aggressively mutable, but it is expected that this protocol will not change the inputs in any way.
(ast->data this)
Convert an AST node (or its field) to its clojure form.
Convert an AST node (or its field) to its clojure form.
Return a default value for the given type-hint
.
Signature: [type-hint & type-parameters]
This method will be called (if defined) when there is no field in the
source map to convert with new-ast
and fill-ast!
combo. Normally
in this case nil
would be written, but it may not be always correct.
Return a default value for the given `type-hint`. Signature: `[type-hint & type-parameters]` This method will be called (if defined) when there is no field in the source map to convert with `new-ast` and `fill-ast!` combo. Normally in this case `nil` would be written, but it may not be always correct.
An atom containing a hierarchy of java AST classes and their keyword shorthands.
An atom containing a hierarchy of java AST classes and their keyword shorthands.
Fill a javaparser object with data
based on type-hint
.
Signature: [ast data type-hint & type-parameters]
type-hint
(and, if present and relevant, type-parameters
) determines,
how ast
will be modified.
This method is expected to mutate ast
in place. It may or may not return
it (the core library doesn't require it), but returning it would be nice.
This is an implementation detail. Unless you're extending javaparser-clj,
you probably want ->ast*
or ->ast
.
Fill a javaparser object with `data` based on `type-hint`. Signature: `[ast data type-hint & type-parameters]` `type-hint` (and, if present and relevant, `type-parameters`) determines, how `ast` will be modified. This method is expected to mutate `ast` in place. It may or may not return it (the core library doesn't require it), but returning it would be nice. This is an implementation detail. Unless you're extending javaparser-clj, you probably want `->ast*` or `->ast`.
(name->str n)
Convert a fully-qualified name to its string form
Convert a fully-qualified name to its string form
Create a new javaparser object from data
based on type-hint
.
Signature: [data type-hint & type-parameters]
type-hint
(and, if present and relevant, type-parameters
) determines
which class will be output.
This method is expected to set the bare minimum of fields on the output
object (or none at all and just call a ctor), leaving the rest to
fill-ast!
.
This is an implementation detail. Unless you're extending javaparser-clj,
you probably want ->ast*
or ->ast
.
Create a new javaparser object from `data` based on `type-hint`. Signature: `[data type-hint & type-parameters]` `type-hint` (and, if present and relevant, `type-parameters`) determines which class will be output. This method is expected to set the bare minimum of fields on the output object (or none at all and just call a ctor), leaving the rest to `fill-ast!`. This is an implementation detail. Unless you're extending javaparser-clj, you probably want `->ast*` or `->ast`.
(read-java in)
Read a java source from in
and parse it into a clojure map.
Arguments:
in
: a java.io.Reader
to read source from.
Read a java source from `in` and parse it into a clojure map. Arguments: `in` : a `java.io.Reader` to read source from.
(strip-ranges j)
Strip all range information from the parsed java structure
Strip all range information from the parsed java structure
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close