diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/CustomUsageSearcherTest.kt b/idea/tests/org/jetbrains/kotlin/findUsages/CustomUsageSearcherTest.kt index fe9951525b6..8aaa76c7212 100644 --- a/idea/tests/org/jetbrains/kotlin/findUsages/CustomUsageSearcherTest.kt +++ b/idea/tests/org/jetbrains/kotlin/findUsages/CustomUsageSearcherTest.kt @@ -5,21 +5,30 @@ package org.jetbrains.kotlin.findUsages +import com.intellij.find.findUsages.CustomUsageSearcher +import com.intellij.find.findUsages.FindUsagesOptions +import com.intellij.psi.PsiElement +import com.intellij.usageView.UsageInfo +import com.intellij.usages.Usage +import com.intellij.usages.UsageInfo2UsageAdapter +import org.jetbrains.kotlin.idea.KotlinFileType +import org.jetbrains.kotlin.idea.maskExtensions import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCaseBase +import org.jetbrains.kotlin.idea.util.application.runReadAction + class CustomUsageSearcherTest : KotlinLightCodeInsightFixtureTestCaseBase() { fun testAddCustomUsagesForKotlin() { -// TODO("[VD] There are diff API for ExtensionTestUtil in 191, 192, 193") -// val customUsageSearcher = object : CustomUsageSearcher() { -// override fun processElementUsages(element: PsiElement, processor: Processor, options: FindUsagesOptions) { -// runReadAction { processor.process(UsageInfo2UsageAdapter(UsageInfo(element))) } -// } -// } -// // ExtensionTestUtil.maskExtensions(CustomUsageSearcher.EP_NAME, listOf(customUsageSearcher), testRootDisposable) -// myFixture.configureByText(KotlinFileType.INSTANCE, """val selfUsed = 1""") -// -// val usages = myFixture.getUsageViewTreeTextRepresentation(myFixture.elementAtCaret) -// assertTrue(usages.contains("val selfUsed")) + val customUsageSearcher = object : CustomUsageSearcher() { + override fun processElementUsages(element: PsiElement, processor: ProcessorInCompat, options: FindUsagesOptions) { + runReadAction { processor.process(UsageInfo2UsageAdapter(UsageInfo(element))) } + } + } + maskExtensions(CustomUsageSearcher.EP_NAME, listOf(customUsageSearcher), testRootDisposable) + myFixture.configureByText(KotlinFileType.INSTANCE, """val selfUsed = 1""") + + val usages = myFixture.getUsageViewTreeTextRepresentation(myFixture.elementAtCaret) + assertTrue(usages.contains("val selfUsed")) } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/customUsageSearcher.kt b/idea/tests/org/jetbrains/kotlin/findUsages/customUsageSearcher.kt new file mode 100644 index 00000000000..05056d4dccf --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/findUsages/customUsageSearcher.kt @@ -0,0 +1,11 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.findUsages + +import com.intellij.util.Processor + +// BUNCH 193 +typealias ProcessorInCompat = Processor \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/findUsages/customUsageSearcher.kt.201 b/idea/tests/org/jetbrains/kotlin/findUsages/customUsageSearcher.kt.201 new file mode 100644 index 00000000000..8c02c468a9c --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/findUsages/customUsageSearcher.kt.201 @@ -0,0 +1,11 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.findUsages + +import com.intellij.util.Processor + +// BUNCH 201 +typealias ProcessorInCompat = Processor \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/compat.kt b/idea/tests/org/jetbrains/kotlin/idea/compat.kt index 7b310c7a152..e4d67c2312f 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/compat.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/compat.kt @@ -6,7 +6,10 @@ package org.jetbrains.kotlin.idea import com.intellij.ide.hierarchy.HierarchyTreeStructure +import com.intellij.openapi.Disposable +import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.openapi.util.Computable +import com.intellij.testFramework.ExtensionTestUtil import com.intellij.testFramework.codeInsight.hierarchy.HierarchyViewTestFixture // BUNCH: 193 @@ -18,3 +21,11 @@ fun doHierarchyTestCompat( ) { HierarchyViewTestFixture.doHierarchyTest(treeStructureComputable.compute(), expectedStructure) } + +fun maskExtensions( + pointName: ExtensionPointName, + newExtensions: List, + parentDisposable: Disposable +) { + ExtensionTestUtil.maskExtensions(pointName, newExtensions, parentDisposable) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/compat.kt.192 b/idea/tests/org/jetbrains/kotlin/idea/compat.kt.192 index 0ef6f5408ca..3cf24901394 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/compat.kt.192 +++ b/idea/tests/org/jetbrains/kotlin/idea/compat.kt.192 @@ -6,10 +6,13 @@ package org.jetbrains.kotlin.idea import com.intellij.ide.hierarchy.HierarchyTreeStructure +import com.intellij.openapi.Disposable +import com.intellij.openapi.extensions.ExtensionPointName import com.intellij.openapi.util.Computable +import com.intellij.testFramework.PlatformTestUtil import com.intellij.testFramework.codeInsight.hierarchy.HierarchyViewTestFixture -// BUNCH: 193 +// BUNCH: 192 @Suppress("UNUSED_PARAMETER") fun doHierarchyTestCompat( hierarchyFixture: HierarchyViewTestFixture, @@ -18,3 +21,11 @@ fun doHierarchyTestCompat( ) { hierarchyFixture.doHierarchyTest(treeStructureComputable.compute(), expectedStructure) } + +fun maskExtensions( + pointName: ExtensionPointName, + newExtensions: List, + parentDisposable: Disposable +) { + PlatformTestUtil.maskExtensions(pointName, newExtensions, parentDisposable) +} \ No newline at end of file