Introduce Variable: Skip leading/trailing comments inside selection

#KT-13054 Fixed
This commit is contained in:
Alexey Sedunov
2016-07-26 18:21:06 +03:00
parent 00b6839e59
commit 8a9a3285de
8 changed files with 59 additions and 7 deletions
@@ -136,12 +136,12 @@ inline fun <reified T : PsiElement> PsiElement.getChildrenOfType(): Array<T> {
return PsiTreeUtil.getChildrenOfType(this, T::class.java) ?: arrayOf()
}
fun PsiElement.getNextSiblingIgnoringWhitespaceAndComments(): PsiElement? {
return siblings(withItself = false).filter { it !is PsiWhiteSpace && it !is PsiComment }.firstOrNull()
fun PsiElement.getNextSiblingIgnoringWhitespaceAndComments(withItself: Boolean = false): PsiElement? {
return siblings(withItself = withItself).filter { it !is PsiWhiteSpace && it !is PsiComment }.firstOrNull()
}
fun PsiElement.getPrevSiblingIgnoringWhitespaceAndComments(): PsiElement? {
return siblings(withItself = false, forward = false).filter { it !is PsiWhiteSpace && it !is PsiComment }.firstOrNull()
fun PsiElement.getPrevSiblingIgnoringWhitespaceAndComments(withItself: Boolean = false): PsiElement? {
return siblings(withItself = withItself, forward = false).filter { it !is PsiWhiteSpace && it !is PsiComment }.firstOrNull()
}
inline fun <reified T : PsiElement> T.nextSiblingOfSameType() = PsiTreeUtil.getNextSiblingOfType(this, T::class.java)