aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorFilip Zybała <fzybala@virtuslab.com>2020-03-20 15:27:30 +0100
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-03-26 12:36:03 +0100
commit8a87b5e0bd2eda12f4e44512e3f8856c72e53b3e (patch)
tree75b10c56bd933e2cfdcf0c32492ce9d6b61b1533 /plugins
parent8ef04b5d6bb46a5fbd9cea9b8d08048bc9f03879 (diff)
downloaddokka-8a87b5e0bd2eda12f4e44512e3f8856c72e53b3e.tar.gz
dokka-8a87b5e0bd2eda12f4e44512e3f8856c72e53b3e.tar.bz2
dokka-8a87b5e0bd2eda12f4e44512e3f8856c72e53b3e.zip
Changed modifier to PlatformDependent
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt9
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt15
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt1
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt7
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt23
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt4
6 files changed, 34 insertions, 25 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index c40c5b7c..d87152d5 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -34,10 +34,9 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
private fun signature(c: DClasslike) = contentBuilder.contentFor(c, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
if (c is DClass) {
- if (c.extra[AdditionalModifiers]?.content?.contains(ExtraModifiers.DATA) == true) {
- text("data ")
- } else {
- text(c.modifier.name + " ")
+ platformText(c.modifier){
+ if (c.extra[AdditionalModifiers]?.content?.contains(ExtraModifiers.DATA) == true && it.name == "final") "data "
+ else it.name + " "
}
}
when (c) {
@@ -72,7 +71,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
private fun signature(f: DFunction) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
platformText(f.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
- text(f.modifier.name + " ")
+ platformText(f.modifier) { it.name }
text("fun ")
list(f.generics, prefix = "<", suffix = "> ") {
+buildSignature(it)
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index ccee7269..bed6c25c 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -233,7 +233,8 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
else PlatformDependent.from(platformData,info.supertypes),
generics = descriptor.typeConstructor.parameters.map { it.toTypeParameter() },
documentation = info.docs,
- modifier = descriptor.modifier(),
+ modifier = if(isExpect) PlatformDependent.expectFrom(descriptor.modifier())
+ else PlatformDependent.from(platformData, descriptor.modifier()),
companion = descriptor.companion(driWithPlatform),
platformData = listOf(platformData),
extra = PropertyContainer.withAll(descriptor.additionalExtras(), descriptor.getAnnotations())
@@ -261,7 +262,8 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
visibility = if(isExpect) PlatformDependent.expectFrom(descriptor.visibility.toDokkaVisibility())
else PlatformDependent.from(platformData,descriptor.visibility.toDokkaVisibility()),
documentation = descriptor.resolveDescriptorData(if (!isExpect) platformData else null),
- modifier = descriptor.modifier(),
+ modifier = if(isExpect) PlatformDependent.expectFrom(descriptor.modifier())
+ else PlatformDependent.from(platformData, descriptor.modifier()),
type = descriptor.returnType!!.toBound(),
platformData = listOf(platformData),
extra = PropertyContainer.withAll(descriptor.additionalExtras(), descriptor.getAnnotations())
@@ -288,7 +290,8 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
else PlatformDependent.from(platformData,descriptor.visibility.toDokkaVisibility()),
generics = descriptor.typeParameters.map { it.toTypeParameter() },
documentation = descriptor.resolveDescriptorData(if (!isExpect) platformData else null),
- modifier = descriptor.modifier(),
+ modifier = if(isExpect) PlatformDependent.expectFrom(descriptor.modifier())
+ else PlatformDependent.from(platformData, descriptor.modifier()),
type = descriptor.returnType!!.toBound(),
platformData = listOf(platformData),
extra = PropertyContainer.withAll(descriptor.additionalExtras(), descriptor.getAnnotations())
@@ -315,7 +318,8 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
else PlatformDependent.from(platformData,descriptor.visibility.toDokkaVisibility()),
documentation = descriptor.resolveDescriptorData(if (!isExpect) platformData else null),
type = descriptor.returnType.toBound(),
- modifier = descriptor.modifier(),
+ modifier = if(isExpect) PlatformDependent.expectFrom(descriptor.modifier())
+ else PlatformDependent.from(platformData, descriptor.modifier()),
generics = descriptor.typeParameters.map { it.toTypeParameter() },
platformData = listOf(platformData),
extra = PropertyContainer.withAll<DFunction>(descriptor.additionalExtras(), descriptor.getAnnotations()).let {
@@ -377,7 +381,8 @@ private class DokkaDescriptorVisitor( // TODO: close this class and make it priv
documentation = descriptor.resolveDescriptorData(if (!isExpect) platformData else null),
type = descriptor.returnType!!.toBound(),
generics = descriptor.typeParameters.map { it.toTypeParameter() },
- modifier = descriptor.modifier(),
+ modifier = if(isExpect) PlatformDependent.expectFrom(descriptor.modifier())
+ else PlatformDependent.from(platformData, descriptor.modifier()),
receiver = descriptor.extensionReceiverParameter?.let {
visitReceiverParameterDescriptor(
it,
diff --git a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
index 3f3ebe3a..b9e02398 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/DefaultPageCreator.kt
@@ -166,6 +166,7 @@ open class DefaultPageCreator(
protected open fun contentForFunction(f: DFunction) = contentBuilder.contentFor(f) {
header(1) { text(f.name) }
platformDependentHint(f.dri, f.platformData.toSet()){
+ if(f.sources.expect != null) text("actual")
+buildSignature(f)
+contentForComments(f)
}
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 218f8c82..ee862fb8 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -122,6 +122,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
val classlikes = innerClasses.map { parseClasslike(it, dri) }
val visibility = getVisibility().toPlatformDependant()
val ancestors = ancestorsSet.toList().toPlatformDependant()
+ val modifiers = getModifier().toPlatformDependant()
return when {
isAnnotationType ->
DAnnotation(
@@ -193,7 +194,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
mapTypeParameters(dri),
ancestors,
documentation,
- getModifier(),
+ modifiers,
listOf(platformData),
PropertyContainer.empty<DClass>() + annotations.toList().toExtra()
)
@@ -226,7 +227,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
psi.returnType?.let { getBound(type = it) } ?: Void,
psi.mapTypeParameters(dri),
null,
- psi.getModifier(),
+ psi.getModifier().toPlatformDependant(),
listOf(platformData),
PropertyContainer.withAll(
InheritedFunction(isInherited),
@@ -339,7 +340,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
null,
accessors.firstOrNull { it.hasParameters() }?.let { parseFunction(it, parent) },
accessors.firstOrNull { it.returnType == psi.type }?.let { parseFunction(it, parent) },
- psi.getModifier(),
+ psi.getModifier().toPlatformDependant(),
listOf(platformData),
PropertyContainer.empty<DProperty>() + psi.annotations.toList().toExtra()
)
diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
index 6de3f121..dac937c0 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
@@ -47,7 +47,7 @@ internal fun DPackage.asJava(): DPackage {
generics = emptyList(),
supertypes = PlatformDependent.empty(),
documentation = PlatformDependent.empty(),
- modifier = JavaModifier.Final,
+ modifier = PlatformDependent(map = platformData.map{ it to JavaModifier.Final}.toMap()),
platformData = platformData,
extra = PropertyContainer.empty()
)
@@ -68,9 +68,9 @@ internal fun DProperty.asJava(isTopLevel: Boolean = false, relocateToClass: Stri
dri.withClass(relocateToClass)
},
modifier = if (setter == null) {
- JavaModifier.Final
+ PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap())
} else {
- JavaModifier.Empty
+ PlatformDependent(map = platformData.map{it to JavaModifier.Empty}.toMap())
},
visibility = visibility.copy(
map = visibility.mapValues { JavaVisibility.Private }
@@ -91,9 +91,9 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas
},
name = "get" + name.capitalize(),
modifier = if (setter == null) {
- JavaModifier.Final
+ PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap())
} else {
- JavaModifier.Empty
+ PlatformDependent(map = platformData.map{it to JavaModifier.Empty}.toMap())
},
visibility = visibility.copy(
map = visibility.mapValues { JavaVisibility.Public }
@@ -109,9 +109,9 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas
},
name = "set" + name.capitalize(),
modifier = if (setter == null) {
- JavaModifier.Final
+ PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap())
} else {
- JavaModifier.Empty
+ PlatformDependent(map = platformData.map{it to JavaModifier.Empty}.toMap())
},
visibility = visibility.copy(
map = visibility.mapValues { JavaVisibility.Public }
@@ -131,7 +131,9 @@ internal fun DFunction.asJava(containingClassName: String): DFunction {
// dri = dri.copy(callable = dri.callable?.asJava()),
name = newName,
type = type.asJava(),
- modifier = if(modifier is KotlinModifier.Final && isConstructor) JavaModifier.Empty else modifier,
+ modifier = if(modifier.all{(_,v)-> v is KotlinModifier.Final} && isConstructor)
+ PlatformDependent(map = platformData.map{it to JavaModifier.Empty}.toMap())
+ else PlatformDependent(map = platformData.map{it to modifier.allValues.first()}.toMap()),
parameters = listOfNotNull(receiver?.asJava()) + parameters.map { it.asJava() },
receiver = null
) // TODO static if toplevel
@@ -157,7 +159,8 @@ internal fun DClass.asJava(): DClass = copy(
supertypes = supertypes.copy(
map = supertypes.mapValues { it.value.map { it.possiblyAsJava() } }
),
- modifier = if (modifier is KotlinModifier.Empty) JavaModifier.Final else modifier
+ modifier = if (modifier.all{(_,v) -> v is KotlinModifier.Empty}) PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap())
+ else PlatformDependent(map = platformData.map{it to modifier.allValues.first()}.toMap())
)
private fun DTypeParameter.asJava(): DTypeParameter = copy(
@@ -195,7 +198,7 @@ internal fun DObject.asJava(): DObject = copy(
properties = properties.map { it.asJava() } +
DProperty(
name = "INSTANCE",
- modifier = JavaModifier.Final,
+ modifier = PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap()),
dri = dri.copy(callable = Callable("INSTANCE", null, emptyList())),
documentation = PlatformDependent.empty(),
sources = PlatformDependent.empty(),
diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
index 6a571660..54bf663d 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -33,7 +33,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
if (c is DClass) {
- text(c.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ")
+ platformText(c.modifier){ it.takeIf{it !in ignoredModifiers}?.name.orEmpty() + " "}
}
when (c) {
@@ -63,7 +63,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
}
private fun signature(f: DFunction) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
- text(f.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ")
+ platformText(f.modifier){ it.takeIf{it !in ignoredModifiers}?.name.orEmpty() + " "}
val returnType = f.type
signatureForProjection(returnType)
text(" ")