[FIR IDE] Add Fir lightclasses tests and fix FindUsages tests
This commit is contained in:
committed by
Ilya Kirillov
parent
3cefef03ff
commit
dbb54c87bc
+2
-2
@@ -36,12 +36,12 @@ abstract class AbstractCompilerLightClassTest : KotlinMultiFileTestWithJava<Kotl
|
||||
val expectedFile = KotlinTestUtils.replaceExtension(wholeFile, "java")
|
||||
val allowFrontendExceptions = InTextDirectivesUtils.isDirectiveDefined(wholeFile.readText(), "// ALLOW_FRONTEND_EXCEPTION")
|
||||
|
||||
LightClassTestCommon.testLightClass(
|
||||
expectedFile,
|
||||
val actual = LightClassTestCommon.getActualLightClassText(
|
||||
wholeFile,
|
||||
{ fqname -> findLightClass(allowFrontendExceptions, environment, fqname) },
|
||||
LightClassTestCommon::removeEmptyDefaultImpls
|
||||
)
|
||||
KotlinTestUtils.assertEqualsToFile(expectedFile, actual)
|
||||
}
|
||||
|
||||
override fun createTestModule(
|
||||
|
||||
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.asJava
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.psi.PsiClass
|
||||
import com.intellij.psi.impl.compiled.ClsElementImpl
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.asJava.PsiClassRenderer.renderClass
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||
@@ -19,12 +18,11 @@ object LightClassTestCommon {
|
||||
private val SUBJECT_FQ_NAME_PATTERN = Pattern.compile("^//\\s*(.*)$", Pattern.MULTILINE)
|
||||
private const val NOT_GENERATED_DIRECTIVE = "// NOT_GENERATED"
|
||||
|
||||
fun testLightClass(
|
||||
expectedFile: File,
|
||||
fun getActualLightClassText(
|
||||
testDataFile: File,
|
||||
findLightClass: (String) -> PsiClass?,
|
||||
normalizeText: (String) -> String,
|
||||
) {
|
||||
): String {
|
||||
val text = FileUtil.loadFile(testDataFile, true)
|
||||
val matcher = SUBJECT_FQ_NAME_PATTERN.matcher(text)
|
||||
TestCase.assertTrue("No FqName specified. First line of the form '// f.q.Name' expected", matcher.find())
|
||||
@@ -32,8 +30,7 @@ object LightClassTestCommon {
|
||||
|
||||
val lightClass = findLightClass(fqName)
|
||||
|
||||
val actual = actualText(fqName, lightClass, normalizeText)
|
||||
KotlinTestUtils.assertEqualsToFile(expectedFile, actual)
|
||||
return actualText(fqName, lightClass, normalizeText)
|
||||
}
|
||||
|
||||
private fun actualText(fqName: String?, lightClass: PsiClass?, normalizeText: (String) -> String): String {
|
||||
|
||||
Reference in New Issue
Block a user