Coder Social home page Coder Social logo

codegenerator's Introduction

CodeGenerator

An idea-plugin for code generation, support template customization.

// TODO: add demo

As we know, Intellij had provided useful code generators such as constructors, getter/setters, equals, hashCode, overrides and delegates, etc. And Intellij allows us to apply customized velocity templates for each generator. But we cannot add our own generators.

Code Generator is here to help. Two types of generation are supported here

  • Members(fields/method) based templates, such as serializers, equals, etc.
  • Class based template, such as transformers, converters, etc. Normally new classes are created.

Installation

  1. Search CodeGenerator in Idea plugins
  2. Download zip from from 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. Select the location of the zip file, click OK to continue.
  4. Click Apply button of the Settings/Preferences dialog.
  5. Restart IntelliJ IDEA to activate.

Usage

  1. Go to the Settings/Preferences > Other Settings > CodeGenerator to create a new generator/template.
  2. Right click on your java file, Select Generate > CodeGenerator > [name of your generator] to run the generator.

According to the settings of your generator, there might be dialogs show up asking to select members or classes that's required by your generator.

Pipeline for Generators

Say we want to create a template for generating getters/setters, how will user use your template? An example(the default intellij implementation) is:

  1. A dialog show up listing all the fields that hadn't implement getters/setters yet.
  2. User select the members.
  3. The code is generated using the getter/setter template.

Thus, as a template creator, we need to:

getters-setters-workflow

Here we call it a pipeline for generators. Currently two types of user action are supported:

  1. Member selection: generator user can select fields/methods.
  2. Class selection: generator user can select a class.

Another example is: you might want to create templates that generate convertors between two classes, so that you want the user to select the target class to convert to.

In CodeGenerator, you can create a pipeline with several steps, CodeGenerator will execute the steps sequencially to collect the context variables. Finally generate the code use the template.

pipeline

Member Selection

member-selection

Templates varies on what members it allows for selection, for example:

  • Getters/Setters generator might want user to select only the fields that have no getters/setters implemented.
  • Delegate generators might want user to select the methods that belongs to the field or its super classes.

Thus CodeGenerator allows generator creators to provide the members to select:

  • set availableMembers to provide the members to select.
  • set selectedMembers to select the members initially, not setting it means select all available members.

Also after the selection, the template context will add some more variables:

  • fields1: the selected fields, where 1 is the step postfix;
  • methods1: the selected methods, if any;
  • members1: the selected fields/methods.

Here is an example of the context variables:

context-of-pipeline

Note in the begining, the class0 variable refers to the class entry where user starts code generation.

Class Selection

class-selection

Class selection is much simpler that template creator could specify the initial class to select.

Thanks to

  • CodeMaker: where the idea and part of code comes from.
  • generate-tostring: Offical toString generator. Part of the code comes from it.

codegenerator's People

Contributors

aesy avatar lotabout avatar ramazangirgin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

codegenerator's Issues

Language

I asume its only for Java templates?
We have the same problem in each language with this IDE's. The first time I've seen a negative aspect in Intelli products.

Unable to load settings pane

Hey there, I just installed this plugin (version 1.3.3) into IntelliJ IDEA 2020.1, and unfortunately it seems that something has broken. I can no longer load the settings pane, it just displays a "Loading..." spinner forever. The following error is reported in by the IDE:

cannot create configurable component

java.lang.NullPointerException
	at java.desktop/javax.swing.ImageIcon.<init>(ImageIcon.java:217)
	at me.lotabout.codegenerator.ui.CodeGeneratorConfig.$$$setupUI$$$(CodeGeneratorConfig.java)
	at me.lotabout.codegenerator.ui.CodeGeneratorConfig.<init>(CodeGeneratorConfig.java:40)
	at me.lotabout.codegenerator.ui.CodeGeneratorConfigurable.createComponent(CodeGeneratorConfigurable.java:40)
	at com.intellij.openapi.options.ex.ConfigurableWrapper.createComponent(ConfigurableWrapper.java:162)
	at com.intellij.openapi.options.ex.ConfigurableCardPanel.lambda$createConfigurableComponent$4(ConfigurableCardPanel.java:109)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)
	at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:61)
	at com.intellij.openapi.options.ex.ConfigurableCardPanel.createConfigurableComponent(ConfigurableCardPanel.java:105)
	at com.intellij.openapi.options.ex.ConfigurableCardPanel.lambda$create$0(ConfigurableCardPanel.java:54)
	at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)
	at com.intellij.openapi.application.ReadAction.compute(ReadAction.java:61)
	at com.intellij.openapi.options.ex.ConfigurableCardPanel.create(ConfigurableCardPanel.java:53)
	at com.intellij.openapi.options.newEditor.ConfigurableEditor$1.create(ConfigurableEditor.java:56)
	at com.intellij.openapi.options.newEditor.ConfigurableEditor$1.create(ConfigurableEditor.java:53)
	at com.intellij.ui.CardLayoutPanel.createValue(CardLayoutPanel.java:73)
	at com.intellij.ui.CardLayoutPanel.select(CardLayoutPanel.java:101)
	at com.intellij.ui.CardLayoutPanel.lambda$null$0(CardLayoutPanel.java:117)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:201)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
	at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeLater$4(ApplicationImpl.java:310)
	at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:80)
	at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:128)
	at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:46)
	at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:184)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:974)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:847)
	at com.intellij.ide.IdeEventQueue.lambda$null$8(IdeEventQueue.java:449)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:728)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:496)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:117)
	at java.desktop/java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:190)
	at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:235)
	at java.desktop/java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:233)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.desktop/java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:233)
	at java.desktop/java.awt.Dialog.show(Dialog.java:1063)
	at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl$MyDialog.show(DialogWrapperPeerImpl.java:708)
	at com.intellij.openapi.ui.impl.DialogWrapperPeerImpl.show(DialogWrapperPeerImpl.java:437)
	at com.intellij.openapi.ui.DialogWrapper.doShow(DialogWrapper.java:1707)
	at com.intellij.openapi.ui.DialogWrapper.show(DialogWrapper.java:1666)
	at com.intellij.ide.actions.ShowSettingsUtilImpl.showSettingsDialog(ShowSettingsUtilImpl.java:80)
	at com.intellij.ide.actions.ShowSettingsAction.perform(ShowSettingsAction.java:54)
	at com.intellij.ide.actions.ShowSettingsAction.actionPerformed(ShowSettingsAction.java:41)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:280)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.lambda$actionPerformed$0(ActionMenuItem.java:296)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:281)
	at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.runOnOwnContext(IdeFocusManagerImpl.java:77)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:285)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1967)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$0(ActionMenuItem.java:112)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:112)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:517)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:36)
	at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:539)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6651)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
	at java.desktop/java.awt.Component.processEvent(Component.java:6416)
	at java.desktop/java.awt.Container.processEvent(Container.java:2263)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5026)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4858)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4918)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4547)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4488)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2307)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2773)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4858)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:778)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:95)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:751)
	at java.desktop/java.awt.EventQueue$5.run(EventQueue.java:749)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:748)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:974)
	at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:912)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:844)
	at com.intellij.ide.IdeEventQueue.lambda$null$8(IdeEventQueue.java:449)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:739)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:831)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:502)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

I am still able to actually use the plugin via the Alt+Insert "Generate > CodeGenerator > ..." menu, so it seems the core functionality is intact, it's just the settings pane that's broken.

Let me know if there's any additional information I can provide to help debug the issue :)

Instructions for building from source

Would it be possible to provide instructions for building this plugin from source? I would like to modify it and add some functionality for my own purposes.

Use default generate menu

I really like this, thanks for putting your time into making it.

It would make it easier/faster to use if the templates were accessible from the default generate menu! It seems like that's how it works in CodeMaker, any particular reason why it was removed?

I could make a pull request for this if you'd like.

Would be an useful utility class: DateTool (and maybe a random generator)

Hello

thank you very much for sharing and maintaining your great work!,
It's always great to start the CodeGenerator and let the magic happen 😄. I use it for projects for non-profit organizations.

Maybe it would not be so complicated for you to include one or two tools classes for velocity in the next update, therefore I ask:

I tried to make the change in a fork myself and then return it as a merge request, but after about 4 hours of reading and experimenting I still couldn't get the project to compile (probably because of my slightly outdated IntelliJ version) 😞 - I guess it's much easier for you.

It would be great if you could add to these tools at some point.

Thanks a lot, kind regards,
Thomas

Debug / Development cycle

Whats the best development cycle? I find myself stuck in between writing the generator in vim, then copying into the settings dialogue of IntelliJ, then checking what has been generated after clicking apply. This way does not show any errors in the velocity code.

Is there a better way?

Static Imports

Hi, this is more a question then an issue but i did not find a better place to ask this :)

This plugin will add imports for class that are provided with a the full path

I do would like to add some static imports though. Is that possible when using the Write to "body" method?

Best Regards

David

Not compatible with IntelliJ IDEA 2023.2.1

  • The version of Code Generator plugin: 1.5.2
  • The version of IDE: IntelliJ IDEA 2023.2.1 (Ultimate Edition) Build #IU-232.9559.62
  • The version of Apache Velocity plugin: bundled 232.9559.62
  • The following is the error logs:
java.lang.NoSuchMethodError: 'java.lang.Object[] org.apache.velocity.VelocityContext.getKeys()'
	at me.lotabout.codegenerator.util.GenerationUtil.velocityEvaluate(GenerationUtil.java:134)
	at me.lotabout.codegenerator.action.CodeGeneratorAction.selectMember(CodeGeneratorAction.java:232)
	at me.lotabout.codegenerator.action.CodeGeneratorAction.executePipeline(CodeGeneratorAction.java:162)
	at me.lotabout.codegenerator.action.CodeGeneratorAction.actionPerformed(CodeGeneratorAction.java:102)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:339)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:313)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:362)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:313)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.invokeAction(ActionUtil.java:538)
	at com.intellij.ui.popup.ActionPopupStep.performAction(ActionPopupStep.java:266)
	at com.intellij.ui.popup.ActionPopupStep.lambda$onChosen$3(ActionPopupStep.java:243)
	at com.intellij.ui.popup.AbstractPopup.lambda$dispose$18(AbstractPopup.java:1625)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.lambda$doWhenFocusSettlesDown$3(FocusManagerImpl.java:173)
	at com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:33)
	at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.kt:210)
	at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.kt:176)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:169)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:163)
	at com.intellij.ui.popup.AbstractPopup.dispose(AbstractPopup.java:1623)
	at com.intellij.ui.popup.WizardPopup.dispose(WizardPopup.java:165)
	at com.intellij.ui.popup.list.ListPopupImpl.dispose(ListPopupImpl.java:394)
	at com.intellij.ui.popup.PopupFactoryImpl$ActionGroupPopup.dispose(PopupFactoryImpl.java:293)
	at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:129)
	at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:161)
	at com.intellij.openapi.util.Disposer.dispose(Disposer.java:262)
	at com.intellij.openapi.util.Disposer.dispose(Disposer.java:250)
	at com.intellij.ui.popup.WizardPopup.disposeAllParents(WizardPopup.java:273)
	at com.intellij.ui.popup.WizardPopup.disposeAllParents(WizardPopup.java:275)
	at com.intellij.ui.popup.list.ListPopupImpl.disposePopup(ListPopupImpl.java:496)
	at com.intellij.ui.popup.list.ListPopupImpl.handleNextStep(ListPopupImpl.java:523)
	at com.intellij.ui.popup.list.ListPopupImpl._handleSelect(ListPopupImpl.java:483)
	at com.intellij.ui.popup.list.ListPopupImpl.handleSelect(ListPopupImpl.java:429)
	at com.intellij.ui.popup.list.ListPopupImpl$MyMouseListener.mouseReleased(ListPopupImpl.java:699)
	at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6657)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
	at com.intellij.ui.popup.list.ListPopupImpl$MyList.processMouseEvent(ListPopupImpl.java:764)
	at java.desktop/java.awt.Component.processEvent(Component.java:6422)
	at java.desktop/java.awt.Container.processEvent(Container.java:2266)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4954)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4581)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4522)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2808)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:794)
	at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
	at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:766)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:764)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:763)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:685)
	at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:633)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:588)
	at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363)
	at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992)
	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
	at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992)
	at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

添加新的模板出错

使用新添加的模板后提示错误

org.jetbrains.java.generate.exception.GenerateCodeException: Error in Velocity code generator
Caused by: Invocation of method 'sanitizeJavaIdentifier' in  class java.lang.Class threw exception java.lang.IllegalArgumentException: Argument for @NotNull parameter 'name' of com/intellij/openapi/util/text/StringUtil.sanitizeJavaIdentifier must not be null at me.lotabout.codegenerator.util.GenerationUtil[line 10, column 71]
	at me.lotabout.codegenerator.util.GenerationUtil.velocityEvaluate(GenerationUtil.java:144)
	at me.lotabout.codegenerator.worker.JavaBodyWorker.execute(JavaBodyWorker.java:35)
	at me.lotabout.codegenerator.action.CodeGeneratorAction.actionPerformed(CodeGeneratorAction.java:120)
	at com.intellij.openapi.actionSystem.ex.ActionUtil$1.run(ActionUtil.java:220)
	at com.intellij.openapi.application.TransactionGuardImpl.runSyncTransaction(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransactionAndWait(TransactionGuardImpl.java:153)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:235)
	at com.intellij.ui.popup.ActionPopupStep.performAction(ActionPopupStep.java:203)
	at com.intellij.ui.popup.ActionPopupStep.performAction(ActionPopupStep.java:191)
	at com.intellij.ui.popup.ActionPopupStep.lambda$onChosen$2(ActionPopupStep.java:185)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:195)
	at com.intellij.ui.popup.AbstractPopup.lambda$dispose$8(AbstractPopup.java:1405)
	at com.intellij.util.ui.UIUtil.invokeLaterIfNeeded(UIUtil.java:3078)
```

* IntelliJ版本:2018.2

Cannot add own suffix to generated class - default package names starts with redundant '\n'

  1. Plugin version 1.5.2. IDEA Build #IU-223.8214.52 OS - Linux
  2. new template created
        <CodeTemplate>
          <option name="name" value="TestDataFactory" />
          <option name="type" value="class" />
          <option name="template" value="public class ${ClassName} {&#10;     public static ${class0.name} aDefault${class0.name}(){&#10;         return ${class0.name}.build();&#10;     }&#10;}&#10;" />
          <option name="classNameVm" value="${class0.qualifiedName}TestDataFactory" />
          <option name="defaultTargetPackage" value="" />
          <option name="defaultTargetModule" value="" />
        </CodeTemplate>
  1. generate code
package
        ru.test.example;

directory with name started with '\n' created

src/test/java$ ls
''$'\n''ru'   ru

UI file manager screenshot:
image

Didn't found the way to fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.