Files
openide/java/java-tests/testSrc/com/intellij/util/indexing/StubIndexTest.kt
Dmitry Batkovich a5fb991472 index: directly read stub tree (forward index) when trying to process stub keys in a single file WEB-49073
GitOrigin-RevId: 742b12e53495a94d44df97bec13d989b28a8c0d4
2021-01-14 09:53:54 +00:00

36 lines
1.6 KiB
Kotlin

// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.util.indexing
import com.intellij.psi.impl.java.stubs.index.JavaShortClassNameIndex
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.testFramework.SkipSlowTestLocally
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
@SkipSlowTestLocally
class StubIndexTest : JavaCodeInsightFixtureTestCase() {
fun `test stub index query for single file with matching key`() {
val clazz = myFixture.addClass("class Foo {}")
val file = clazz.containingFile
val indexQueryResultOptimized =
JavaShortClassNameIndex.getInstance().get("Foo", myFixture.project, GlobalSearchScope.fileScope(file))
assertEquals(clazz, assertOneElement(indexQueryResultOptimized))
val indexQueryResultNotOptimized =
JavaShortClassNameIndex.getInstance().get("Foo", myFixture.project, GlobalSearchScope.allScope(myFixture.project))
assertEquals(clazz, assertOneElement(indexQueryResultNotOptimized))
}
fun `test stub index query for single file without matching key`() {
val file = myFixture.addClass("class Foo {}").containingFile
val indexQueryResultOptimized =
JavaShortClassNameIndex.getInstance().get("Bar", myFixture.project, GlobalSearchScope.fileScope(file))
assertEmpty(indexQueryResultOptimized)
val indexQueryResultNotOptimized =
JavaShortClassNameIndex.getInstance().get("Bar", myFixture.project, GlobalSearchScope.allScope(myFixture.project))
assertEmpty(indexQueryResultNotOptimized)
}
}