Skip to content

Commit

Permalink
Merge pull request #232 from jankal/fix/dumb-indexing
Browse files Browse the repository at this point in the history
fix(indexing): do not access index before it is ready / while in dumb mode
  • Loading branch information
shyim authored Nov 23, 2024
2 parents 4368e78 + 526a84f commit 76f4b7e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/kotlin/de/shyim/shopware6/xml/AdminComponentProvider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -37,12 +38,14 @@ class AdminComponentProvider : XmlTagNameProvider, XmlElementDescriptorProvider
override fun getDescriptor(tag: XmlTag): XmlElementDescriptor? {
val adminComponents = HashMap<String, AdminComponent>()

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
}
}
}

Expand Down

0 comments on commit 76f4b7e

Please sign in to comment.