From ccf75d0bd67f85ce2a121cd572f5e6bb4501c093 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 19 Jun 2020 12:21:14 +0200 Subject: Remove unnecessary files from core, rename aditional -> additional --- core/src/main/kotlin/markdown/MarkdownProcessor.kt | 53 --------------- core/src/main/kotlin/model/additionalExtras.kt | 75 ++++++++++++++++++++++ core/src/main/kotlin/model/aditionalExtras.kt | 75 ---------------------- core/src/main/kotlin/model/typeWrappers.kt | 0 core/src/main/kotlin/utilities/Path.kt | 5 -- 5 files changed, 75 insertions(+), 133 deletions(-) delete mode 100644 core/src/main/kotlin/markdown/MarkdownProcessor.kt create mode 100644 core/src/main/kotlin/model/additionalExtras.kt delete mode 100644 core/src/main/kotlin/model/aditionalExtras.kt delete mode 100644 core/src/main/kotlin/model/typeWrappers.kt delete mode 100644 core/src/main/kotlin/utilities/Path.kt (limited to 'core/src/main/kotlin') diff --git a/core/src/main/kotlin/markdown/MarkdownProcessor.kt b/core/src/main/kotlin/markdown/MarkdownProcessor.kt deleted file mode 100644 index 1304d58e..00000000 --- a/core/src/main/kotlin/markdown/MarkdownProcessor.kt +++ /dev/null @@ -1,53 +0,0 @@ -package org.jetbrains.dokka.markdown - -import org.intellij.markdown.IElementType -import org.intellij.markdown.MarkdownElementTypes -import org.intellij.markdown.ast.ASTNode -import org.intellij.markdown.ast.LeafASTNode -import org.intellij.markdown.ast.getTextInNode -import org.intellij.markdown.flavours.commonmark.CommonMarkFlavourDescriptor -import org.intellij.markdown.parser.MarkdownParser - -class MarkdownNode(val node: ASTNode, val parent: MarkdownNode?, val markdown: String) { - val children: List = node.children.map { MarkdownNode(it, this, markdown) } - val type: IElementType get() = node.type - val text: String get() = node.getTextInNode(markdown).toString() - fun child(type: IElementType): MarkdownNode? = children.firstOrNull { it.type == type } - - val previous get() = parent?.children?.getOrNull(parent.children.indexOf(this) - 1) - - override fun toString(): String = StringBuilder().apply { presentTo(this) }.toString() -} - -fun MarkdownNode.visit(action: (MarkdownNode, () -> Unit) -> Unit) { - action(this) { - for (child in children) { - child.visit(action) - } - } -} - -fun MarkdownNode.toTestString(): String { - val sb = StringBuilder() - var level = 0 - visit { node, visitChildren -> - sb.append(" ".repeat(level * 2)) - node.presentTo(sb) - sb.appendln() - level++ - visitChildren() - level-- - } - return sb.toString() -} - -private fun MarkdownNode.presentTo(sb: StringBuilder) { - sb.append(type.toString()) - sb.append(":" + text.replace("w\n", "\u23CE")) -} - -fun parseMarkdown(markdown: String): MarkdownNode { - if (markdown.isEmpty()) - return MarkdownNode(LeafASTNode(MarkdownElementTypes.MARKDOWN_FILE, 0, 0), null, markdown) - return MarkdownNode(MarkdownParser(CommonMarkFlavourDescriptor()).buildMarkdownTreeFromString(markdown), null, markdown) -} diff --git a/core/src/main/kotlin/model/additionalExtras.kt b/core/src/main/kotlin/model/additionalExtras.kt new file mode 100644 index 00000000..94d0e751 --- /dev/null +++ b/core/src/main/kotlin/model/additionalExtras.kt @@ -0,0 +1,75 @@ +package org.jetbrains.dokka.model + +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.model.properties.ExtraProperty +import org.jetbrains.dokka.model.properties.MergeStrategy + +class AdditionalModifiers(val content: SourceSetDependent>) : ExtraProperty { + companion object : ExtraProperty.Key { + override fun mergeStrategyFor( + left: AdditionalModifiers, + right: AdditionalModifiers + ): MergeStrategy = MergeStrategy.Replace(AdditionalModifiers(left.content + right.content)) + } + + override fun equals(other: Any?): Boolean = + if (other is AdditionalModifiers) other.content == content else false + + override fun hashCode() = content.hashCode() + override val key: ExtraProperty.Key = AdditionalModifiers +} + +fun SourceSetDependent>.toAdditionalModifiers() = AdditionalModifiers(this) + +class Annotations(val content: SourceSetDependent>) : ExtraProperty { + companion object : ExtraProperty.Key { + override fun mergeStrategyFor(left: Annotations, right: Annotations): MergeStrategy = + MergeStrategy.Replace(Annotations(left.content + right.content)) + } + + override val key: ExtraProperty.Key = Annotations + + data class Annotation(val dri: DRI, val params: Map, val mustBeDocumented: Boolean = false) { + override fun equals(other: Any?): Boolean = when (other) { + is Annotation -> dri == other.dri + else -> false + } + + override fun hashCode(): Int = dri.hashCode() + } +} + +fun SourceSetDependent>.toAnnotations() = Annotations(this) + +sealed class AnnotationParameterValue +data class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue() +data class ArrayValue(val value: List) : AnnotationParameterValue() +data class EnumValue(val enumName: String, val enumDri: DRI) : AnnotationParameterValue() +data class ClassValue(val className: String, val classDRI: DRI) : AnnotationParameterValue() +data class StringValue(val value: String) : AnnotationParameterValue() + + +object PrimaryConstructorExtra : ExtraProperty, ExtraProperty.Key { + override val key: ExtraProperty.Key = this +} + +data class ActualTypealias(val underlyingType: SourceSetDependent) : ExtraProperty { + companion object : ExtraProperty.Key { + override fun mergeStrategyFor( + left: ActualTypealias, + right: ActualTypealias + ) = + MergeStrategy.Replace(ActualTypealias(left.underlyingType + right.underlyingType)) + } + + override val key: ExtraProperty.Key = ActualTypealias +} + +data class ConstructorValues(val values: SourceSetDependent>) : ExtraProperty{ + companion object : ExtraProperty.Key { + override fun mergeStrategyFor(left: ConstructorValues, right: ConstructorValues) = + MergeStrategy.Replace(ConstructorValues(left.values + right.values)) + } + + override val key: ExtraProperty.Key = ConstructorValues +} \ No newline at end of file diff --git a/core/src/main/kotlin/model/aditionalExtras.kt b/core/src/main/kotlin/model/aditionalExtras.kt deleted file mode 100644 index 94d0e751..00000000 --- a/core/src/main/kotlin/model/aditionalExtras.kt +++ /dev/null @@ -1,75 +0,0 @@ -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.properties.ExtraProperty -import org.jetbrains.dokka.model.properties.MergeStrategy - -class AdditionalModifiers(val content: SourceSetDependent>) : ExtraProperty { - companion object : ExtraProperty.Key { - override fun mergeStrategyFor( - left: AdditionalModifiers, - right: AdditionalModifiers - ): MergeStrategy = MergeStrategy.Replace(AdditionalModifiers(left.content + right.content)) - } - - override fun equals(other: Any?): Boolean = - if (other is AdditionalModifiers) other.content == content else false - - override fun hashCode() = content.hashCode() - override val key: ExtraProperty.Key = AdditionalModifiers -} - -fun SourceSetDependent>.toAdditionalModifiers() = AdditionalModifiers(this) - -class Annotations(val content: SourceSetDependent>) : ExtraProperty { - companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: Annotations, right: Annotations): MergeStrategy = - MergeStrategy.Replace(Annotations(left.content + right.content)) - } - - override val key: ExtraProperty.Key = Annotations - - data class Annotation(val dri: DRI, val params: Map, val mustBeDocumented: Boolean = false) { - override fun equals(other: Any?): Boolean = when (other) { - is Annotation -> dri == other.dri - else -> false - } - - override fun hashCode(): Int = dri.hashCode() - } -} - -fun SourceSetDependent>.toAnnotations() = Annotations(this) - -sealed class AnnotationParameterValue -data class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue() -data class ArrayValue(val value: List) : AnnotationParameterValue() -data class EnumValue(val enumName: String, val enumDri: DRI) : AnnotationParameterValue() -data class ClassValue(val className: String, val classDRI: DRI) : AnnotationParameterValue() -data class StringValue(val value: String) : AnnotationParameterValue() - - -object PrimaryConstructorExtra : ExtraProperty, ExtraProperty.Key { - override val key: ExtraProperty.Key = this -} - -data class ActualTypealias(val underlyingType: SourceSetDependent) : ExtraProperty { - companion object : ExtraProperty.Key { - override fun mergeStrategyFor( - left: ActualTypealias, - right: ActualTypealias - ) = - MergeStrategy.Replace(ActualTypealias(left.underlyingType + right.underlyingType)) - } - - override val key: ExtraProperty.Key = ActualTypealias -} - -data class ConstructorValues(val values: SourceSetDependent>) : ExtraProperty{ - companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: ConstructorValues, right: ConstructorValues) = - MergeStrategy.Replace(ConstructorValues(left.values + right.values)) - } - - override val key: ExtraProperty.Key = ConstructorValues -} \ No newline at end of file diff --git a/core/src/main/kotlin/model/typeWrappers.kt b/core/src/main/kotlin/model/typeWrappers.kt deleted file mode 100644 index e69de29b..00000000 diff --git a/core/src/main/kotlin/utilities/Path.kt b/core/src/main/kotlin/utilities/Path.kt deleted file mode 100644 index 00e2aa60..00000000 --- a/core/src/main/kotlin/utilities/Path.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.jetbrains.dokka.utilities - -import java.io.File - -fun File.appendExtension(extension: String) = if (extension.isEmpty()) this else File(path + "." + extension) -- cgit