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)
@lotabout Created PR for supporting the latest intellij version, please have a look. it seems plugin should be recompiled with latest plugin sdk version then it will work. I tested it and it works.
@Haixing-Hu you can check if pre-release version works for your IDE until PR getting merged. https://github.com/ramazangirgin/CodeGenerator/releases/tag/v1.6.0
@ramazangirgin I have tested the pre-release version v1.6.0 with IntelliJ IDEA 2023.2.1 (Ultimate Edition) Build #IU-232.9559.62, and it functions flawlessly! Thank you very much.
@ramazangirgin Sorry, I found a bug :-(
I have the following code template for generating the equals() method:
#macro(generateTypeParams)
#if ($class0.typeParamList.size() > 0)
<##
#foreach( $type in $class0.typeParamList )
#if ($foreach.index > 0)
, ##
#end
?##
#end
>##
#end
#end
#set( $typeParams = "#generateTypeParams()" )
public boolean equals(final Object o){
if (this == o) {
return true;
}
if ((o == null) || (getClass() != o.getClass())) {
return false;
}
final $class0.name$typeParams other = ($class0.name$typeParams) o;
return ##
#if ($class0.hasSuper)
super.equals(other)##
#foreach($field in $fields)
&& ltd.qubit.commons.lang.Equality.equals($field.accessor, other.$field.accessor)##
#end
#else
#foreach($field in $fields)
#if($velocityCount > 1)
&& ##
#end
ltd.qubit.commons.lang.Equality.equals($field.accessor, other.$field.accessor) ##
#end
#end
;
}
This code template works in the pre-release version v1.6.0 with IntelliJ IDEA 2023.1.5 (Ultimate Edition) Build #IU-231.9392.1 but it has bug in the pre-release version v1.6.0 with IntelliJ IDEA 2023.2.1 (Ultimate Edition) Build #IU-232.9559.62. It generates incorrect code that omits the && symbols between equality fields.
The following is the code generated in IntelliJ IDEA 2023.1.5 (which is correct):
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if ((o == null) || (getClass() != o.getClass())) {
return false;
}
final Address other = (Address) o;
return Equality.equals(country, other.country)
&& Equality.equals(province, other.province)
&& Equality.equals(city, other.city);
}
The following is the code generated in IntelliJ IDEA 2023.2.1 (which is wrong):
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if ((o == null) || (getClass() != o.getClass())) {
return false;
}
final Address other = (Address) o;
return Equality.equals(country, other.country)
Equality.equals(province, other.province) Equality.equals(city, other.city);
}
Note the lost of && symbols between Equality.equals() statements.
@ramazangirgin Sorry, I found a bug :-(
I have the following code template for generating the
equals()method:#macro(generateTypeParams) #if ($class0.typeParamList.size() > 0) <## #foreach( $type in $class0.typeParamList ) #if ($foreach.index > 0) , ## #end ?## #end >## #end #end #set( $typeParams = "#generateTypeParams()" ) public boolean equals(final Object o){ if (this == o) { return true; } if ((o == null) || (getClass() != o.getClass())) { return false; } final $class0.name$typeParams other = ($class0.name$typeParams) o; return ## #if ($class0.hasSuper) super.equals(other)## #foreach($field in $fields) && ltd.qubit.commons.lang.Equality.equals($field.accessor, other.$field.accessor)## #end #else #foreach($field in $fields) #if($velocityCount > 1) && ## #end ltd.qubit.commons.lang.Equality.equals($field.accessor, other.$field.accessor) ## #end #end ; }This code template works in the pre-release version v1.6.0 with IntelliJ IDEA 2023.1.5 (Ultimate Edition) Build #IU-231.9392.1 but it has bug in the pre-release version v1.6.0 with IntelliJ IDEA 2023.2.1 (Ultimate Edition) Build #IU-232.9559.62. It generates incorrect code that omits the
&&symbols between equality fields.The following is the code generated in IntelliJ IDEA 2023.1.5 (which is correct):
public boolean equals(final Object o) { if (this == o) { return true; } if ((o == null) || (getClass() != o.getClass())) { return false; } final Address other = (Address) o; return Equality.equals(country, other.country) && Equality.equals(province, other.province) && Equality.equals(city, other.city); }The following is the code generated in IntelliJ IDEA 2023.2.1 (which is wrong):
public boolean equals(final Object o) { if (this == o) { return true; } if ((o == null) || (getClass() != o.getClass())) { return false; } final Address other = (Address) o; return Equality.equals(country, other.country) Equality.equals(province, other.province) Equality.equals(city, other.city); }Note the lost of
&&symbols betweenEquality.equals()statements.
I have found the reason of the error. The velocity 2.x has removed $velocityCount and replace it with $foreach.index (zero-based) and $foreach.count (1-based). Therefore the #if($velocityCount > 1) in my template should be changed to #if($foreach.index > 0).