picimako / gherkin-overview

IntelliJ-based IDE plugin to provide a tag-based overview of Gherkin and JBehave test automation projects.
https://plugins.jetbrains.com/plugin/16716-gherkin-overview
Apache License 2.0
3 stars 0 forks source link

IDE reports an "java.lang.Throwable: Invalid file" error when a file name changed #12

Closed s2k closed 11 months ago

s2k commented 11 months ago

Observed behaviour

I got the stack trace below when the name of a feature file changed. The filename change happened due to changing the Git branch, possibly changing the branch in a shell outside of the IDE. (Usually all I notice in the IDE, is that the small branch info in the bottom right if the IDE window is updated - and the project files list updates as needed.)

java.lang.Throwable: Invalid file: file:///Users/<username>/full/path/to/feature_file/xyz.feature (invalid)
    at com.intellij.openapi.diagnostic.Logger.error(Logger.java:370)
    at com.intellij.psi.impl.file.impl.FileManagerImpl.findFile(FileManagerImpl.java:353)
    at com.intellij.psi.impl.PsiManagerImpl.findFile(PsiManagerImpl.java:156)
    at com.picimako.gherkin.toolwindow.TagOccurrencesRegistry.calculateCounts(TagOccurrencesRegistry.java:69)
    at com.picimako.gherkin.toolwindow.TagOccurrencesRegistry.updateOccurrenceCounts(TagOccurrencesRegistry.java:65)
    at com.picimako.gherkin.toolwindow.GherkinTagTreeModel.lambda$updateModelForFile$8(GherkinTagTreeModel.java:208)
    at com.intellij.util.SmartList.forEach(SmartList.java:385)
    at com.picimako.gherkin.toolwindow.GherkinTagTreeModel.lambda$updateModelForFile$9(GherkinTagTreeModel.java:208)
    at java.base/java.util.Optional.ifPresent(Optional.java:178)
    at com.picimako.gherkin.toolwindow.GherkinTagTreeModel.lambda$updateModelForFile$10(GherkinTagTreeModel.java:208)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at com.picimako.gherkin.toolwindow.GherkinTagTreeModel.updateModelForFile(GherkinTagTreeModel.java:207)
    at com.picimako.gherkin.toolwindow.GherkinPsiChangeListener.updateModelAndToolWindow(GherkinPsiChangeListener.java:93)
    at com.picimako.gherkin.toolwindow.GherkinPsiChangeListener.updateGherkinTree(GherkinPsiChangeListener.java:77)
    at com.picimako.gherkin.toolwindow.GherkinPsiChangeListener.childrenChanged(GherkinPsiChangeListener.java:40)
    at com.intellij.psi.impl.PsiManagerImpl.notifyPsiTreeChangeListener(PsiManagerImpl.java:407)
    at com.intellij.psi.impl.PsiManagerImpl.fireEvent(PsiManagerImpl.java:350)
    at com.intellij.psi.impl.PsiManagerImpl.childrenChanged(PsiManagerImpl.java:299)
    at com.intellij.psi.AbstractFileViewProvider.onContentReload(AbstractFileViewProvider.java:275)
    at com.intellij.psi.impl.file.impl.FileManagerImpl.reloadPsiAfterTextChange(FileManagerImpl.java:573)
    at com.intellij.psi.impl.file.impl.PsiVFSListener$MyFileDocumentManagerListener.lambda$fileWithNoDocumentChanged$0(PsiVFSListener.java:700)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:992)
    at com.intellij.psi.impl.file.impl.PsiVFSListener$MyFileDocumentManagerListener.fileWithNoDocumentChanged(PsiVFSListener.java:695)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeMethod(MessageBusImpl.kt:699)
    at com.intellij.util.messages.impl.MessageBusImplKt.invokeListener(MessageBusImpl.kt:659)
    at com.intellij.util.messages.impl.MessageBusImplKt.executeOrAddToQueue(MessageBusImpl.kt:491)
    at com.intellij.util.messages.impl.ToDirectChildrenMessagePublisher.publish$intellij_platform_core(CompositeMessageBus.kt:310)
    at com.intellij.util.messages.impl.MessagePublisher.invoke(MessageBusImpl.kt:448)
    at jdk.proxy2/jdk.proxy2.$Proxy29.fileWithNoDocumentChanged(Unknown Source)
    at jdk.internal.reflect.GeneratedMethodAccessor389.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.multiCast(FileDocumentManagerImpl.java:176)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.lambda$new$0(FileDocumentManagerImpl.java:132)
    at jdk.proxy2/jdk.proxy2.$Proxy29.fileWithNoDocumentChanged(Unknown Source)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl.contentsChanged(FileDocumentManagerImpl.java:698)
    at com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl$MyAsyncFileListener$1.afterVfsChange(FileDocumentManagerImpl.java:648)
    at com.intellij.openapi.vfs.newvfs.AsyncEventSupport.afterVfsChange(AsyncEventSupport.java:135)
    at com.intellij.openapi.vfs.newvfs.AsyncEventSupport.processEventsFromRefresh(AsyncEventSupport.java:158)
    at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.fireEventsInWriteAction(RefreshSessionImpl.java:233)
    at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.lambda$fireEvents$1(RefreshSessionImpl.java:214)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runEdtProgressWriteAction$7(ApplicationImpl.java:972)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:186)
    at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$executeProcessUnderProgress$13(CoreProgressManager.java:604)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:679)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computeUnderProgress(CoreProgressManager.java:635)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:603)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:173)
    at com.intellij.openapi.progress.util.PotemkinProgress.runInSwingThread(PotemkinProgress.java:150)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$runEdtProgressWriteAction$8(ApplicationImpl.java:972)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:980)
    at com.intellij.openapi.application.impl.ApplicationImpl.runEdtProgressWriteAction(ApplicationImpl.java:970)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithNonCancellableProgressInDispatchThread(ApplicationImpl.java:953)
    at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.lambda$fireEvents$2(RefreshSessionImpl.java:209)
    at com.intellij.openapi.application.WriteAction.lambda$run$1(WriteAction.java:87)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:980)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1006)
    at com.intellij.openapi.application.WriteAction.run(WriteAction.java:86)
    at com.intellij.openapi.vfs.newvfs.RefreshSessionImpl.fireEvents(RefreshSessionImpl.java:208)
    at com.intellij.openapi.vfs.newvfs.RefreshQueueImpl.lambda$queueSession$2(RefreshQueueImpl.java:109)
    at com.intellij.openapi.application.impl.NonBlockingReadActionImpl$Submission.lambda$safeTransferToEdt$7(NonBlockingReadActionImpl.java:708)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:208)
    at com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:190)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
    at com.intellij.openapi.application.impl.ApplicationImpl$4.run(ApplicationImpl.java:478)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:79)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:121)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:41)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:792)
    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.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:690)
    at com.intellij.ide.IdeEventQueue._dispatchEvent$lambda$10(IdeEventQueue.kt:593)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWithoutImplicitRead(ApplicationImpl.java:1485)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:593)
    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:997)
    at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
    at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:997)
    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)

Expected behaviour

The plugin should update it's file list/loaded files when files (or folders) are changed externally (i.e. in a file system explorer or from within a terminal/shell).

Since the plugin already notices the change (thus the exception), it should also handle file system changes in a meaningful way, for example, by updating the (internal?) state if the loaded file list).

IDE Info

IntelliJ IDEA 2023.2.5 (Ultimate Edition)
Build #IU-232.10227.8, built on November 9, 2023
…
Runtime version: 17.0.9+7-b1000.46 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 13.6.1
GC: G1 Young Generation, G1 Old Generation
Memory: 8096M
Cores: 16
Metal Rendering is ON
Non-Bundled Plugins:
    com.jetbrains.plugins.ini4idea (232.10227.13)
    com.paperetto.dash (3.3)
    com.github.b3er.idea.plugins.arc.browser (0.32)
    com.mroche.JsonHelper (1.3.0)
    com.khmelyuk.multirun (1.13)
    com.intellij.ideolog (222.2.0.0)
    org.jetbrains.plugins.ruby (232.10203.2)
    com.alayouni.ansiHighlight (23.2.0)
    com.github.kisstkondoros.codemetrics (1.0.4)
    io.codearte.props2yaml (1.0.2)
    String Manipulation (9.12.0)
    CheckStyle-IDEA (5.85.0)
    gherkin-overview (1.5.0)
    com.jetbrains.packagesearch.intellij-plugin (232.9921.28)
    org.jetbrains.kotlin (232-1.9.21-release-633-IJ10072.27)
    MavenRunHelper (4.27.1-IJ2022.2)
    org.asciidoctor.intellij.asciidoc (0.40.7)
    net.seesharpsoft.intellij.plugins.csv (3.2.3-232)
    com.haulmont.jpab (2023.4.0-232)
    io.nimbly.tzatziki (15.3.3)
    Pythonid (232.10227.8)
    izhangzhihao.rainbow.brackets (2023.3.7)
    mobi.hsz.idea.gitignore (4.5.2)
    org.jetbrains.intellij.scripting-ruby (1.2)
    net.ashald.envfile (3.4.1)
    pro.bashsupport (3.3.4.232)
    ru.adelf.idea.dotenv (2023.2)
    com.mallowigi.colorHighlighter (17.1.0)

Kotlin: 232-1.9.21-release-633-IJ10072.27
picimako commented 11 months ago

Hello @s2k! Thank you for the detailed report.

I created a patch release with the fix (v1.5.1). An additional check was required, so that files that are deemed invalid by the IJ platform (or are non-existent), are not processed during tag count updates.

The new version should be approved by the JetBrains Marketplace team within the next two days.

I'll leave this issue open for now, in case you still encounter the exception with the new version.

s2k commented 11 months ago

Awesome, you're welcome & thanks for the quick fix! 🙏🏼