Code generation
Summary
Context-aware Code Generation is a unique feature that allows the tool to selectively use the content of the entire input source file to generate code. Context can be created out of fields, method names, parameters, and documentation. Providing additional information like constraints or exception declaration can help the model to generate more accurate results.
Example
To use the code generation feature create a new file. As an example of code generation of Java programming language, we will use a class name PaymentDao.
Notice that the code defines a set of methods and two fields logger
and session
.
Generating code
In the provided example the source file defines a class with a set of methods. CodeMaker AI can process the entire file and generate the code for any method or function that has an empty body.
Generating code using Visual Studio Code
Generating code using JetBrains IDE
Generating code using CodeMaker CLI
Executed command in the terminal:
codemaker generate code **/PaymentDao.java
Replacing code
Similarly to generating code, it is possible to replace all method or function definitions across the entire file. In such case, the provided documentation will be used to generate the method function body.
Replacing documentation using Visual Studio Code
Right-click in the editor and from the context menu choose CodeMaker AI > Replace > Code.
Replacing documentation using JetBrains IDE
Right-click in the editor and from the context menu choose CodeMaker AI > Replace > Code.
Replacing documentation using CodeMaker CLI
Executed command in the terminal:
codemaker generate code --replace=true **/PaymentDao.java
Last updated