All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.org.intellij.markdown.ast.ASTUtil.kt Maven / Gradle / Ivy

There is a newer version: 0.7.3
Show newest version
package org.intellij.markdown.ast

import org.intellij.markdown.IElementType

fun ASTNode.findChildOfType(type: IElementType): ASTNode? {
    return children.firstOrNull { it.type == type }
}

fun ASTNode.getParentOfType(vararg types: IElementType): ASTNode? {
    var currentNode = parent
    while (currentNode != null && !types.contains(currentNode.type)) {
        currentNode = currentNode.parent
    }
    return currentNode
}

fun ASTNode.getTextInNode(allFileText: CharSequence): CharSequence {
    return allFileText.subSequence(startOffset, endOffset)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy