aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/model
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/kotlin/model')
-rw-r--r--core/src/main/kotlin/model/Documentable.kt16
-rw-r--r--core/src/main/kotlin/model/documentableProperties.kt14
-rw-r--r--core/src/main/kotlin/model/properties/PropertyContainer.kt13
-rw-r--r--core/src/main/kotlin/model/properties/properties.kt6
-rw-r--r--core/src/main/kotlin/model/typeWrappers.kt4
5 files changed, 36 insertions, 17 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt
index 48f00474..73a5f9d3 100644
--- a/core/src/main/kotlin/model/Documentable.kt
+++ b/core/src/main/kotlin/model/Documentable.kt
@@ -3,6 +3,8 @@ package org.jetbrains.dokka.model
import com.intellij.psi.PsiNamedElement
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.doc.DocumentationNode
+import org.jetbrains.dokka.model.properties.ExtraProperty
+import org.jetbrains.dokka.model.properties.MergeStrategy
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.PlatformData
@@ -72,10 +74,10 @@ interface WithType {
}
interface WithAbstraction {
- val modifier: Modifier
+ val modifier: Modifier?
enum class Modifier {
- Abstract, Open, Final
+ Abstract, Open, Final, Static
}
}
@@ -145,7 +147,7 @@ data class Class(
override val generics: List<TypeParameter>,
override val supertypes: PlatformDependent<List<DRI>>,
override val documentation: PlatformDependent<DocumentationNode>,
- override val modifier: WithAbstraction.Modifier,
+ override val modifier: WithAbstraction.Modifier?,
override val platformData: List<PlatformData>,
override val extra: PropertyContainer<Class> = PropertyContainer.empty()
) : Classlike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes,
@@ -206,7 +208,7 @@ data class Function(
override val type: TypeWrapper,
override val generics: List<TypeParameter>,
override val receiver: Parameter?,
- override val modifier: WithAbstraction.Modifier,
+ override val modifier: WithAbstraction.Modifier?,
override val platformData: List<PlatformData>,
override val extra: PropertyContainer<Function> = PropertyContainer.empty()
) : Documentable(), Callable, WithGenerics, WithExtraProperties<Function> {
@@ -285,8 +287,8 @@ data class Property(
override val type: TypeWrapper,
override val receiver: Parameter?,
val setter: Function?,
- val getter: Function,
- override val modifier: WithAbstraction.Modifier,
+ val getter: Function?,
+ override val modifier: WithAbstraction.Modifier?,
override val platformData: List<PlatformData>,
override val extra: PropertyContainer<Property> = PropertyContainer.empty()
) : Documentable(), Callable, WithExtraProperties<Property> {
@@ -348,4 +350,4 @@ sealed class DocumentableSource(val path: String)
class DescriptorDocumentableSource(val descriptor: DeclarationDescriptor) :
DocumentableSource(descriptor.toSourceElement.containingFile.toString())
-class PsiDocumentableSource(val psi: PsiNamedElement) : DocumentableSource(psi.containingFile.virtualFile.path) \ No newline at end of file
+class PsiDocumentableSource(val psi: PsiNamedElement) : DocumentableSource(psi.containingFile.virtualFile.path)
diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt
new file mode 100644
index 00000000..38a06451
--- /dev/null
+++ b/core/src/main/kotlin/model/documentableProperties.kt
@@ -0,0 +1,14 @@
+package org.jetbrains.dokka.model
+
+import org.jetbrains.dokka.model.properties.ExtraProperty
+import org.jetbrains.dokka.model.properties.MergeStrategy
+
+data class InheritedFunction(val isInherited: Boolean): ExtraProperty<Function> {
+ object InheritedFunctionKey: ExtraProperty.Key<Function, Boolean> {
+ override fun mergeStrategyFor(left: Boolean, right: Boolean) = MergeStrategy.Fail {
+ throw IllegalArgumentException("Function inheritance should be consistent!")
+ }
+ }
+ override val key: ExtraProperty.Key<Function, Boolean> =
+ InheritedFunctionKey
+} \ No newline at end of file
diff --git a/core/src/main/kotlin/model/properties/PropertyContainer.kt b/core/src/main/kotlin/model/properties/PropertyContainer.kt
index 50216278..d30c6844 100644
--- a/core/src/main/kotlin/model/properties/PropertyContainer.kt
+++ b/core/src/main/kotlin/model/properties/PropertyContainer.kt
@@ -1,16 +1,15 @@
package org.jetbrains.dokka.model.properties
-import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
class PropertyContainer<C : Any> internal constructor(
- @PublishedApi internal val map: Map<Property.Key<C, *>, Property<C>>
+ @PublishedApi internal val map: Map<ExtraProperty.Key<C, *>, ExtraProperty<C>>
) {
- operator fun <D : C> plus(prop: Property<D>): PropertyContainer<D> =
+ operator fun <D : C> plus(prop: ExtraProperty<D>): PropertyContainer<D> =
PropertyContainer(map + (prop.key to prop))
// TODO: Add logic for caching calculated properties
- inline operator fun <reified T : Any> get(key: Property.Key<C, T>): T? = when (val prop = map[key]) {
+ inline operator fun <reified T : Any> get(key: ExtraProperty.Key<C, T>): T? = when (val prop = map[key]) {
is T? -> prop
else -> throw ClassCastException("Property for $key stored under not matching key type.")
}
@@ -27,7 +26,7 @@ interface WithExtraProperties<C : Any> {
}
fun <C> C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperties<C> {
- val aggregatedExtras: List<List<Property<C>>> =
+ val aggregatedExtras: List<List<ExtraProperty<C>>> =
(left.extra.map.values + right.extra.map.values)
.groupBy { it.key }
.values
@@ -37,12 +36,12 @@ fun <C> C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperti
@Suppress("UNCHECKED_CAST")
val strategies: List<MergeStrategy<C>> = toMerge.map { (l, r) ->
- (l.key as Property.Key<C, Property<C>>).mergeStrategyFor(l, r)
+ (l.key as ExtraProperty.Key<C, ExtraProperty<C>>).mergeStrategyFor(l, r)
}
strategies.firstIsInstanceOrNull<MergeStrategy.Fail>()?.error?.invoke()
- val replaces: List<Property<C>> = strategies.filterIsInstance<MergeStrategy.Replace<C>>().map { it.newProperty }
+ val replaces: List<ExtraProperty<C>> = strategies.filterIsInstance<MergeStrategy.Replace<C>>().map { it.newProperty }
val needingFullMerge: List<(preMerged: C, left: C, right: C) -> C> =
strategies.filterIsInstance<MergeStrategy.Full<C>>().map { it.merger }
diff --git a/core/src/main/kotlin/model/properties/properties.kt b/core/src/main/kotlin/model/properties/properties.kt
index 4ca44926..83f8d63d 100644
--- a/core/src/main/kotlin/model/properties/properties.kt
+++ b/core/src/main/kotlin/model/properties/properties.kt
@@ -1,6 +1,6 @@
package org.jetbrains.dokka.model.properties
-interface Property<in C : Any> {
+interface ExtraProperty<in C : Any> {
interface Key<in C: Any, T: Any> {
fun mergeStrategyFor(left: T, right: T): MergeStrategy<C> = MergeStrategy.Fail {
throw NotImplementedError("Property merging for $this is not implemented")
@@ -9,12 +9,12 @@ interface Property<in C : Any> {
val key: Key<C, *>
}
-interface CalculatedProperty<in C: Any, T: Any>: Property.Key<C, T> {
+interface CalculatedProperty<in C: Any, T: Any>: ExtraProperty.Key<C, T> {
fun calculate(subject: C): T
}
sealed class MergeStrategy<in C> {
- class Replace<in C : Any>(val newProperty: Property<C>): MergeStrategy<C>()
+ class Replace<in C : Any>(val newProperty: ExtraProperty<C>): MergeStrategy<C>()
object Remove: MergeStrategy<Any>()
class Full<C: Any>(val merger: (preMerged: C, left: C, right: C) -> C): MergeStrategy<C>()
class Fail(val error: () -> Nothing): MergeStrategy<Any>()
diff --git a/core/src/main/kotlin/model/typeWrappers.kt b/core/src/main/kotlin/model/typeWrappers.kt
index 5719c6d3..b26a3f6d 100644
--- a/core/src/main/kotlin/model/typeWrappers.kt
+++ b/core/src/main/kotlin/model/typeWrappers.kt
@@ -94,4 +94,8 @@ class JavaTypeWrapper : TypeWrapper {
override fun toString(): String {
return constructorFqName.orEmpty()
}
+
+ companion object {
+ val VOID = JavaTypeWrapper(listOf("void"), listOf(), null, true)
+ }
}