Skip to content

Commit

Permalink
add kdoc for findChildByTypeRecursively and endOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
mgroth0 committed Dec 29, 2024
1 parent e2846c1 commit fe71a48
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,16 @@ public fun ASTNode.remove() {
treeParent.removeChild(this)
}

/**
* Searches the receiver [ASTNode] recursively, returning the first child with type [elementType]. If none are found, returns [null].
* If [includeSelf] is [true], includes the receiver in the search. The receiver would then be the first element searched, so it is guaranteed to be returned if it has type [elementType].
*/
public fun ASTNode.findChildByTypeRecursively(
elementType: IElementType,
includeSelf: Boolean,
): ASTNode? = recursiveChildren(includeSelf).firstOrNull { it.elementType == elementType }

/**
* Returns the end offset of the text of this [ASTNode]
*/
public fun ASTNode.endOffset(): Int = textRange.endOffset

0 comments on commit fe71a48

Please sign in to comment.