detekt / detekt-intellij-plugin

detekt plugin for IntelliJ
https://plugins.jetbrains.com/plugin/10761-detekt
Apache License 2.0
297 stars 39 forks source link

org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments: Couldn't get containingKtFile for ktElement #480

Closed icedrek closed 1 year ago

icedrek commented 1 year ago

Bug description

Please include steps to reproduce expected and actual behavior.

Environment

Stacktrace

org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments: Couldn't get containingKtFile for ktElement at org.jetbrains.kotlin.idea.caches.resolve.KotlinCacheServiceImpl.fileForElement(KotlinCacheServiceImpl.kt:190) at org.jetbrains.kotlin.idea.caches.resolve.KotlinCacheServiceImpl.getResolutionFacade(KotlinCacheServiceImpl.kt:79) at org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils.getResolutionFacade(ResolutionUtils.kt:23) at org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils.analyze(ResolutionUtils.kt:123) at org.jetbrains.kotlin.idea.caches.resolve.ResolutionUtils.analyze$default(ResolutionUtils.kt:122) at org.jetbrains.kotlin.idea.core.UtilsKt.canOmitDeclaredType(Utils.kt:169) at org.jetbrains.kotlin.idea.intentions.JoinDeclarationAndAssignmentIntention.applyTo(JoinDeclarationAndAssignmentIntention.kt:101) at org.jetbrains.kotlin.idea.intentions.JoinDeclarationAndAssignmentIntention.applyTo(JoinDeclarationAndAssignmentIntention.kt:36) at org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection$IntentionBasedQuickFix.invoke(IntentionBasedInspection.kt:182) at com.intellij.codeInspection.LocalQuickFixOnPsiElement.applyFix(LocalQuickFixOnPsiElement.java:100) at org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection$IntentionBasedQuickFix.invoke(IntentionBasedInspection.kt:171) at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.lambda$invokeIntention$5(ShowIntentionActionsHandler.java:257) at com.intellij.openapi.application.WriteAction.lambda$run$1(WriteAction.java:86) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:1011) at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1037) at com.intellij.openapi.application.WriteAction.run(WriteAction.java:85) at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.invokeIntention(ShowIntentionActionsHandler.java:257) at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.lambda$chooseActionAndInvoke$4(ShowIntentionActionsHandler.java:233) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:219) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:174) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:164) at com.intellij.openapi.command.impl.CoreCommandProcessor.executeCommand(CoreCommandProcessor.java:150) at com.intellij.codeInsight.intention.impl.ShowIntentionActionsHandler.chooseActionAndInvoke(ShowIntentionActionsHandler.java:232) at com.intellij.codeInsight.daemon.impl.DaemonTooltipAction.execute(DaemonTooltipActionProvider.kt:54) at com.intellij.codeInsight.daemon.impl.DaemonTooltipWithActionRenderer$addActionsRow$runFixAction$1.invoke(DaemonTooltipWithActionRenderer.kt:145) at com.intellij.codeInsight.daemon.impl.DaemonTooltipWithActionRenderer$addActionsRow$runFixAction$1.invoke(DaemonTooltipWithActionRenderer.kt:47) at com.intellij.codeInsight.daemon.impl.DaemonTooltipWithActionRendererKt$createActionLabel$1.hyperlinkActivated(DaemonTooltipWithActionRenderer.kt:369) at com.intellij.ui.HyperlinkAdapter.hyperlinkUpdate(HyperlinkAdapter.java:14) at com.intellij.ui.HyperlinkLabel.fireHyperlinkEvent(HyperlinkLabel.java:240) at com.intellij.ui.HyperlinkLabel.processMouseEvent(HyperlinkLabel.java:162) at java.desktop/java.awt.Component.processEvent(Component.java:6421) at java.desktop/java.awt.Container.processEvent(Container.java:2266) at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5026) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854) at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4948) at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4575) at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4516) at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310) at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2804) at java.desktop/java.awt.Component.dispatchEvent(Component.java:4854) at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:788) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:737) at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:731) 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:761) at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:759) 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:758) at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:918) at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.java:840) at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:763) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:450) at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:791) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:449) at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113) at com.intellij.ide.IdeEventQueue.performActivity(IdeEventQueue.java:624) at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:447) at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:881) at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:493) 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) Caused by: java.lang.IllegalStateException: KtElement not inside KtFile: null for element IF of type class org.jetbrains.kotlin.psi.KtIfExpression node = Element(IF) at org.jetbrains.kotlin.psi.KtElementImpl.getContainingKtFile(KtElementImpl.java:65) at org.jetbrains.kotlin.idea.caches.resolve.KotlinCacheServiceImpl.fileForElement(KotlinCacheServiceImpl.kt:187) ... 68 more

arturbosch commented 1 year ago

Duplicate of #271