From 526a84f28d21bc7e8a07af2460f850adb0e21088 Mon Sep 17 00:00:00 2001 From: Alex Jank Date: Sat, 23 Nov 2024 10:00:46 +0100 Subject: [PATCH] fix(indexing): do not access index before it is ready / while in dumb mode fixes #231 --- .../shyim/shopware6/xml/AdminComponentProvider.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/de/shyim/shopware6/xml/AdminComponentProvider.kt b/src/main/kotlin/de/shyim/shopware6/xml/AdminComponentProvider.kt index 672d64b..5252795 100644 --- a/src/main/kotlin/de/shyim/shopware6/xml/AdminComponentProvider.kt +++ b/src/main/kotlin/de/shyim/shopware6/xml/AdminComponentProvider.kt @@ -3,6 +3,7 @@ package de.shyim.shopware6.xml import com.intellij.codeInsight.completion.XmlTagInsertHandler import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementBuilder +import com.intellij.openapi.project.DumbService import com.intellij.psi.html.HtmlTag import com.intellij.psi.impl.source.xml.XmlElementDescriptorProvider import com.intellij.psi.search.GlobalSearchScope @@ -37,12 +38,14 @@ class AdminComponentProvider : XmlTagNameProvider, XmlElementDescriptorProvider override fun getDescriptor(tag: XmlTag): XmlElementDescriptor? { val adminComponents = HashMap() - for (key in FileBasedIndex.getInstance().getAllKeys(AdminComponentIndex.key, tag.project)) { - val values = FileBasedIndex.getInstance() - .getValues(AdminComponentIndex.key, key, GlobalSearchScope.allScope(tag.project)) + if (!DumbService.getInstance(tag.project).isDumb) { + for (key in FileBasedIndex.getInstance().getAllKeys(AdminComponentIndex.key, tag.project)) { + val values = FileBasedIndex.getInstance() + .getValues(AdminComponentIndex.key, key, GlobalSearchScope.allScope(tag.project)) - values.forEach { - adminComponents[it.name] = it + values.forEach { + adminComponents[it.name] = it + } } }