From 84ea5c68420a75c7b8401000dbe6dbf3ff2cd6d0 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 4 Nov 2015 16:26:07 +0100 Subject: @Inject all the things --- src/Utilities/GuiceModule.kt | 65 -------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 src/Utilities/GuiceModule.kt (limited to 'src/Utilities/GuiceModule.kt') diff --git a/src/Utilities/GuiceModule.kt b/src/Utilities/GuiceModule.kt deleted file mode 100644 index e852ae19..00000000 --- a/src/Utilities/GuiceModule.kt +++ /dev/null @@ -1,65 +0,0 @@ -package org.jetbrains.dokka.Utilities - -import com.google.inject.Binder -import com.google.inject.Module -import com.google.inject.Provider -import com.google.inject.name.Names -import com.google.inject.util.Providers -import org.jetbrains.dokka.* -import org.jetbrains.dokka.Formats.FormatDescriptor -import java.io.File - -class GuiceModule(val config: DokkaGenerator) : Module { - override fun configure(binder: Binder) { - binder.bind(DokkaGenerator::class.java).toInstance(config) - binder.bind(File::class.java).annotatedWith(Names.named("outputDir")).toInstance(File(config.outputDir)) - - binder.bindNameAnnotated("singleFolder") - binder.bindNameAnnotated("singleFolder") - binder.bindNameAnnotated("folders") - binder.bindNameAnnotated("folders") - - // defaults - binder.bind(LocationService::class.java).to(FoldersLocationService::class.java) - binder.bind(FileLocationService::class.java).to(FoldersLocationService::class.java) - binder.bind(LanguageService::class.java).to(KotlinLanguageService::class.java) - - binder.bind(HtmlTemplateService::class.java).toProvider(object : Provider { - override fun get(): HtmlTemplateService = HtmlTemplateService.default("/dokka/styles/style.css") - }) - - binder.registerCategory("language") - binder.registerCategory("outline") - binder.registerCategory("format") - binder.registerCategory("generator") - - val descriptor = ServiceLocator.lookup("format", config.outputFormat, config) - - descriptor.outlineServiceClass?.let { clazz -> - binder.bind(OutlineFormatService::class.java).to(clazz) - } - descriptor.formatServiceClass?.let { clazz -> - binder.bind(FormatService::class.java).to(clazz) - } - if (descriptor.packageDocumentationBuilderServiceClass != null) { - binder.bind(PackageDocumentationBuilder::class.java).to(descriptor.packageDocumentationBuilderServiceClass) - } else { - binder.bind(PackageDocumentationBuilder::class.java).toProvider(Providers.of(null)) - } - - binder.bind(Generator::class.java).to(descriptor.generatorServiceClass) - } - -} - -private inline fun 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) - } -} - -private inline fun Binder.bindNameAnnotated(name: String) { - bind(Base::class.java).annotatedWith(Names.named(name)).to(T::class.java) -} - -- cgit