Use comment directive for not generated case to be valid Java file
This commit is contained in:
@@ -16,12 +16,13 @@ import java.util.regex.Pattern
|
||||
|
||||
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,
|
||||
testDataFile: File,
|
||||
findLightClass: (String) -> PsiClass?,
|
||||
normalizeText: (String) -> String
|
||||
expectedFile: File,
|
||||
testDataFile: File,
|
||||
findLightClass: (String) -> PsiClass?,
|
||||
normalizeText: (String) -> String
|
||||
) {
|
||||
val text = FileUtil.loadFile(testDataFile, true)
|
||||
val matcher = SUBJECT_FQ_NAME_PATTERN.matcher(text)
|
||||
@@ -36,7 +37,7 @@ object LightClassTestCommon {
|
||||
|
||||
private fun actualText(fqName: String?, lightClass: PsiClass?, normalizeText: (String) -> String): String {
|
||||
if (lightClass == null) {
|
||||
return "<not generated>"
|
||||
return NOT_GENERATED_DIRECTIVE
|
||||
}
|
||||
TestCase.assertTrue("Not a light class: $lightClass ($fqName)", lightClass is KtLightClass)
|
||||
|
||||
@@ -52,5 +53,5 @@ object LightClassTestCommon {
|
||||
// Actual text for light class is generated with ClsElementImpl.appendMirrorText() that can find empty DefaultImpl inner class in stubs
|
||||
// for all interfaces. This inner class can't be used in Java as it generally is not seen from light classes built from Kotlin sources.
|
||||
// It is also omitted during classes generation in backend so it also absent in light classes built from compiled code.
|
||||
fun removeEmptyDefaultImpls(text: String) : String = text.replace("\n static final class DefaultImpls {\n }\n", "")
|
||||
fun removeEmptyDefaultImpls(text: String): String = text.replace("\n static final class DefaultImpls {\n }\n", "")
|
||||
}
|
||||
Reference in New Issue
Block a user