201: PsiElementVisitor.visitElement nullability
This commit is contained in:
committed by
Nikolay Krasko
parent
98c6efaed9
commit
890109beb8
@@ -13,22 +13,23 @@ import org.jetbrains.kotlin.psi.KtFile
|
|||||||
|
|
||||||
internal fun KtFile.dumpStructureText(): String {
|
internal fun KtFile.dumpStructureText(): String {
|
||||||
val sb = StringBuilder()
|
val sb = StringBuilder()
|
||||||
this.accept(object : PsiElementVisitor() {
|
this.accept(
|
||||||
override fun visitElement(element: PsiElement?) {
|
object : PsiElementVisitor() {
|
||||||
if (element is PsiWhiteSpace) {
|
override fun visitElement(element: PsiElement) {
|
||||||
if (sb.lastOrNull() !in listOf(' ', '{', '}', '(', ')')) {
|
if (element is PsiWhiteSpace) {
|
||||||
sb.append(" ")
|
if (sb.lastOrNull() !in listOf(' ', '{', '}', '(', ')')) {
|
||||||
|
sb.append(" ")
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return
|
if (element is LeafPsiElement) {
|
||||||
|
sb.append(element.text)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
element.acceptChildren(this)
|
||||||
}
|
}
|
||||||
if (element is LeafPsiElement) {
|
},
|
||||||
sb.append(element.text)
|
)
|
||||||
return
|
|
||||||
}
|
|
||||||
element?.acceptChildren(this)
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return sb.toString().trim()
|
return sb.toString().trim()
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user