Keep empty bodies for declarations with comments (KT-16078)

#KT-16078 Fixed
This commit is contained in:
Nikolay Krasko
2017-02-16 17:59:36 +03:00
parent e16b0524b6
commit d58707972d
13 changed files with 75 additions and 20 deletions
@@ -311,6 +311,12 @@ private fun findFirstLeafWhollyInRange(file: PsiFile, range: TextRange): PsiElem
return if (elementRange.endOffset <= range.endOffset) element else null
}
val PsiElement.textRangeWithoutComments: TextRange
get() {
val firstNonCommentChild = children.firstOrNull { it !is PsiWhiteSpace && it !is PsiComment } ?: return textRange
return TextRange(firstNonCommentChild.startOffset, endOffset)
}
// ---------------------------------- Debug/logging ----------------------------------------------------------------------------------------
fun PsiElement.getElementTextWithContext(): String {