JetBrains / js-graphql-intellij-plugin

GraphQL language support for WebStorm, IntelliJ IDEA and other IDEs based on the IntelliJ Platform.
https://jimkyndemeyer.github.io/js-graphql-intellij-plugin/
MIT License
879 stars 97 forks source link

Exception when typing backtick after typing `gql` #486

Closed megatrond closed 2 years ago

megatrond commented 3 years ago

Describe the bug Whenever i type:

gql`

The plugin will throw an exception:

com.intellij.diagnostic.PluginException: Element: class com.intellij.lang.jsgraphql.psi.GraphQLFile #GraphQL  because: VirtualFileWindow in /path/to/file/being/edited.js is invalid
invalidated at: see attachment [Plugin: com.intellij.lang.jsgraphql]
    at com.intellij.ide.plugins.PluginManagerCore.createPluginException(PluginManagerCore.java:274)
    at com.intellij.diagnostic.PluginProblemReporterImpl.createPluginExceptionByClass(PluginProblemReporterImpl.java:12)
    at com.intellij.diagnostic.PluginException.createByClass(PluginException.java:100)
    at com.intellij.psi.util.PsiUtilCore.ensureValid(PsiUtilCore.java:476)
    at com.intellij.psi.impl.source.tree.injected.EditorWindowTrackerImpl$EditorWindowImpl.checkValid(EditorWindowTrackerImpl.java:145)
    at com.intellij.psi.impl.source.tree.injected.EditorWindowTrackerImpl$EditorWindowImpl.hostToInjected(EditorWindowTrackerImpl.java:165)
    at com.intellij.psi.impl.source.tree.injected.InjectedCaret.getLogicalPosition(InjectedCaret.java:79)
    at com.intellij.openapi.editor.CaretModel.getLogicalPosition(CaretModel.java:110)
    at com.intellij.openapi.editor.EditorModificationUtilEx.calcAfterLineEnd(EditorModificationUtilEx.java:187)
    at com.intellij.openapi.editor.EditorModificationUtilEx.calcStringToFillVirtualSpace(EditorModificationUtilEx.java:112)
    at com.intellij.openapi.editor.EditorModificationUtilEx.insertStringAtCaretNoScrolling(EditorModificationUtilEx.java:62)
    at com.intellij.openapi.editor.EditorModificationUtilEx.insertStringAtCaret(EditorModificationUtilEx.java:49)
    at com.intellij.openapi.editor.EditorModificationUtilEx.insertStringAtCaret(EditorModificationUtilEx.java:41)
    at com.intellij.codeInsight.editorActions.TypedHandler.type(TypedHandler.java:254)
    at com.intellij.codeInsight.editorActions.TypedHandler.handleQuote(TypedHandler.java:509)
    at com.intellij.codeInsight.editorActions.TypedHandler.lambda$doExecute$5(TypedHandler.java:202)
    at com.intellij.openapi.editor.impl.CaretModelImpl.lambda$runForEachCaret$3(CaretModelImpl.java:312)
    at com.intellij.openapi.editor.impl.CaretModelImpl.doWithCaretMerging(CaretModelImpl.java:421)
    at com.intellij.openapi.editor.impl.CaretModelImpl.runForEachCaret(CaretModelImpl.java:321)
    at com.intellij.openapi.editor.impl.CaretModelImpl.runForEachCaret(CaretModelImpl.java:296)
    at com.intellij.codeInsight.editorActions.TypedHandler.doExecute(TypedHandler.java:163)
    at com.intellij.codeInsight.editorActions.TypedHandler.lambda$execute$0(TypedHandler.java:145)
    at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:152)
    at com.intellij.codeInsight.editorActions.TypedHandler.execute(TypedHandler.java:145)
    at com.intellij.codeInsight.lookup.impl.LookupTypedHandler.execute(LookupTypedHandler.java:73)
    at com.intellij.codeInsight.template.emmet.EmmetPreviewTypedHandler.execute(EmmetPreviewTypedHandler.java:39)
    at com.intellij.execution.impl.ConsoleViewImpl$MyTypedHandler.execute(ConsoleViewImpl.java:1128)
    at com.intellij.openapi.editor.impl.DefaultRawTypedHandler$1.run(DefaultRawTypedHandler.java:55)
    at com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:936)
    at com.intellij.openapi.editor.impl.DefaultRawTypedHandler.execute(DefaultRawTypedHandler.java:49)
    at com.intellij.openapi.editor.impl.EditorFactoryImpl$MyRawTypedHandler.execute(EditorFactoryImpl.java:302)
    at com.intellij.openapi.editor.actionSystem.TypedAction.lambda$actionPerformed$2(TypedAction.java:200)
    at com.intellij.reporting.FreezeLoggerImpl.runUnderPerformanceMonitor(FreezeLoggerImpl.java:28)
    at com.intellij.openapi.editor.actionSystem.TypedAction.lambda$actionPerformed$3(TypedAction.java:199)
    at com.intellij.util.SlowOperations.allowSlowOperations(SlowOperations.java:152)
    at com.intellij.openapi.editor.actionSystem.TypedAction.actionPerformed(TypedAction.java:199)
    at com.intellij.openapi.editor.impl.EditorImpl.processKeyTypedNormally(EditorImpl.java:1320)
    at com.intellij.openapi.editor.impl.EditorImpl.processKeyTyped(EditorImpl.java:1302)
    at com.intellij.openapi.editor.impl.EditorImpl$MyInputMethodHandler.replaceInputMethodText(EditorImpl.java:3763)
    at com.intellij.openapi.editor.impl.EditorImpl.replaceInputMethodText(EditorImpl.java:3384)
    at com.intellij.openapi.editor.impl.EditorComponentImpl.processInputMethodEvent(EditorComponentImpl.java:209)
    at java.desktop/java.awt.Component.processEvent(Component.java:6434)
    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.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:886)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:755)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:442)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:825)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$8(IdeEventQueue.java:441)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:794)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:493)
    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: com.intellij.psi.PsiInvalidElementAccessException: Element: class com.intellij.lang.jsgraphql.psi.GraphQLFile #GraphQL  because: VirtualFileWindow in /Users/trond/projects/helium-tenants/seed/entities/locations.js is invalid
invalidated at: see attachment
    ... 67 more

I can type two backticks elsewhere and copy/paste them to the gql but if I don't I'm not able to type a second backtick

To Reproduce Link to Repo with Reproduction or Steps to Reproduce:

  1. Create a new js file
  2. Import gql
  3. Have some code
  4. Try to add a gql call before the code, so that one backtick will provoke a syntax error

Expected behavior Being able to type a second backtick

Screenshots Screenshot 2021-08-17 at 12 57 47

Version and Environment Details Operation system: MacOS Big Sur 11.3.1 IDE name and version: WebStorm 2021.2 Plugin version: 3.0.0

megatrond commented 3 years ago

I can add that doing this exact thing on WebStorm 2021.1.3 does cause the plugin to throw

vepanimas commented 3 years ago

Hi! It's a platform issue (https://youtrack.jetbrains.com/issue/IDEA-235523) that is reproduced only in specific keyboard layouts. I'm already looking into it.

megatrond commented 3 years ago

Well that is awesome! I disabled "Insert pair quote" for now, and exceptions are no longer thrown :)

Also thanks for a great plugin ❤️

vepanimas commented 2 years ago

Should be fixed in WebStorm and other IDEs since 2021.2.2.