201: Uast: fixing KotlinUastGenerationTest by using system-independent inline unaware asRecursiveLogString
This commit is contained in:
@@ -26,6 +26,8 @@ import org.jetbrains.uast.generate.replace
|
|||||||
import org.jetbrains.uast.kotlin.generate.KotlinUastElementFactory
|
import org.jetbrains.uast.kotlin.generate.KotlinUastElementFactory
|
||||||
import org.jetbrains.uast.test.env.kotlin.findElementByTextFromPsi
|
import org.jetbrains.uast.test.env.kotlin.findElementByTextFromPsi
|
||||||
import org.jetbrains.uast.test.env.kotlin.findUElementByTextFromPsi
|
import org.jetbrains.uast.test.env.kotlin.findUElementByTextFromPsi
|
||||||
|
import org.jetbrains.uast.visitor.UastVisitor
|
||||||
|
import java.lang.StringBuilder
|
||||||
import kotlin.test.fail as kfail
|
import kotlin.test.fail as kfail
|
||||||
|
|
||||||
class KotlinUastGenerationTest : KotlinLightCodeInsightFixtureTestCase() {
|
class KotlinUastGenerationTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||||
@@ -936,3 +938,26 @@ class KotlinUastGenerationTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// it is a copy of org.jetbrains.uast.UastUtils.asRecursiveLogString with `appendLine` instead of `appendln` to avoid windows related issues
|
||||||
|
private fun UElement.asRecursiveLogString(render: (UElement) -> String = { it.asLogString() }): String {
|
||||||
|
val stringBuilder = StringBuilder()
|
||||||
|
val indent = " "
|
||||||
|
|
||||||
|
accept(object : UastVisitor {
|
||||||
|
private var level = 0
|
||||||
|
|
||||||
|
override fun visitElement(node: UElement): Boolean {
|
||||||
|
stringBuilder.append(indent.repeat(level))
|
||||||
|
stringBuilder.appendLine(render(node))
|
||||||
|
level++
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun afterVisitElement(node: UElement) {
|
||||||
|
super.afterVisitElement(node)
|
||||||
|
level--
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return stringBuilder.toString()
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user