mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 11:53:49 +07:00
36 lines
1.6 KiB
Kotlin
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)
|
|
}
|
|
} |