aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/model
diff options
context:
space:
mode:
authorSzymon Świstun <sswistun@virtuslab.com>2020-01-20 14:55:42 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-02-12 13:13:18 +0100
commit50e711d24b517bc93c37d89f258c9dafaa038ad1 (patch)
tree201c27b6860ac14b6ddc673ff099d74f53b4e15c /core/src/main/kotlin/model
parent5a432c9c62ff95779a495fb354c83f5f7c481a1d (diff)
downloaddokka-50e711d24b517bc93c37d89f258c9dafaa038ad1.tar.gz
dokka-50e711d24b517bc93c37d89f258c9dafaa038ad1.tar.bz2
dokka-50e711d24b517bc93c37d89f258c9dafaa038ad1.zip
kotlin-as-java plugin
Diffstat (limited to 'core/src/main/kotlin/model')
-rw-r--r--core/src/main/kotlin/model/Documentable.kt52
1 files changed, 36 insertions, 16 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt
index 86ba24b7..1744e27f 100644
--- a/core/src/main/kotlin/model/Documentable.kt
+++ b/core/src/main/kotlin/model/Documentable.kt
@@ -4,7 +4,9 @@ import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.doc.DocumentationNode
import org.jetbrains.dokka.pages.PlatformData
import org.jetbrains.dokka.transformers.descriptors.KotlinClassKindTypes
-import org.jetbrains.dokka.transformers.descriptors.KotlinTypeWrapper
+import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
+import org.jetbrains.kotlin.descriptors.Visibilities
+import org.jetbrains.kotlin.descriptors.Visibility
class Module(override val name: String, val packages: List<Package>) : Documentable() {
override val dri: DRI = DRI.topLevel
@@ -32,7 +34,8 @@ class Class(
override val classlikes: List<Classlike>,
override val expected: ClassPlatformInfo?,
override val actual: List<ClassPlatformInfo>,
- override val extra: MutableSet<Extra> = mutableSetOf()
+ override val extra: MutableSet<Extra> = mutableSetOf(),
+ override val visibility: Map<PlatformData, Visibility>
) : Classlike(
name = name,
dri = dri,
@@ -43,7 +46,7 @@ class Class(
expected = expected,
actual = actual,
extra = extra
-)
+), WithVisibility
class Enum(
override val dri: DRI,
@@ -55,8 +58,9 @@ class Enum(
override val classlikes: List<Classlike> = emptyList(),
override val expected: ClassPlatformInfo? = null,
override val actual: List<ClassPlatformInfo>,
- override val extra: MutableSet<Extra> = mutableSetOf()
-) : Classlike(dri = dri, name = name, kind = KotlinClassKindTypes.ENUM_CLASS, actual = actual) {
+ override val extra: MutableSet<Extra> = mutableSetOf(),
+ override val visibility: Map<PlatformData, Visibility>
+) : Classlike(dri = dri, name = name, kind = KotlinClassKindTypes.ENUM_CLASS, actual = actual), WithVisibility {
constructor(c: Classlike, entries: List<EnumEntry>, ctors: List<Function>) : this(
dri = c.dri,
name = c.name,
@@ -67,7 +71,8 @@ class Enum(
classlikes = c.classlikes,
expected = c.expected,
actual = c.actual,
- extra = c.extra
+ extra = c.extra,
+ visibility = c.visibility
)
override val children: List<Documentable>
@@ -79,7 +84,8 @@ class EnumEntry(
override val name: String,
override val expected: ClassPlatformInfo? = null,
override val actual: List<ClassPlatformInfo>,
- override val extra: MutableSet<Extra> = mutableSetOf()
+ override val extra: MutableSet<Extra> = mutableSetOf(),
+ override val visibility: Map<PlatformData, Visibility>
) : Classlike(
dri = dri,
name = name,
@@ -93,7 +99,8 @@ class EnumEntry(
name = c.name,
actual = c.actual,
expected = c.expected,
- extra = c.extra
+ extra = c.extra,
+ visibility = c.visibility
)
override val children: List<Parameter>
@@ -109,8 +116,9 @@ class Function(
val parameters: List<Parameter>,
override val expected: PlatformInfo?,
override val actual: List<PlatformInfo>,
- override val extra: MutableSet<Extra> = mutableSetOf()
-) : CallableNode() {
+ override val extra: MutableSet<Extra> = mutableSetOf(),
+ override val visibility: Map<PlatformData, Visibility>
+) : CallableNode(), WithVisibility {
override val children: List<Parameter>
get() = listOfNotNull(receiver) + parameters
}
@@ -121,8 +129,10 @@ class Property(
override val receiver: Parameter?,
override val expected: PlatformInfo?,
override val actual: List<PlatformInfo>,
- override val extra: MutableSet<Extra> = mutableSetOf()
-) : CallableNode() {
+ override val extra: MutableSet<Extra> = mutableSetOf(),
+ val accessors: List<Function>,
+ override val visibility: Map<PlatformData, Visibility>
+) : CallableNode(), WithVisibility {
override val children: List<Parameter>
get() = listOfNotNull(receiver)
}
@@ -208,7 +218,7 @@ abstract class Classlike(
override val expected: ClassPlatformInfo? = null,
override val actual: List<ClassPlatformInfo>,
override val extra: MutableSet<Extra> = mutableSetOf()
-) : ScopeNode() {
+) : ScopeNode(), WithVisibility {
val inherited by lazy { platformInfo.mapNotNull { (it as? ClassPlatformInfo)?.inherited }.flatten() }
}
@@ -217,8 +227,12 @@ abstract class ScopeNode : Documentable() {
abstract val properties: List<Property>
abstract val classlikes: List<Classlike>
- override val children: List<Documentable>
- get() = functions + properties + classlikes
+ override val children: List<Documentable> // It is written so awkwardly because of type inference being lost here
+ get() = mutableListOf<Documentable>().apply {
+ addAll(functions)
+ addAll(properties)
+ addAll(classlikes)
+ }
}
abstract class CallableNode : Documentable() {
@@ -235,6 +249,7 @@ interface TypeWrapper {
val arguments: List<TypeWrapper>
val dri: DRI?
}
+
interface ClassKind
fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? =
@@ -244,4 +259,9 @@ fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? =
this.children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull()
}
-interface Extra \ No newline at end of file
+interface Extra
+object STATIC : Extra
+
+interface WithVisibility {
+ val visibility: Map<PlatformData, Visibility>
+} \ No newline at end of file