minecraft-dev / MinecraftDev

Plugin for IntelliJ IDEA that gives special support for Minecraft modding projects.
https://minecraftdev.org/
GNU Lesser General Public License v3.0
1.52k stars 186 forks source link

LocalVariables$LocalAnalysisFailedException #2388

Open ZZZank opened 1 month ago

ZZZank commented 1 month ago

Minecraft Development for IntelliJ plugin version

2024.2-1.8.2

IntelliJ version

2024.2.2

Operating System

windows11 23h2

Target platform

Architectury, Minecraft Forge, Mixins

Description of the bug

when opening an mixin class that contains a method whose mixin annotation (e.g. @Inject) uses captureLocal (e.g. locals=LocalCapture.CAPTURE_FAILSOFT), an exception will happen:

java.lang.RuntimeException: com.demonwav.mcdev.platform.mixin.util.LocalVariables$LocalAnalysisFailedException
    at com.intellij.util.ExceptionUtil.rethrow(ExceptionUtil.java:136)
    at com.intellij.concurrency.JobLauncherImpl.safeIterate(JobLauncherImpl.java:194)
    at com.intellij.concurrency.JobLauncherImpl.invokeConcurrentlyUnderProgressAsync(JobLauncherImpl.java:100)
    at com.intellij.concurrency.JobLauncherImpl.processConcurrentlyAsync(JobLauncherImpl.java:465)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.lambda$inspect$11(InspectionRunner.java:180)
    at com.intellij.codeInspection.InspectionEngine.withSession(InspectionEngine.java:205)
    at com.intellij.codeInsight.daemon.impl.InspectionRunner.inspect(InspectionRunner.java:141)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.lambda$collectInformationWithProgress$4(LocalInspectionsPass.java:143)
    at com.intellij.codeInsight.daemon.impl.HighlightInfoUpdaterImpl.lambda$runWithInvalidPsiRecycler$32(HighlightInfoUpdaterImpl.java:689)
    at com.intellij.codeInsight.daemon.impl.ManagedHighlighterRecycler.runWithRecycler(ManagedHighlighterRecycler.java:87)
    at com.intellij.codeInsight.daemon.impl.HighlightInfoUpdaterImpl.runWithInvalidPsiRecycler(HighlightInfoUpdaterImpl.java:671)
    at com.intellij.codeInsight.daemon.impl.LocalInspectionsPass.collectInformationWithProgress(LocalInspectionsPass.java:153)
    at com.intellij.codeInsight.daemon.impl.ProgressableTextEditorHighlightingPass.doCollectInformation(ProgressableTextEditorHighlightingPass.java:86)
    at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:67)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:431)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceKt.runWithSpanIgnoreThrows(trace.kt:118)
    at com.intellij.platform.diagnostic.telemetry.helpers.TraceUtil.runWithSpanThrows(TraceUtil.java:36)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$3(PassExecutorService.java:426)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.tryRunReadAction(AnyThreadWriteThreadingSupport.kt:291)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:965)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$4(PassExecutorService.java:417)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:660)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:735)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:691)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:659)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:79)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:416)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:392)
    at com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.cacheFileTypesInside(FileTypeManagerImpl.java:802)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$1(PassExecutorService.java:392)
    at com.intellij.openapi.application.impl.AnyThreadWriteThreadingSupport.executeByImpatientReader(AnyThreadWriteThreadingSupport.kt:486)
    at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:178)
    at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:390)
    at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:259)
    at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
    at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
    at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
    at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
    at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
Caused by: com.demonwav.mcdev.platform.mixin.util.LocalVariables$LocalAnalysisFailedException

The syntax of mixin itself is correct, and can perform normally in-game.

Earthcomputer commented 1 month ago

Please show the mixin

ZZZank commented 1 month ago

Mixin: https://github.com/ZZZank/JEIAreaFixer/blob/4bde8d27ca6f2c0fbad150c95db603c36df95f61/src/main/java/zzzank/mod/jei_area_fixer/mixin/xat/MixinTrinketGui.java#L26 Target: https://github.com/XzeroAir/Trinkets/blob/0ee6c6b109415879b2744d98a12f740526258405/main/java/xzeroair/trinkets/client/gui/TrinketGui.java#L195

This is not the original project my issue refers to, but the error can also be reproduced in this project. The first project is using Architectury+1.16.5, another using RetroFuturaGradle+1.12.2

@Inject(
        method = "renderTrinketInventory",
        at = @At(
            value = "CONSTANT",
            ordinal = 0,
            args = "intValue=64"
        ),
        remap = false,
        locals = LocalCapture.CAPTURE_FAILSOFT
    )
    public void jaf$clearCachedArea(int x, int y, CallbackInfo ci, int slots, int columnLength, int maxColumns) {
    //method body will not affect whether the error will happen
    }

EDIT: note that the it might not always raise an exception, it can also be code checking stop working after changing captureLocal related things like params and locals=XXXXX