<commit_before>package io.damo.kspec


interface SpecTree {
    fun getRoot(): SpecBranch
    fun readSpecBody()
}

open class SpecTreeNode {

    companion object {
        private var currentId: Long = 0
        fun nextId() = currentId++
    }

    val id: Long
    val name: String
    val parent: SpecBranch?
    val children: MutableCollection<SpecTreeNode>

    constructor(
        name: String,
        parent: SpecBranch?,
        children: MutableCollection<SpecTreeNode>
    ) {
        this.id = nextId()
        this.name = name
        this.parent = parent
        this.children = children
    }

    fun isRoot() = (parent == null)

    open fun isFocused(): Boolean {
        return children.any {
            it.isFocused()
        }
    }
}

class SpecBranch : SpecTreeNode {
    companion object {
        fun createRoot() = SpecBranch("", null, arrayListOf(), null, null)
    }

    var before: (() -> Unit)?
    var after: (() -> Unit)?

    constructor(
        name: String,
        parent: SpecBranch?,
        children: MutableCollection<SpecTreeNode> = arrayListOf(),
        before: (() -> Unit)? = null,
        after: (() -> Unit)? = null
    ) : super(name, parent, children) {

        this.before = before
        this.after = after
    }

    fun addChildBranch(name: String): SpecBranch {
        val newBranch = SpecBranch(name, this)
        children.add(newBranch)<commit_msg>Cleanup SpecTreeNode, making it abstract<commit_after>package io.damo.kspec


interface SpecTree {
    fun getRoot(): SpecBranch
    fun readSpecBody()
}

abstract class SpecTreeNode {
    companion object {
        private var currentId: Long = 0
        fun nextId() = currentId++
    }

    val id: Long
    val name: String
    val parent: SpecBranch?
    val children: MutableCollection<SpecTreeNode>

    constructor(
        name: String,
        parent: SpecBranch?,
        children: MutableCollection<SpecTreeNode>
    ) {
        this.id = nextId()
        this.name = name
        this.parent = parent
        this.children = children
    }

    fun isRoot() = (parent == null)

    abstract fun isFocused(): Boolean
}

class SpecBranch : SpecTreeNode {
    companion object {
        fun createRoot() = SpecBranch("", null, arrayListOf(), null, null)
    }

    var before: (() -> Unit)?
    var after: (() -> Unit)?

    constructor(
        name: String,
        parent: SpecBranch?,
        children: MutableCollection<SpecTreeNode> = arrayListOf(),
        before: (() -> Unit)? = null,
        after: (() -> Unit)? = null
    ) : super(name, parent, children) {

        this.before = before
        this.after = after
    }

    override fun isFocused(): Boolean {
        return children.any {
            it.isFocused()
        }
    }

    fun addChildBranch(name: String): SpecBranch {
        val newBranch = SpecBranch(name, this)
        children.add(newBranch)
{'fraction_non_alphanumeric': 0.11099620820406757, 'fraction_numerical': 0.0006894174422612892, 'mean_word_length': 2.1925192519251926, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5009161', 'n_tokens_mistral': 842, 'n_tokens_neox': 844, 'n_words': 223}