Skip to content

Commit dcdd314

Browse files
committed
fix: guard 3 index call sites against dumb mode
Code review (5 finder angles + 1-vote verification) flagged three call sites that consume PrototypedIndex / CqrsIndexUtil without the dumb-mode wrapper their own KDoc/contract requires: - prototyped/PrototypedCompletion.kt:46 — completion popup at a PrototypeTrait site during indexing would throw IndexNotReadyException. - cqrs/CqrsHandlersLineMarkerProvider.kt:30 — gutter pass over a Command/Query class during indexing would crash and silently drop every CQRS line marker. - prototyped/PrototypedPropertyReference.kt:29 — getVariants() called during indexing would crash completion. Fix: early-return when DumbService.isDumb(project), so the IDE simply shows no result until indexes are ready, instead of erroring. ./gradlew test -x patchPluginXml: 76/76 passing, exit 0. https://claude.ai/code/session_01SKogXRGoKRw1AV4SpzUTW6
1 parent 2331e78 commit dcdd314

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/main/kotlin/com/github/xepozz/spiral/cqrs/CqrsHandlersLineMarkerProvider.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.github.xepozz.spiral.php.hasInterface
66
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerInfo
77
import com.intellij.codeInsight.daemon.RelatedItemLineMarkerProvider
88
import com.intellij.codeInsight.navigation.NavigationGutterIconBuilder
9+
import com.intellij.openapi.project.DumbService
910
import com.intellij.openapi.util.NotNullLazyValue
1011
import com.intellij.psi.PsiElement
1112
import com.jetbrains.php.PhpIndex
@@ -24,6 +25,7 @@ class CqrsHandlersLineMarkerProvider : RelatedItemLineMarkerProvider() {
2425
if (!isCommand && !isQuery) return null
2526

2627
val project = phpClass.project
28+
if (DumbService.isDumb(project)) return null
2729
val phpIndex = PhpIndex.getInstance(project)
2830

2931
val classes = if (isQuery) {

src/main/kotlin/com/github/xepozz/spiral/prototyped/PrototypedCompletion.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.github.xepozz.spiral.SpiralIcons
55
import com.github.xepozz.spiral.config.index.PrototypedIndex
66
import com.github.xepozz.spiral.php.hasTrait
77
import com.intellij.codeInsight.completion.CompletionContributor
8+
import com.intellij.openapi.project.DumbService
89
import com.intellij.codeInsight.completion.CompletionParameters
910
import com.intellij.codeInsight.completion.CompletionProvider
1011
import com.intellij.codeInsight.completion.CompletionResultSet
@@ -39,6 +40,7 @@ class PrototypedCompletion : CompletionContributor() {
3940
) {
4041
val element = parameters.position.parent as? FieldReference ?: return
4142
val project = element.project
43+
if (DumbService.isDumb(project)) return
4244

4345
val phpClass = PsiTreeUtil.getParentOfType(element, PhpClass::class.java) ?: return
4446
if (!phpClass.hasTrait(SpiralFrameworkClasses.PROTOTYPE_TRAIT)) return

src/main/kotlin/com/github/xepozz/spiral/prototyped/PrototypedPropertyReference.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.github.xepozz.spiral.prototyped
22

33
import com.github.xepozz.spiral.config.index.PrototypedIndex
4+
import com.intellij.openapi.project.DumbService
45
import com.intellij.openapi.util.TextRange
56
import com.intellij.psi.PsiElement
67
import com.intellij.psi.PsiReferenceBase
@@ -26,8 +27,9 @@ class PrototypedPropertyReference(
2627
override fun getRangeInElement() = range
2728

2829
override fun getVariants(): Array<out Any?> {
29-
val properties = PrototypedIndex.getPrototypes(element.project)
30-
val phpIndex = PhpIndex.getInstance(element.project)
30+
val project = element.project
31+
if (DumbService.isDumb(project)) return emptyArray()
32+
val properties = PrototypedIndex.getPrototypes(project)
3133

3234
return properties.toTypedArray()
3335
}

0 commit comments

Comments
 (0)