Skip to content

Commit

Permalink
Update AstNodeUtils.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls committed Jun 22, 2022
1 parent f24f4ee commit 0fb80d7
Showing 1 changed file with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -723,19 +723,6 @@ fun ASTNode.extractLineOfText(): String {
return text.joinToString(separator = "").trim()
}

/**
* @param pred a predicate
* @return filtered sequence
*/
private fun <T> Sequence<T>.takeWhileInclusive(pred: (T) -> Boolean): Sequence<T> {
var shouldContinue = true
return takeWhile {
val result = shouldContinue
shouldContinue = pred(it)
result
}
}

/**
* Checks node has `@Test` annotation
*/
Expand Down Expand Up @@ -846,6 +833,15 @@ fun ASTNode.takeByChainOfTypes(vararg types: IElementType): ASTNode? {
return node
}

private fun <T> Sequence<T>.takeWhileInclusive(pred: (T) -> Boolean): Sequence<T> {
var shouldContinue = true
return takeWhile {
val result = shouldContinue
shouldContinue = pred(it)
result
}
}

private fun Collection<KtAnnotationEntry>.containSuppressWithName(name: String) =
this.any {
it.shortName.toString() == (Suppress::class.simpleName) &&
Expand Down

0 comments on commit 0fb80d7

Please sign in to comment.