All Projects → x-hansong → Codemaker

x-hansong / Codemaker

Licence: apache-2.0
A idea-plugin for Java/Scala, support custom code template.

Programming Languages

java
68154 projects - #9 most used programming language
scala
5932 projects

Projects that are alternatives of or similar to Codemaker

Loopy
A code generator for array-based code on CPUs and GPUs
Stars: ✭ 367 (-16.59%)
Mutual labels:  code-generation, code-generator
nunavut
Generate code from DSDL using PyDSDL and Jinja2
Stars: ✭ 23 (-94.77%)
Mutual labels:  code-generator, code-generation
php-json-schema-model-generator
Creates (immutable) PHP model classes from JSON-Schema files including all validation rules as PHP code
Stars: ✭ 36 (-91.82%)
Mutual labels:  code-generator, code-generation
mr.boilerplate
Online app to generate Scala boilerplate
Stars: ✭ 32 (-92.73%)
Mutual labels:  code-generator, code-generation
php-code-generator
PHP code generator library
Stars: ✭ 144 (-67.27%)
Mutual labels:  code-generator, code-generation
GraphQL.Tools
GraphQL.Tools is a GraphQL to C# compiler (code-generator) which turns your GraphQL schema into a set of C# classes, interfaces, and enums.
Stars: ✭ 49 (-88.86%)
Mutual labels:  code-generator, code-generation
Kodgen
C++17 parser and code generator
Stars: ✭ 19 (-95.68%)
Mutual labels:  code-generator, code-generation
kube-code-generator
Kubernetes code generator docker image
Stars: ✭ 60 (-86.36%)
Mutual labels:  code-generator, code-generation
qm
QM model-based design tool and code generator based on UML state machines
Stars: ✭ 54 (-87.73%)
Mutual labels:  code-generator, code-generation
autogenu-jupyter
An automatic code generator for nonlinear model predictive control (NMPC) and the continuation/GMRES method (C/GMRES) based numerical solvers for NMPC
Stars: ✭ 89 (-79.77%)
Mutual labels:  code-generator, code-generation
typed-astunparse
Python 3 AST unparser with type comments support.
Stars: ✭ 27 (-93.86%)
Mutual labels:  code-generator, code-generation
Xmlschemaclassgenerator
Generate C# classes from XML Schema files
Stars: ✭ 277 (-37.05%)
Mutual labels:  code-generation, code-generator
tiles
Programmatic code generation
Stars: ✭ 78 (-82.27%)
Mutual labels:  code-generator, code-generation
Javaparser
Java 1-15 Parser and Abstract Syntax Tree for Java, including preview features to Java 13
Stars: ✭ 3,972 (+802.73%)
Mutual labels:  code-generation, code-generator
EasyEE-Auto
EasyEE 自动化代码生成器。EasyEE Automated code generator.
Stars: ✭ 39 (-91.14%)
Mutual labels:  code-generator, code-generation
copygen
Go generator to copy values from type to type and fields from struct to struct (copier without reflection). Generate any code based on types.
Stars: ✭ 121 (-72.5%)
Mutual labels:  code-generator, code-generation
oag
Idiomatic Go (Golang) client package generation from OpenAPI documents
Stars: ✭ 51 (-88.41%)
Mutual labels:  code-generator, code-generation
django-code-generator
Generate code from your Django models for faster development
Stars: ✭ 35 (-92.05%)
Mutual labels:  code-generator, code-generation
molicode
molicode
Stars: ✭ 75 (-82.95%)
Mutual labels:  code-generator, code-generation
Efdesigner
Entity Framework visual design surface and code-first code generation for EF6, Core and beyond
Stars: ✭ 256 (-41.82%)
Mutual labels:  code-generation, code-generator

CodeMaker

A idea-plugin for Java/Scala to generate code, support custom code template.

demonstration

This plugin generates code from right click 'Generate...' menu while focused on a Java/Scala class. The output class can be customized using a provided velocity template to format the code based on the origin class and optional selected classes. There are many features are contributed by Dmitry Karlinsky and I appreciate that.

The following features are available:

  • Support add custom template to generate more code.(Velocity templates and groovy templates)
  • Generate the model class for the persistent class.
  • Generate the converter class for the model class and the persistent class.
  • Generate @see doc for override method.
  • Support Scala.
  • Generate api table from code

Install

Option 1

  • Search 'CodeMaker' in Idea plugins repository.

Option 2

Download Releases

To install a plugin from the disk in idea

  1. Open the Settings/Preferences dialog box and select Plugins on the left pane.
  2. On the right pane of the dialog, click the Install plugin from disk button.
  3. In the dialog that opens, select the desired plugin. You can quickly locate and select the necessary file if you drag-and-drop the corresponding item from your file browser (Explorer, Finder, etc.) into the area where the tree is shown. Click OK to proceed.
  4. Click Apply button of the Settings/Preferences dialog.
  5. Following the system prompt that appears, restart IntelliJ IDEA to activate the installed plugin, or postpone it, at your choice.

Usage

This plugin generates code from right click 'Generate...' menu while focused on a Java/Scala class. Generate

The plugin support multiple class to generate one code, you can set the class number of template to select multiple classes to use.

select class

Configuration

configure

  • Add template: click "Add Template" button to add a template, after saving changes.
  • Delete template: click "Delete Template" button to delete a template.

property

  • classNumber: The template context will contain the class which user select when trigger the generate action. for example, the number is 1, the template context only has the focused class: $class0; if the number is 2, when you trigger the generate action, you need select a class, then the template context will have two class entry: $class0, $class1
  • className: The class name support velocity and the template context.

Template Context

########################################################################################
##
## Common variables:
##  $YEAR - yyyy
##  $TIME - yyyy-MM-dd HH:mm:ss
##  $USER - user.name
##
## Available variables:
##  $class0 - the context class, alias: $class
##  $class1 - the selected class, like $class1, $class2
##  $ClassName - generate by the config of "Class Name", the generated class name
##
## Class Entry Structure:
##  $class0.className - the class Name
##  $class0.packageName - the packageName
##  $class0.importList - the list of imported classes name
##  $class0.fields - the list of the class fields
##          - type: the field type
##          - name: the field name
##          - modifier: the field modifier, like "private",or "@Setter private" if include annotations
##  $class0.allFields - the list of the class fields include all fields of superclass
##          - type: the field type
##          - name: the field name
##          - modifier: the field modifier, like "private",or "@Setter private" if include annotations
##  $class0.methods - the list of class methods
##          - name: the method name
##          - modifier: the method modifier, like "private static"
##          - returnType: the method returnType
##          - params: the method params, like "(String name)"
##  $class0.allMethods - the list of class methods include all methods of superclass
##          - name: the method name
##          - modifier: the method modifier, like "private static"
##          - returnType: the method returnType
##          - params: the method params, like "(String name)"#
########################################################################################

Advance

If you want to add variables into template context, you can modified the source and package the plugin to meet your needs.

The injection of template context is executed by com.xiaohansong.codemaker.action.CodeMakerAction.generateCode

private String generateCode(CodeTemplate codeTemplate, List<ClassEntry> selectClasses) {
        Map<String, Object> map = new HashMap<>();
        for (int i = 0; i < selectClasses.size(); i++) {
            map.put("class" + i, selectClasses.get(i));
        }
        Date now = new Date();
        map.put("class", selectClasses.get(0));
        map.put("YEAR", DateFormatUtils.format(now, "yyyy"));
        map.put("TIME", DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
        map.put("USER", System.getProperty("user.name"));
        String className = VelocityUtil.evaluate(codeTemplate.getClassNameVm(), map);
        map.put("ClassName", className);
        map.put("utils", new Utils());
        map.put("BR", "\n");

        return VelocityUtil.evaluate(codeTemplate.getCodeTemplate(), map);
    }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].