aboutsummaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-12-11 16:01:51 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-12-11 16:01:51 +0300
commit6ef35accd16533c84be5d0164739b146cfb55b73 (patch)
tree08564235782d2cebd0203da0ab82e860c2111b05 /core/src
parent214e16e07d93b3565c433ed67b78796e80f43ec5 (diff)
downloaddokka-6ef35accd16533c84be5d0164739b146cfb55b73.tar.gz
dokka-6ef35accd16533c84be5d0164739b146cfb55b73.tar.bz2
dokka-6ef35accd16533c84be5d0164739b146cfb55b73.zip
Fix optional binding
Diffstat (limited to 'core/src')
-rw-r--r--core/src/main/kotlin/Formats/FormatDescriptor.kt10
-rw-r--r--core/src/main/kotlin/Utilities/DokkaModules.kt6
2 files changed, 10 insertions, 6 deletions
diff --git a/core/src/main/kotlin/Formats/FormatDescriptor.kt b/core/src/main/kotlin/Formats/FormatDescriptor.kt
index aa00df97..a1120c00 100644
--- a/core/src/main/kotlin/Formats/FormatDescriptor.kt
+++ b/core/src/main/kotlin/Formats/FormatDescriptor.kt
@@ -3,6 +3,7 @@ package org.jetbrains.dokka.Formats
import com.google.inject.Binder
import org.jetbrains.dokka.*
import org.jetbrains.dokka.Utilities.bind
+import org.jetbrains.dokka.Utilities.lazyBind
import org.jetbrains.dokka.Utilities.toOptional
import org.jetbrains.dokka.Utilities.toType
import kotlin.reflect.KClass
@@ -23,11 +24,12 @@ abstract class FileGeneratorBasedFormatDescriptor : FormatDescriptor {
override fun configureOutput(binder: Binder): Unit = with(binder) {
bind<Generator>() toType NodeLocationAwareGenerator::class
-
- bind<OutlineFormatService>() toOptional (outlineServiceClass)
- bind<FormatService>() toOptional formatServiceClass
bind<NodeLocationAwareGenerator>() toType generatorServiceClass
- bind<PackageListService>() toOptional packageListServiceClass
+
+
+ lazyBind<OutlineFormatService>() toOptional (outlineServiceClass)
+ lazyBind<FormatService>() toOptional formatServiceClass
+ lazyBind<PackageListService>() toOptional packageListServiceClass
}
abstract val formatServiceClass: KClass<out FormatService>?
diff --git a/core/src/main/kotlin/Utilities/DokkaModules.kt b/core/src/main/kotlin/Utilities/DokkaModules.kt
index 6b5e153e..763e29a9 100644
--- a/core/src/main/kotlin/Utilities/DokkaModules.kt
+++ b/core/src/main/kotlin/Utilities/DokkaModules.kt
@@ -73,7 +73,9 @@ private inline fun <reified Base : Any, reified T : Base> Binder.bindNameAnnotat
inline fun <reified T: Any> Binder.bind(): AnnotatedBindingBuilder<T> = bind(T::class.java)
-inline infix fun <reified T: Any, TKClass: KClass<out T>> AnnotatedBindingBuilder<T>.toOptional(kClass: TKClass?) =
- kClass?.let { to(it.java) }
+inline fun <reified T: Any> Binder.lazyBind(): Lazy<AnnotatedBindingBuilder<T>> = lazy { bind(T::class.java) }
+
+inline infix fun <reified T: Any, TKClass: KClass<out T>> Lazy<AnnotatedBindingBuilder<T>>.toOptional(kClass: TKClass?) =
+ kClass?.let { value toType it }
inline infix fun <reified T: Any, TKClass: KClass<out T>> AnnotatedBindingBuilder<T>.toType(kClass: TKClass) = to(kClass.java)