diff --git a/plugins/uast-kotlin/tests/AbstractKotlinIdentifiersTest.kt.191 b/plugins/uast-kotlin/tests/AbstractKotlinIdentifiersTest.kt.191 index 0262154ebf6..5f2a69146c5 100644 --- a/plugins/uast-kotlin/tests/AbstractKotlinIdentifiersTest.kt.191 +++ b/plugins/uast-kotlin/tests/AbstractKotlinIdentifiersTest.kt.191 @@ -12,7 +12,7 @@ import kotlin.test.assertNotNull abstract class AbstractKotlinIdentifiersTest : AbstractKotlinUastTest(), IdentifiersTestBase { private fun getTestFile(testName: String, ext: String) = - File(File(AbstractKotlinUastTest.TEST_KOTLIN_MODEL_DIR, testName).canonicalPath + '.' + ext) + File(File(TEST_KOTLIN_MODEL_DIR, testName).canonicalPath + '.' + ext) override fun getIdentifiersFile(testName: String): File = getTestFile(testName, "identifiers.txt") diff --git a/plugins/uast-kotlin/tests/AbstractKotlinUastLightCodeInsightFixtureTest.kt.191 b/plugins/uast-kotlin/tests/AbstractKotlinUastLightCodeInsightFixtureTest.kt.191 new file mode 100644 index 00000000000..d43fe9fd4b1 --- /dev/null +++ b/plugins/uast-kotlin/tests/AbstractKotlinUastLightCodeInsightFixtureTest.kt.191 @@ -0,0 +1,45 @@ +/* + * Copyright 2010-2019 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.uast.test.kotlin + +import com.intellij.openapi.util.registry.Registry +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.vfs.VirtualFileManager +import com.intellij.testFramework.LightProjectDescriptor +import com.intellij.util.io.URLUtil +import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase +import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor +import org.jetbrains.uast.UFile +import org.jetbrains.uast.kotlin.KotlinUastLanguagePlugin +import java.io.File + +abstract class AbstractKotlinUastLightCodeInsightFixtureTest : KotlinLightCodeInsightFixtureTestCase() { + + override fun getProjectDescriptor(): LightProjectDescriptor = + KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE_FULL_JDK + + override fun setUp() { + super.setUp() + Registry.get("kotlin.uast.multiresolve.enabled").setValue(true, testRootDisposable) + } + + fun getVirtualFile(testName: String): VirtualFile { + val testFile = TEST_KOTLIN_MODEL_DIR.listFiles { pathname -> pathname.nameWithoutExtension == testName }.first() + val vfs = VirtualFileManager.getInstance().getFileSystem(URLUtil.FILE_PROTOCOL) + return vfs.findFileByPath(testFile.canonicalPath)!! + } + + abstract fun check(testName: String, file: UFile) + + fun doTest(testName: String, checkCallback: (String, UFile) -> Unit = { testName, file -> check(testName, file) }) { + val virtualFile = getVirtualFile(testName) + + val psiFile = myFixture.configureByText(virtualFile.name, File(virtualFile.canonicalPath!!).readText()) + val uFile = KotlinUastLanguagePlugin().convertElementWithParent(psiFile, null) ?: error("Can't get UFile for $testName") + checkCallback(testName, uFile as UFile) + } + +} \ No newline at end of file