KSP-KOS / EditorTools

Tools that make creating kOS scripts easier.
GNU General Public License v3.0
53 stars 43 forks source link

IntelliJ Errors #79

Open markjfisher opened 1 year ago

markjfisher commented 1 year ago

I'm getting errors using IntelliJ (latest ultimate edition) editing kos scripts.

Access from Event Dispatch Thread (EDT) is not allowed

com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments: Current thread: Thread[AWT-EventQueue-0,6,main] 1177299881 (EventQueue.isDispatchThread()=true)
SystemEventQueueThread: (same)
at com.intellij.openapi.application.impl.ApplicationImpl.throwThreadAccessException(ApplicationImpl.java:1050)
at com.intellij.openapi.application.impl.ApplicationImpl.assertIsNonDispatchThread(ApplicationImpl.java:1044)
at com.intellij.codeInsight.daemon.impl.WolfTheProblemSolverImpl.queue(WolfTheProblemSolverImpl.java:231)
at ksp.kos.ideaplugin.KerboScriptFile.lambda$new$0(KerboScriptFile.java:39)
at com.intellij.openapi.project.SmartModeScheduler.runWhenSmart(SmartModeScheduler.kt:100)
at com.intellij.openapi.project.DumbServiceImpl.runWhenSmart(DumbServiceImpl.java:242)
at ksp.kos.ideaplugin.KerboScriptFile.<init>(KerboScriptFile.java:35)
at ksp.kos.ideaplugin.parser.KerboScriptParserDefinition.createFile(KerboScriptParserDefinition.java:68)
at com.intellij.psi.AbstractFileViewProvider.createFile(AbstractFileViewProvider.java:140)

A couple of things happen typically when the error happens: variables don't highlight correctly in larger programs (e.g. if I select a variable name, other versions of that variable don't highlight, so refactoring variable names doesn't work), and sometimes files completely disappear from the Left Hand file view, and I have to kill IntelliJ and restart to get them to show.

jim-hart commented 1 year ago

Hey @valery-labuzhsky, I know you aren't actively involved with development anymore, but if you have the time to look at this, can you comment if you've come across this issue before?

valery-labuzhsky commented 1 year ago

Hey guys, fixing both issues

valery-labuzhsky commented 1 year ago

Hey @markjfisher, good news, I published the new version. Could you please verify everything is ok while jetbrains team is verifying it? Both issues should be fixed. https://plugins.jetbrains.com/files/8130/345011/KerboScript_kOS_.zip

valery-labuzhsky commented 1 year ago

Hey @markjfisher, jetbrains published the plugin, so you can download through the marketplace as usual.

jim-hart commented 1 year ago

Awesome; thank you for the quick response!

jim-hart commented 1 year ago

Fixed by #80

markjfisher commented 1 year ago

Looking good on the no-errors front. Thanks for the fix! I've commented on the indentation ticket separately, which has a small issue.

markjfisher commented 1 year ago

Maybe spoke too soon, just got this error after playing around with a few scripts:

com.intellij.diagnostic.PluginException: Element: class ksp.kos.ideaplugin.psi.impl.KerboScriptDeclareIdentifierClauseImpl #KerboScript  because: different providers: com.intellij.psi.SingleRootFileViewProvider{vFile=jar://C:/Users/markj/AppData/Local/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34.plugins/KerboScript(kOS)/lib/instrumented-KerboScript(kOS).jar!/builtin.ks, vFileId=44632, content=VirtualFileContent{size=6046}, eventSystemEnabled=true}(33b6501); com.intellij.psi.SingleRootFileViewProvider{vFile=jar://C:/Users/markj/AppData/Local/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34.plugins/KerboScript(kOS)/lib/instrumented-KerboScript(kOS).jar!/builtin.ks, vFileId=44632, content=VirtualFileContent{size=6046}, eventSystemEnabled=true}(1a15ad6a)
invalidated at: see attachment [Plugin: kos-ksp.idea-plugin]
    at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:23)
    at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:99)
    at com.intellij.psi.util.PsiUtilCore.ensureValid(PsiUtilCore.java:482)
    at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.ensureValid(SmartPointerManagerImpl.java:112)
    at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.createSmartPsiElementPointer(SmartPointerManagerImpl.java:82)
    at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.createSmartPsiElementPointer(SmartPointerManagerImpl.java:75)
    at com.intellij.psi.impl.smartPointers.SmartPointerManagerImpl.createSmartPsiElementPointer(SmartPointerManagerImpl.java:70)
    at com.intellij.psi.SmartPointerManager.createPointer(SmartPointerManager.java:32)
    at com.intellij.model.psi.impl.Psi2Symbol$MyPointer.<init>(Psi2Symbol.java:50)
    at com.intellij.model.psi.impl.Psi2Symbol.<init>(Psi2Symbol.java:26)
    at com.intellij.model.psi.impl.PsiSymbolServiceImpl.asSymbol(PsiSymbolServiceImpl.java:20)
    at com.intellij.model.psi.impl.EvaluatorReference.resolveReference(EvaluatorReference.kt:26)
    at com.intellij.model.psi.impl.TargetData$Referenced.getTargets(classes.kt:57)
    at com.intellij.model.psi.impl.TargetsKt.targetSymbols(targets.kt:29)
    at com.intellij.webSymbols.documentation.WebSymbolDocumentationTargetProvider.documentationTargets(WebSymbolDocumentationTargetProvider.kt:15)
    at com.intellij.lang.documentation.impl.TargetsKt.documentationTargets(targets.kt:19)
    at com.intellij.lang.documentation.ide.impl.IdeDocumentationTargetProviderImpl.documentationTargets(IdeDocumentationTargetProviderImpl.kt:36)
    at com.intellij.lang.documentation.ide.impl.DocumentationTargetHoverInfoKt$calcTargetDocumentationInfo$1$request$1$targets$1.invoke(DocumentationTargetHoverInfo.kt:39)
    at com.intellij.lang.documentation.ide.impl.DocumentationTargetHoverInfoKt$calcTargetDocumentationInfo$1$request$1$targets$1.invoke(DocumentationTargetHoverInfo.kt:39)
    at com.intellij.lang.documentation.ide.impl.DocumentationTargetHoverInfoKt.injectedThenHost(DocumentationTargetHoverInfo.kt:76)
    at com.intellij.lang.documentation.ide.impl.DocumentationTargetHoverInfoKt$calcTargetDocumentationInfo$1$request$1.invoke(DocumentationTargetHoverInfo.kt:37)
    at com.intellij.lang.documentation.ide.impl.DocumentationTargetHoverInfoKt$calcTargetDocumentationInfo$1$request$1.invoke(DocumentationTargetHoverInfo.kt:36)
    at com.intellij.openapi.application.rw.InternalReadAction.insideReadAction(InternalReadAction.kt:108)
    at com.intellij.openapi.application.rw.InternalReadAction.access$insideReadAction(InternalReadAction.kt:15)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$1.invoke(InternalReadAction.kt:92)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadCancellable$1.invoke(InternalReadAction.kt:91)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob$lambda$0(cancellation.kt:17)
    at com.intellij.openapi.progress.Cancellation.withCurrentJob(Cancellation.java:60)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob(cancellation.kt:17)
    at com.intellij.openapi.progress.CancellationKt.executeWithJobAndCompleteIt(cancellation.kt:126)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$1$lambda$0(cancellableReadAction.kt:49)
    at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1102)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal$lambda$1(cancellableReadAction.kt:47)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtilService.runActionAndCancelBeforeWrite(ProgressIndicatorUtilService.java:63)
    at com.intellij.openapi.progress.util.ProgressIndicatorUtils.runActionAndCancelBeforeWrite(ProgressIndicatorUtils.java:129)
    at com.intellij.openapi.application.rw.CancellableReadActionKt.cancellableReadActionInternal(cancellableReadAction.kt:45)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadCancellable(InternalReadAction.kt:91)
    at com.intellij.openapi.application.rw.InternalReadAction.access$tryReadCancellable(InternalReadAction.kt:15)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadAction$2.invoke(InternalReadAction.kt:77)
    at com.intellij.openapi.application.rw.InternalReadAction$tryReadAction$2.invoke(InternalReadAction.kt:72)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob$lambda$0(cancellation.kt:17)
    at com.intellij.openapi.progress.Cancellation.withCurrentJob(Cancellation.java:60)
    at com.intellij.openapi.progress.CancellationKt.withCurrentJob(cancellation.kt:17)
    at com.intellij.openapi.progress.CoroutinesKt.blockingContext(coroutines.kt:193)
    at com.intellij.openapi.application.rw.InternalReadAction.tryReadAction(InternalReadAction.kt:72)
    at com.intellij.openapi.application.rw.InternalReadAction.readLoop(InternalReadAction.kt:64)
    at com.intellij.openapi.application.rw.InternalReadAction.access$readLoop(InternalReadAction.kt:15)
    at com.intellij.openapi.application.rw.InternalReadAction$runReadAction$4.invokeSuspend(InternalReadAction.kt:43)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: com.intellij.psi.PsiInvalidElementAccessException: Element: class ksp.kos.ideaplugin.psi.impl.KerboScriptDeclareIdentifierClauseImpl #KerboScript  because: different providers: com.intellij.psi.SingleRootFileViewProvider{vFile=jar://C:/Users/markj/AppData/Local/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34.plugins/KerboScript(kOS)/lib/instrumented-KerboScript(kOS).jar!/builtin.ks, vFileId=44632, content=VirtualFileContent{size=6046}, eventSystemEnabled=true}(33b6501); com.intellij.psi.SingleRootFileViewProvider{vFile=jar://C:/Users/markj/AppData/Local/JetBrains/Toolbox/apps/IDEA-U/ch-0/231.9011.34.plugins/KerboScript(kOS)/lib/instrumented-KerboScript(kOS).jar!/builtin.ks, vFileId=44632, content=VirtualFileContent{size=6046}, eventSystemEnabled=true}(1a15ad6a)
invalidated at: see attachment
    ... 52 more
markjfisher commented 1 year ago

I tried clearing my intellij caches and installing from scratch in case there was anything left from previous install, but still getting same errors about different providers

valery-labuzhsky commented 1 year ago

Hey @markjfisher, Unfortunately an exception is not very informative. Googling didn't give much results either. The only option we left right now is to reproduce this. Could you please play around and find out which minimum amount of step needed and which minimum amount of code required to reproduce it?

jim-hart commented 1 year ago

Opening this one back up.

markjfisher commented 1 year ago

I'll try and get some time to replicate this with minimal setup.

branan commented 2 months ago

I saw the "different providers" backtrace once, but that was on version 1.2.2. If I manage to see it again w/ 1.4 I'll also see if I can make a repro case.