The example below demonstrates how a simple code snippet can be built using JDT Core. It also
demonstrates how to create the same snippet using Fluentast.
You can find additional examples in
the docs or in the demo project on Github.
There are a number of options out there to programmatically create Java code. Most notably, there is Javapoet.
However, sometimes you just can't help using JDT. Maybe you are developing an Eclipse plugin? Maybe you want to leverage one of the numerous features of JDT?
Either way, if you are stuck with JDT, you will have to be prepared to do lots of typing. Or, you know, just use Fluentast and save you some hassle. I mean, have you looked at the example above?
Supported Elements
The most common syntax elements, such as if-statements, loops, variable assignments and so forth are supported. However, there might still be some missing.
For an overview of supported syntax elements please see the supported syntax elements documentation.
Additional Features
Creating an abstract syntax tree is still to cumbersome? You may simple add blocks and statements as strings and mix them with other fluent elements.
Have a look at the demo project.
Contributions Welcome
There is still a lot of work to do. Add fluent interfaces for not-yet supported types or even add entirely new capabilities: Your contributions are
certainly welcome! Have a look at the repository.