2xsaiko / hctm-base

MIT License
2 stars 3 forks source link

Errors when trying to implement method of BlockBundledCableIo in Java project #4

Open rndtrash opened 3 years ago

rndtrash commented 3 years ago

IDE: Intellij IDEA Community 2021.1 EAP (from snap) OS: Ubuntu JDK: 11 HCTM-base version: Any? (I tried versions 3.1.0 - 3.5.1) No matter what I tried, I am unable to implement onBundledInputChange method of BlockBundledCableIo interface in my Java project. IDEA's "Decompile to Java" produced this:

   @JvmDefault
   default void onBundledInputChange_zV4tSj4/* $FF was: onBundledInputChange-zV4tSj4*/(short data, @NotNull BlockState state, @NotNull World world, @NotNull BlockPos pos, @NotNull Direction side, @NotNull Direction edge) {
      Intrinsics.checkParameterIsNotNull(state, "state");
      Intrinsics.checkParameterIsNotNull(world, "world");
      Intrinsics.checkParameterIsNotNull(pos, "pos");
      Intrinsics.checkParameterIsNotNull(side, "side");
      Intrinsics.checkParameterIsNotNull(edge, "edge");
   }

When trying to generate method override (notice a dash in function name): Снимок экрана от 2021-02-28 15-58-24 IDEA throws this error:

com.intellij.util.IncorrectOperationException: Incorrect method 'public void onBundledInputChange-zV4tSj4() {}'
    at com.intellij.psi.impl.PsiJavaParserFacadeImpl.newException(PsiJavaParserFacadeImpl.java:388)
    at com.intellij.psi.impl.PsiJavaParserFacadeImpl.createMethodFromText(PsiJavaParserFacadeImpl.java:184)
    at com.intellij.psi.impl.PsiElementFactoryImpl.createMethodFromText(PsiElementFactoryImpl.java:684)
    at com.intellij.psi.impl.PsiJavaParserFacadeImpl.createMethodFromText(PsiJavaParserFacadeImpl.java:193)
    at com.intellij.psi.impl.PsiElementFactoryImpl.createMethod(PsiElementFactoryImpl.java:221)
    at com.intellij.codeInsight.generation.GenerateMembersUtil.createMethod(GenerateMembersUtil.java:493)
    at com.intellij.codeInsight.generation.GenerateMembersUtil.substituteGenericMethod(GenerateMembersUtil.java:272)
    at com.intellij.codeInsight.generation.OverrideImplementUtil.overrideOrImplementMethod(OverrideImplementUtil.java:122)
    at com.intellij.codeInsight.generation.OverrideImplementUtil.overrideOrImplementMethodsInRightPlace(OverrideImplementUtil.java:544)
    at com.intellij.codeInsight.generation.OverrideImplementUtil.lambda$chooseAndOverrideOrImplementMethods$5(OverrideImplementUtil.java:448)
    at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$1(WriteCommandAction.java:143)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:959)
    at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.lambda$doRunWriteCommandAction$2(WriteCommandAction.java:141)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:207)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:182)
    at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.doRunWriteCommandAction(WriteCommandAction.java:150)
    at com.intellij.openapi.command.WriteCommandAction$BuilderImpl.run(WriteCommandAction.java:117)
    at com.intellij.codeInsight.generation.OverrideImplementUtil.chooseAndOverrideOrImplementMethods(OverrideImplementUtil.java:447)
    at com.intellij.codeInsight.generation.OverrideImplementUtil.chooseAndOverrideMethods(OverrideImplementUtil.java:421)
    at com.intellij.codeInsight.generation.JavaOverrideMethodsHandler.invoke(JavaOverrideMethodsHandler.java:39)
    at com.intellij.codeInsight.generation.OverrideMethodsHandler.invoke(OverrideMethodsHandler.java:42)
    at com.intellij.codeInsight.actions.CodeInsightAction.lambda$actionPerformedImpl$0(CodeInsightAction.java:58)
    at com.intellij.codeInsight.actions.CodeInsightAction.lambda$actionPerformedImpl$1(CodeInsightAction.java:64)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:216)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:172)
    at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:153)
    at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformedImpl(CodeInsightAction.java:55)
    at com.intellij.codeInsight.actions.CodeInsightAction.actionPerformed(CodeInsightAction.java:33)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAware$5(ActionUtil.java:273)
    at com.intellij.util.SlowOperations.lambda$allowSlowOperations$0(SlowOperations.java:77)
    at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:64)
    at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:76)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAware(ActionUtil.java:273)
    at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:267)
    at com.intellij.ui.popup.ActionPopupStep.performAction(ActionPopupStep.java:231)
    at com.intellij.ui.popup.ActionPopupStep.performAction(ActionPopupStep.java:221)
    at com.intellij.ui.popup.ActionPopupStep.lambda$onChosen$2(ActionPopupStep.java:207)
    at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:95)
    at com.intellij.ui.popup.AbstractPopup.lambda$dispose$18(AbstractPopup.java:1475)
    at com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:101)
    at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.java:188)
    at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.java:140)
    at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:173)
    at com.intellij.openapi.wm.impl.IdeFocusManagerImpl.doWhenFocusSettlesDown(IdeFocusManagerImpl.java:36)
    at com.intellij.ui.popup.AbstractPopup.dispose(AbstractPopup.java:1471)
    at com.intellij.ui.popup.WizardPopup.dispose(WizardPopup.java:163)
    at com.intellij.ui.popup.list.ListPopupImpl.dispose(ListPopupImpl.java:332)
    at com.intellij.ui.popup.PopupFactoryImpl$ActionGroupPopup.dispose(PopupFactoryImpl.java:290)
    at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:138)
    at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:168)
    at com.intellij.openapi.util.Disposer.dispose(Disposer.java:153)
    at com.intellij.openapi.util.Disposer.dispose(Disposer.java:141)
    at com.intellij.ui.popup.WizardPopup.disposeAllParents(WizardPopup.java:266)
    at com.intellij.ui.popup.list.ListPopupImpl.handleNextStep(ListPopupImpl.java:449)
    at com.intellij.ui.popup.list.ListPopupImpl._handleSelect(ListPopupImpl.java:421)
    at com.intellij.ui.popup.list.ListPopupImpl.handleSelect(ListPopupImpl.java:367)
    at com.intellij.ui.popup.PopupFactoryImpl$ActionGroupPopup.handleSelect(PopupFactoryImpl.java:310)
    at com.intellij.ui.popup.list.ListPopupImpl$MyMouseListener.mouseReleased(ListPopupImpl.java:623)
    at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298)
    at java.desktop/java.awt.Component.processMouseEvent(Component.java:6652)
    at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3345)
    at com.intellij.ui.popup.list.ListPopupImpl$MyList.processMouseEvent(ListPopupImpl.java:699)
    at java.desktop/java.awt.Component.processEvent(Component.java:6417)
    at java.desktop/java.awt.Container.processEvent(Container.java:2263)
    at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
    at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2321)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4859)
    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:2784)
    at java.desktop/java.awt.Component.dispatchEvent(Component.java:4859)
    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:973)
    at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:910)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:836)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:449)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:808)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$9(IdeEventQueue.java:448)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:781)
    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)
Caused by: java.lang.AssertionError: Unexpected token: '-'
    at com.intellij.lang.java.parser.JavaParserUtil.parseFragment(JavaParserUtil.java:210)
    at com.intellij.psi.impl.source.tree.JavaElementType$JavaDummyElementType.parseContents(JavaElementType.java:269)
    at com.intellij.psi.impl.source.tree.LazyParseableElement.lambda$ensureParsed$0(LazyParseableElement.java:192)
    at com.intellij.psi.impl.DebugUtil.performPsiModification(DebugUtil.java:567)
    at com.intellij.psi.impl.source.tree.LazyParseableElement.ensureParsed(LazyParseableElement.java:191)
    at com.intellij.psi.impl.source.tree.LazyParseableElement.getFirstChildNode(LazyParseableElement.java:242)
    at com.intellij.psi.impl.source.JavaDummyElement.getFirstChildNode(JavaDummyElement.java:69)
    at com.intellij.psi.impl.PsiJavaParserFacadeImpl.createMethodFromText(PsiJavaParserFacadeImpl.java:182)
    ... 96 more

Caused by: java.lang.AssertionError: Unexpected token: '-' - it looks like that dash is illegal in function name, but where did it appear from? I also tried to manually write override for onBundledInputChange_zV4tSj4, but compiler said that there's nothing to override with that name.

Can you help me? Please? :(

2xsaiko commented 3 years ago

Hmm, this is probably because I'm using the UShort (unsigned short) type in the interface instead of normal Short. I'll have to change that, then. Either way, this API isn't entirely functional yet.

rndtrash commented 3 years ago

Hmm, this is probably because I'm using the UShort (unsigned short) type in the interface instead of normal Short.

What's interesting though is that getBundledOutput which returns UShort is correctly processed by decompiler, and IDEA even allows me to override that method. :confused:

Either way, this API isn't entirely functional yet.

Understood, I hope this API will be finished soon because I want to use those neat bundled cables with TIS 3D and it looks like your mod is the only mod for Fabric that has wires :smiley:

2xsaiko commented 3 years ago

This is definitely something I'll have to fix before I can release RetroComputers as well, but I've kinda designed myself into a corner regarding specifically this API so I haven't worked on this in a while. We'll see, I definitely want to correct this at some point.