tomblachut / svelte-intellij

Svelte components in WebStorm and friends
MIT License
482 stars 38 forks source link

IllegalStateException on empty object as attribute shorthand #73

Closed tgauges closed 4 years ago

tgauges commented 4 years ago

Addon Version: 0.10.0 PHPStorm Version: 2019.2.3

While rewriting component attributes I had an intermediate state of an empty object as attribute:

<Component {someAttribute} attr2={variable} {}><!-- some other stuff --></Component>

I then get multiple of the following exceptions and am unable to edit my file further until i disable the plugin (even restart does not fix it).

java.lang.IllegalStateException: builder.treeBuilt.firstChildNode must not be null at dev.blachut.svelte.lang.psi.SvelteJSLazyElementType.doParseContents(SvelteJSLazyElementType.kt:33) at com.intellij.psi.tree.ILazyParseableElementType.parseContents(ILazyParseableElementType.java:67) at com.intellij.psi.impl.source.tree.LazyParseableElement.lambda$ensureParsed$0(LazyParseableElement.java:198) at com.intellij.psi.impl.DebugUtil.performPsiModification(DebugUtil.java:564) at com.intellij.psi.impl.source.tree.LazyParseableElement.ensureParsed(LazyParseableElement.java:197) at com.intellij.psi.impl.source.tree.LazyParseableElement.getFirstChildNode(LazyParseableElement.java:246) at com.intellij.psi.impl.source.tree.LazyParseableElement.getFirstChildNode(LazyParseableElement.java:40) at com.intellij.psi.impl.source.tree.ASTStructure.getChildren(ASTStructure.java:47) at com.intellij.psi.impl.BlockSupportImpl$4.getChildren(BlockSupportImpl.java:383) at com.intellij.psi.impl.BlockSupportImpl$4.getChildren(BlockSupportImpl.java:379) at com.intellij.util.diff.DiffTree.build(DiffTree.java:105) at com.intellij.util.diff.DiffTree.build(DiffTree.java:144) at com.intellij.util.diff.DiffTree.build(DiffTree.java:144) at com.intellij.util.diff.DiffTree.build(DiffTree.java:144) at com.intellij.util.diff.DiffTree.build(DiffTree.java:144) at com.intellij.util.diff.DiffTree.build(DiffTree.java:144) at com.intellij.util.diff.DiffTree.diff(DiffTree.java:61) at com.intellij.psi.impl.BlockSupportImpl.diffTrees(BlockSupportImpl.java:375) at com.intellij.psi.impl.BlockSupportImpl.mergeTrees(BlockSupportImpl.java:364) at com.intellij.psi.impl.BlockSupportImpl.makeFullParse(BlockSupportImpl.java:271) at com.intellij.psi.impl.BlockSupportImpl.reparse(BlockSupportImpl.java:106) at com.intellij.psi.impl.DocumentCommitThread.doCommit(DocumentCommitThread.java:662) at com.intellij.psi.impl.DocumentCommitThread.lambda$commitUnderProgress$4(DocumentCommitThread.java:441) at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1106) at com.intellij.psi.impl.DocumentCommitThread.commitUnderProgress(DocumentCommitThread.java:453) at com.intellij.psi.impl.DocumentCommitThread.lambda$pollQueue$1(DocumentCommitThread.java:281) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:591) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:537) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59) at com.intellij.psi.impl.DocumentCommitThread.pollQueue(DocumentCommitThread.java:281) at com.intellij.psi.impl.DocumentCommitThread.run(DocumentCommitThread.java:241) at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:207) at com.intellij.util.concurrency.BoundedTaskExecutor.access$100(BoundedTaskExecutor.java:29) at com.intellij.util.concurrency.BoundedTaskExecutor$1.lambda$run$0(BoundedTaskExecutor.java:185) at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:208) at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:181) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)

Minimal files to reproduce: Component.svelte:

<!-- Component.svelte -->
<script>
  export let attribute = 0
</script>

Test.svelte:

<!-- Test.svelte -->
<script>
  import Component from './Component.svelte'

  let attribute = 42
</script>

<Component {}></Component>

This is just an intermediate state of the Test.svelte file, the goal is to have <Component {attribute}></Component>

tomblachut commented 4 years ago

Yep, repro is working for me, thx. It's strange that i didn't catch that before, anyway I'll try to look into it soon.

tomblachut commented 4 years ago

Thanks again for reporting.

svelte-intellij-0.10.0.zip

Here is a fixed build so anyone can sideload it before I'll create a release