<commit_before>package com.emberjs.navigation

import com.emberjs.icons.EmberIconProvider
import com.emberjs.icons.EmberIcons
import com.emberjs.index.EmberClassIndex
import com.emberjs.project.EmberProjectComponent
import com.emberjs.resolver.EmberName
import com.intellij.navigation.ChooseByNameContributor
import com.intellij.navigation.DelegatingItemPresentation
import com.intellij.navigation.NavigationItem
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VfsUtil.isAncestor
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiManager
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.util.indexing.FileBasedIndex
import com.intellij.util.indexing.FindSymbolParameters.searchScopeFor

class EmberGotoClassContributor() : ChooseByNameContributor {

    override fun getNames(project: Project, includeNonProjectItems: Boolean) =
            FileBasedIndex.getInstance().getAllKeys(EmberClassIndex.NAME, project).toTypedArray()

    override fun getItemsByName(name: String, pattern: String, project: Project, includeNonProjectItems: Boolean) =
            getItemsByName(name, project, searchScopeFor(project, includeNonProjectItems))

    fun getItemsByName(name: String, project: Project, scope: GlobalSearchScope): Array<NavigationItem> {
        // Query file index for the VirtualFile containing the indexed item
        return FileBasedIndex.getInstance().getContainingFiles(EmberClassIndex.NAME, name, scope)
                .flatMap { convert(it, project) }
                .toTypedArray()
    }

    private fun convert(file: VirtualFile, project: Project): Collection<NavigationItem> {
        val psiFile = PsiManager.getInstance(project).findFile(file) ?: return listOf()
        val roots = EmberProjectComponent.getInstance(project)?.roots ?: return listOf()

        val iconProvider = EmberIconProvider()

        return roots.filter { isAncestor(it, file, true) }
                .map { EmberName.from(it, file) }
                .filterNotNull()
                .map {
                    val presentation = DelegatingItemPresentation(psiFile.presentation)
                            .withPresentableText(it.displayName)
                            .withLocationString(null)
                            .withIcon(iconProvider.getIcon(it) ?: DEFAULT_ICON)

                    DelegatingNavigationItem(psiFile).withPresentation(presentation)
                }
    }

    companion object {
        val DEFAULT_ICON = EmberIcons.EMPTY_16
    }
}
<commit_msg>EmberGotoClassContributor: Use EmberNameIndex instead of EmberClassIndex<commit_after>package com.emberjs.navigation

import com.emberjs.icons.EmberIconProvider
import com.emberjs.icons.EmberIcons
import com.emberjs.index.EmberNameIndex
import com.emberjs.resolver.EmberName
import com.intellij.navigation.ChooseByNameContributor
import com.intellij.navigation.DelegatingItemPresentation
import com.intellij.navigation.NavigationItem
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Condition
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiManager
import com.intellij.util.CommonProcessors
import com.intellij.util.FilteringProcessor
import com.intellij.util.indexing.FileBasedIndex
import com.intellij.util.indexing.FindSymbolParameters.searchScopeFor

class EmberGotoClassContributor() : ChooseByNameContributor {

    private val index by lazy { FileBasedIndex.getInstance() }
    private val iconProvider by lazy { EmberIconProvider() }

    /**
     * Get all entries from the module index and extract the `displayName` property.
     */
    override fun getNames(project: Project, includeNonProjectItems: Boolean): Array<String> {
        return index.getAllKeys(EmberNameIndex.NAME, project)
                .map { it.displayName }
                .toTypedArray()
    }

    override fun getItemsByName(name: String, pattern: String, project: Project, includeNonProjectItems: Boolean): Array<NavigationItem> {
        val scope = searchScopeFor(project, includeNonProjectItems)

        val collector = CommonProcessors.CollectProcessor<EmberName>()
        val filter = FilteringProcessor<EmberName>(Condition { it.displayName == name }, collector)

        val psiManager = PsiManager.getInstance(project)

        // Collect all matching modules from the index
        index.processAllKeys(EmberNameIndex.NAME, filter, scope, null)

        return collector.results

                // Find the corresponding PsiFiles
                .flatMap { module ->
                    index.getContainingFiles(EmberNameIndex.NAME, module, scope)
                            .map { psiManager.findFile(it)?.let { Pair(module, it) } }
                            .filterNotNull()
                }

                // Convert search results for LookupElements
                .map { convert(it.first, it.second) }
                .toTypedArray()
    }

    private fun convert(module: EmberName, file: PsiFile): DelegatingNavigationItem {
        val presentation = DelegatingItemPresentation(file.presentation)
                .withPresentableText(module.displayName)
                .withLocationString(null)
                .withIcon(iconProvider.getIcon(module) ?: DEFAULT_ICON)

        return DelegatingNavigationItem(file)
                .withPresentation(presentation)
    }

    companion object {
        val DEFAULT_ICON = EmberIcons.EMPTY_16
    }
}

{'fraction_non_alphanumeric': 0.08062442607897154, 'fraction_numerical': 0.0007346189164370982, 'mean_word_length': 3.186010760953113, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2143806', 'n_tokens_mistral': 1499, 'n_tokens_neox': 1452, 'n_words': 288}