diff options
author | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-23 15:18:51 +0100 |
---|---|---|
committer | Dmitry Jemerov <yole@jetbrains.com> | 2015-03-23 15:18:51 +0100 |
commit | 58d9e924fc6c7b94f2b8c3c43bea161716d8dd4f (patch) | |
tree | b53fa05f429bfadf13286de446c1ae67a2ade050 /src | |
parent | ef11076a905599879e06a67a8bc787ae7d611053 (diff) | |
download | dokka-58d9e924fc6c7b94f2b8c3c43bea161716d8dd4f.tar.gz dokka-58d9e924fc6c7b94f2b8c3c43bea161716d8dd4f.tar.bz2 dokka-58d9e924fc6c7b94f2b8c3c43bea161716d8dd4f.zip |
simplify MarkdownNodeClass a bit
Diffstat (limited to 'src')
-rw-r--r-- | src/Markdown/MarkdownProcessor.kt | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/Markdown/MarkdownProcessor.kt b/src/Markdown/MarkdownProcessor.kt index ca5799e2..13023a2c 100644 --- a/src/Markdown/MarkdownProcessor.kt +++ b/src/Markdown/MarkdownProcessor.kt @@ -7,13 +7,11 @@ import org.intellij.markdown.parser.dialects.commonmark.CommonMarkMarkerProcesso class MarkdownNode(val node: ASTNode, val parent: MarkdownNode?, val markdown: String) { val children: List<MarkdownNode> = node.children.map { MarkdownNode(it, this, markdown) } - val endOffset: Int get() = node.endOffset - val startOffset: Int get() = node.startOffset val type: IElementType get() = node.type - val text: String get() = markdown.substring(startOffset, endOffset) + val text: String get() = markdown.substring(node.startOffset, node.endOffset) fun child(type: IElementType): MarkdownNode? = children.firstOrNull { it.type == type } - override fun toString(): String = present() + override fun toString(): String = StringBuilder { presentTo(this) }.toString() } fun MarkdownNode.visit(action: (MarkdownNode, () -> Unit) -> Unit) { @@ -37,7 +35,6 @@ public fun MarkdownNode.toTestString(): String { return sb.toString() } -private fun MarkdownNode.present() = StringBuilder { presentTo(this) }.toString() private fun MarkdownNode.presentTo(sb: StringBuilder) { sb.append(type.toString()) sb.append(":" + text.replace("\n", "\u23CE")) |