aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Utilities
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2019-10-31 15:26:20 +0100
committerPaweł Marks <pmarks@virtuslab.com>2019-10-31 15:26:20 +0100
commit50111daf07c7afd1c1b60e9672ed6786c96efdea (patch)
tree0b4420c2dc74b48c6cea577421d3fbfd3b18d95b /core/src/main/kotlin/Utilities
parent7c30624e3d0868346823b15b5cea5e29a56357f2 (diff)
downloaddokka-50111daf07c7afd1c1b60e9672ed6786c96efdea.tar.gz
dokka-50111daf07c7afd1c1b60e9672ed6786c96efdea.tar.bz2
dokka-50111daf07c7afd1c1b60e9672ed6786c96efdea.zip
Make things compile, no matter the cost
Diffstat (limited to 'core/src/main/kotlin/Utilities')
-rw-r--r--core/src/main/kotlin/Utilities/DokkaModules.kt82
1 files changed, 0 insertions, 82 deletions
diff --git a/core/src/main/kotlin/Utilities/DokkaModules.kt b/core/src/main/kotlin/Utilities/DokkaModules.kt
deleted file mode 100644
index 94fc5c62..00000000
--- a/core/src/main/kotlin/Utilities/DokkaModules.kt
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.jetbrains.dokka.Utilities
-
-import com.google.inject.Binder
-import com.google.inject.Module
-import com.google.inject.TypeLiteral
-import com.google.inject.binder.AnnotatedBindingBuilder
-import com.google.inject.name.Names
-import org.jetbrains.dokka.*
-import org.jetbrains.dokka.Formats.FormatDescriptor
-import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
-import java.io.File
-import kotlin.reflect.KClass
-
-const val impliedPlatformsName = "impliedPlatforms"
-
-class DokkaRunModule(val configuration: DokkaConfiguration) : Module {
- override fun configure(binder: Binder) {
- binder.bind<DokkaConfiguration>().toInstance(configuration)
- binder.bind(StringListType).annotatedWith(Names.named(impliedPlatformsName)).toInstance(configuration.impliedPlatforms)
-
- binder.bind(File::class.java).annotatedWith(Names.named("outputDir")).toInstance(File(configuration.outputDir))
- }
-
-}
-
-class DokkaAnalysisModule(val environment: AnalysisEnvironment,
- val configuration: DokkaConfiguration,
- val defaultPlatformsProvider: DefaultPlatformsProvider,
- val passConfiguration: DokkaConfiguration.PassConfiguration,
- val logger: DokkaLogger) : Module {
- override fun configure(binder: Binder) {
- binder.bind<DokkaLogger>().toInstance(logger)
-
- val coreEnvironment = environment.createCoreEnvironment()
- binder.bind<KotlinCoreEnvironment>().toInstance(coreEnvironment)
-
- val (dokkaResolutionFacade, libraryResolutionFacade) = environment.createResolutionFacade(coreEnvironment)
- binder.bind<DokkaResolutionFacade>().toInstance(dokkaResolutionFacade)
- binder.bind<DokkaResolutionFacade>().annotatedWith(Names.named("libraryResolutionFacade")).toInstance(libraryResolutionFacade)
-
- binder.bind<DokkaConfiguration.PassConfiguration>().toInstance(passConfiguration)
-
- binder.bind<DefaultPlatformsProvider>().toInstance(defaultPlatformsProvider)
-
- val descriptor = ServiceLocator.lookup<FormatDescriptor>("format", configuration.format)
- descriptor.configureAnalysis(binder)
- }
-}
-
-object StringListType : TypeLiteral<@JvmSuppressWildcards List<String>>()
-
-class DokkaOutputModule(val configuration: DokkaConfiguration,
- val logger: DokkaLogger) : Module {
- override fun configure(binder: Binder) {
- binder.bind<DokkaLogger>().toInstance(logger)
-
- val descriptor = ServiceLocator.lookup<FormatDescriptor>("format", configuration.format)
-
- descriptor.configureOutput(binder)
- }
-}
-
-private inline fun <reified T: Any> Binder.registerCategory(category: String) {
- ServiceLocator.allServices(category).forEach {
- @Suppress("UNCHECKED_CAST")
- bind(T::class.java).annotatedWith(Names.named(it.name)).to(T::class.java.classLoader.loadClass(it.className) as Class<T>)
- }
-}
-
-private inline fun <reified Base : Any, reified T : Base> Binder.bindNameAnnotated(name: String) {
- bind(Base::class.java).annotatedWith(Names.named(name)).to(T::class.java)
-}
-
-
-inline fun <reified T: Any> Binder.bind(): AnnotatedBindingBuilder<T> = bind(T::class.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)