diff options
author | Błażej Kardyś <bkardys@virtuslab.com> | 2020-10-18 23:04:26 +0200 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2020-11-09 14:56:24 +0100 |
commit | be80016c77e9b98a75d8e832dd5723737f0e1d72 (patch) | |
tree | d4a1124e9278fcfb3a1c1b00cf743d8553ded011 /plugins/kotlin-as-java/src/main | |
parent | 1aba0ec4973d7915caa93f1e9b3146ad82111903 (diff) | |
download | dokka-be80016c77e9b98a75d8e832dd5723737f0e1d72.tar.gz dokka-be80016c77e9b98a75d8e832dd5723737f0e1d72.tar.bz2 dokka-be80016c77e9b98a75d8e832dd5723737f0e1d72.zip |
Cleaning querying from plugins where possible
Diffstat (limited to 'plugins/kotlin-as-java/src/main')
3 files changed, 23 insertions, 18 deletions
diff --git a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt index 04a63fca..b390751c 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/KotlinAsJavaPlugin.kt @@ -12,19 +12,12 @@ class KotlinAsJavaPlugin : DokkaPlugin() { CoreExtensions.documentableTransformer with KotlinAsJavaDocumentableTransformer() } val javaSignatureProvider by extending { - val dokkaBasePlugin = plugin<DokkaBase>() - dokkaBasePlugin.signatureProvider providing { ctx -> - JavaSignatureProvider(ctx.single(dokkaBasePlugin.commentsToContentConverter), ctx.logger) - } override dokkaBasePlugin.kotlinSignatureProvider + with(plugin<DokkaBase>()) { + signatureProvider providing ::JavaSignatureProvider override kotlinSignatureProvider + } } val kotlinAsJavaDocumentableToPageTranslator by extending { - val dokkaBasePlugin = plugin<DokkaBase>() - CoreExtensions.documentableToPageTranslator providing { ctx -> - KotlinAsJavaDocumentableToPageTranslator( - ctx.single(dokkaBasePlugin.commentsToContentConverter), - ctx.single(dokkaBasePlugin.signatureProvider), - ctx.logger - ) - } override dokkaBasePlugin.documentableToPageTranslator + CoreExtensions.documentableToPageTranslator providing ::KotlinAsJavaDocumentableToPageTranslator override + plugin<DokkaBase>().documentableToPageTranslator } }
\ No newline at end of file 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 1d62a206..60c2e5cc 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka.kotlinAsJava.signatures +import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.signatures.JvmSignatureUtils import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter @@ -11,11 +12,18 @@ import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.ContentKind import org.jetbrains.dokka.pages.ContentNode import org.jetbrains.dokka.pages.TextStyle +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.utilities.DokkaLogger import kotlin.text.Typography.nbsp -class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider, +class JavaSignatureProvider internal constructor(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider, JvmSignatureUtils by JavaSignatureUtils { + constructor(context: DokkaContext) : this( + context.plugin<DokkaBase>().querySingle { commentsToContentConverter }, + context.logger + ) private val contentBuilder = PageContentBuilder(ctcc, this, logger) private val ignoredVisibilities = setOf(JavaVisibility.Default) diff --git a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt index cfb4daa3..ac526d57 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/translators/KotlinAsJavaDocumentableToPageTranslator.kt @@ -1,17 +1,21 @@ package org.jetbrains.dokka.kotlinAsJava.translators +import org.jetbrains.dokka.base.DokkaBase import org.jetbrains.dokka.base.signatures.SignatureProvider import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter import org.jetbrains.dokka.transformers.documentation.DocumentableToPageTranslator import org.jetbrains.dokka.model.DModule import org.jetbrains.dokka.pages.ModulePageNode +import org.jetbrains.dokka.plugability.DokkaContext +import org.jetbrains.dokka.plugability.plugin +import org.jetbrains.dokka.plugability.querySingle import org.jetbrains.dokka.utilities.DokkaLogger -class KotlinAsJavaDocumentableToPageTranslator( - private val commentsToContentConverter: CommentsToContentConverter, - private val signatureProvider: SignatureProvider, - private val logger: DokkaLogger -) : DocumentableToPageTranslator { +class KotlinAsJavaDocumentableToPageTranslator(context: DokkaContext) : DocumentableToPageTranslator { + private val commentsToContentConverter = context.plugin<DokkaBase>().querySingle { commentsToContentConverter } + private val signatureProvider = context.plugin<DokkaBase>().querySingle { signatureProvider } + private val logger: DokkaLogger = context.logger + override fun invoke(module: DModule): ModulePageNode = KotlinAsJavaPageCreator(commentsToContentConverter, signatureProvider, logger).pageForModule(module) }
\ No newline at end of file |