aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2015-10-30 12:24:33 +0100
committerDmitry Jemerov <yole@jetbrains.com>2015-10-30 12:24:33 +0100
commitf60beb6e45720ff44ba4e4db915f5e462fb3b907 (patch)
treed19fcbb67842486cd111f26e9527027e94ac896f /src
parentaf5cd353271120a6ef9853a3913d5e828747178e (diff)
downloaddokka-f60beb6e45720ff44ba4e4db915f5e462fb3b907.tar.gz
dokka-f60beb6e45720ff44ba4e4db915f5e462fb3b907.tar.bz2
dokka-f60beb6e45720ff44ba4e4db915f5e462fb3b907.zip
fix Kotlin warnings
Diffstat (limited to 'src')
-rw-r--r--src/Formats/StandardFormats.kt20
-rw-r--r--src/Generation/Generator.kt18
-rw-r--r--src/Java/JavaDocumentationBuilder.kt2
-rw-r--r--src/Utilities/GuiceModule.kt22
-rw-r--r--src/Utilities/ServiceLocator.kt16
-rw-r--r--src/main.kt4
6 files changed, 39 insertions, 43 deletions
diff --git a/src/Formats/StandardFormats.kt b/src/Formats/StandardFormats.kt
index 1d5ffe13..658735c0 100644
--- a/src/Formats/StandardFormats.kt
+++ b/src/Formats/StandardFormats.kt
@@ -4,44 +4,44 @@ import org.jetbrains.dokka.*
class HtmlFormatDescriptor : FormatDescriptor {
override val formatServiceClass: Class<out FormatService>
- get() = javaClass<HtmlFormatService>()
+ get() = HtmlFormatService::class.java
override val outlineServiceClass: Class<out OutlineFormatService>
- get() = javaClass<HtmlFormatService>()
+ get() = HtmlFormatService::class.java
override val generatorServiceClass: Class<out Generator>
- get() = javaClass<FileGenerator>()
+ get() = FileGenerator::class.java
}
class KotlinWebsiteFormatDescriptor : FormatDescriptor {
override val formatServiceClass: Class<out FormatService>
- get() = javaClass<KotlinWebsiteFormatService>()
+ get() = KotlinWebsiteFormatService::class.java
override val outlineServiceClass: Class<out OutlineFormatService>
- get() = javaClass<YamlOutlineService>()
+ get() = YamlOutlineService::class.java
override val generatorServiceClass: Class<out Generator>
- get() = javaClass<FileGenerator>()
+ get() = FileGenerator::class.java
}
class JekyllFormatDescriptor : FormatDescriptor {
override val formatServiceClass: Class<out FormatService>
- get() = javaClass<JekyllFormatService>()
+ get() = JekyllFormatService::class.java
override val outlineServiceClass: Class<out OutlineFormatService>?
get() = null
override val generatorServiceClass: Class<out Generator>
- get() = javaClass<FileGenerator>()
+ get() = FileGenerator::class.java
}
class MarkdownFormatDescriptor : FormatDescriptor {
override val formatServiceClass: Class<out FormatService>
- get() = javaClass<MarkdownFormatService>()
+ get() = MarkdownFormatService::class.java
override val outlineServiceClass: Class<out OutlineFormatService>?
get() = null
override val generatorServiceClass: Class<out Generator>
- get() = javaClass<FileGenerator>()
+ get() = FileGenerator::class.java
}
diff --git a/src/Generation/Generator.kt b/src/Generation/Generator.kt
index 7dcabb0b..d7db1c52 100644
--- a/src/Generation/Generator.kt
+++ b/src/Generation/Generator.kt
@@ -3,13 +3,15 @@ package org.jetbrains.dokka
public interface Generator {
fun buildPages(nodes: Iterable<DocumentationNode>)
fun buildOutlines(nodes: Iterable<DocumentationNode>)
+}
- final fun buildAll(nodes: Iterable<DocumentationNode>) {
- buildPages(nodes)
- buildOutlines(nodes)
- }
-
- final fun buildPage(node: DocumentationNode): Unit = buildPages(listOf(node))
- final fun buildOutline(node: DocumentationNode): Unit = buildOutlines(listOf(node))
- final fun buildAll(node: DocumentationNode): Unit = buildAll(listOf(node))
+fun Generator.buildAll(nodes: Iterable<DocumentationNode>) {
+ buildPages(nodes)
+ buildOutlines(nodes)
}
+
+fun Generator.buildPage(node: DocumentationNode): Unit = buildPages(listOf(node))
+
+fun Generator.buildOutline(node: DocumentationNode): Unit = buildOutlines(listOf(node))
+
+fun Generator.buildAll(node: DocumentationNode): Unit = buildAll(listOf(node))
diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt
index 88c13d38..f3cedc07 100644
--- a/src/Java/JavaDocumentationBuilder.kt
+++ b/src/Java/JavaDocumentationBuilder.kt
@@ -192,7 +192,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions,
is PsiField -> element.containingClass!!.qualifiedName + "#" + element.name
is PsiMethod ->
element.containingClass!!.qualifiedName + "#" + element.name + "(" +
- element.parameterList.parameters.map { it.type.typeSignature() }.join(",") + ")"
+ element.parameterList.parameters.map { it.type.typeSignature() }.joinToString(",") + ")"
else -> null
}
diff --git a/src/Utilities/GuiceModule.kt b/src/Utilities/GuiceModule.kt
index 57bad468..855d70b6 100644
--- a/src/Utilities/GuiceModule.kt
+++ b/src/Utilities/GuiceModule.kt
@@ -10,8 +10,8 @@ import java.io.File
class GuiceModule(val config: DokkaGenerator) : Module {
override fun configure(binder: Binder) {
- binder.bind(javaClass<DokkaGenerator>()).toInstance(config)
- binder.bind(javaClass<File>()).annotatedWith(Names.named("outputDir")).toInstance(File(config.outputDir))
+ binder.bind(DokkaGenerator::class.java).toInstance(config)
+ binder.bind(File::class.java).annotatedWith(Names.named("outputDir")).toInstance(File(config.outputDir))
binder.bindNameAnnotated<LocationService, SingleFolderLocationService>("singleFolder")
binder.bindNameAnnotated<FileLocationService, SingleFolderLocationService>("singleFolder")
@@ -19,11 +19,11 @@ class GuiceModule(val config: DokkaGenerator) : Module {
binder.bindNameAnnotated<FileLocationService, FoldersLocationService>("folders")
// defaults
- binder.bind(javaClass<LocationService>()).to(javaClass<FoldersLocationService>())
- binder.bind(javaClass<FileLocationService>()).to(javaClass<FoldersLocationService>())
- binder.bind(javaClass<LanguageService>()).to(javaClass<KotlinLanguageService>())
+ 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(javaClass<HtmlTemplateService>()).toProvider(object : Provider<HtmlTemplateService> {
+ binder.bind(HtmlTemplateService::class.java).toProvider(object : Provider<HtmlTemplateService> {
override fun get(): HtmlTemplateService = HtmlTemplateService.default("/dokka/styles/style.css")
})
@@ -35,12 +35,12 @@ class GuiceModule(val config: DokkaGenerator) : Module {
val descriptor = ServiceLocator.lookup<FormatDescriptor>("format", config.outputFormat, config)
descriptor.outlineServiceClass?.let { clazz ->
- binder.bind(javaClass<OutlineFormatService>()).to(clazz)
+ binder.bind(OutlineFormatService::class.java).to(clazz)
}
descriptor.formatServiceClass?.let { clazz ->
- binder.bind(javaClass<FormatService>()).to(clazz)
+ binder.bind(FormatService::class.java).to(clazz)
}
- binder.bind(javaClass<Generator>()).to(descriptor.generatorServiceClass)
+ binder.bind(Generator::class.java).to(descriptor.generatorServiceClass)
}
}
@@ -48,11 +48,11 @@ class GuiceModule(val config: DokkaGenerator) : Module {
private inline fun <reified T: Any> Binder.registerCategory(category: String) {
ServiceLocator.allServices(category).forEach {
@Suppress("UNCHECKED_CAST")
- bind(javaClass<T>()).annotatedWith(Names.named(it.name)).to(javaClass<T>().classLoader.loadClass(it.className) as Class<T>)
+ 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(javaClass<Base>()).annotatedWith(Names.named(name)).to(javaClass<T>())
+ bind(Base::class.java).annotatedWith(Names.named(name)).to(T::class.java)
}
diff --git a/src/Utilities/ServiceLocator.kt b/src/Utilities/ServiceLocator.kt
index bc04238f..57d2f47b 100644
--- a/src/Utilities/ServiceLocator.kt
+++ b/src/Utilities/ServiceLocator.kt
@@ -15,8 +15,8 @@ public object ServiceLocator {
val descriptor = lookupDescriptor(category, implementationName)
val loadedClass = javaClass.classLoader.loadClass(descriptor.className)
val constructor = loadedClass.constructors
- .filter { it.parameterTypes.isEmpty() || (it.parameterTypes.size() == 1 && conf.javaClass.isInstance(it.parameterTypes[0])) }
- .sortedByDescending { it.parameterTypes.size() }
+ .filter { it.parameterTypes.isEmpty() || (it.parameterTypes.size == 1 && conf.javaClass.isInstance(it.parameterTypes[0])) }
+ .sortedByDescending { it.parameterTypes.size }
.firstOrNull() ?: throw ServiceLookupException("Class ${descriptor.className} has no corresponding constructor")
val implementationRawType: Any = if (constructor.parameterTypes.isEmpty()) constructor.newInstance() else constructor.newInstance(constructor)
@@ -81,20 +81,14 @@ public object ServiceLocator {
} ?: emptyList()
}
-public inline fun <reified T : Any> ServiceLocator.lookup(category: String, implementationName: String, conf: DokkaGenerator): T = lookup(javaClass<T>(), category, implementationName, conf)
-public inline fun <reified T : Any> ServiceLocator.lookupClass(category: String, implementationName: String): Class<T> = lookupClass(javaClass<T>(), category, implementationName)
+public inline fun <reified T : Any> ServiceLocator.lookup(category: String, implementationName: String, conf: DokkaGenerator): T = lookup(T::class.java, category, implementationName, conf)
+public inline fun <reified T : Any> ServiceLocator.lookupClass(category: String, implementationName: String): Class<T> = lookupClass(T::class.java, category, implementationName)
public inline fun <reified T : Any> ServiceLocator.lookupOrNull(category: String, implementationName: String, conf: DokkaGenerator): T? = try {
- lookup(javaClass<T>(), category, implementationName, conf)
+ lookup(T::class.java, category, implementationName, conf)
} catch (any: Throwable) {
null
}
-fun main(args: Array<String>) {
- ServiceLocator.allServices("format").forEach {
- println(it)
- }
-}
-
private val ZipEntry.fileName: String
get() = name.substringAfterLast("/", name)
diff --git a/src/main.kt b/src/main.kt
index a534ffdd..1d2442f2 100644
--- a/src/main.kt
+++ b/src/main.kt
@@ -146,7 +146,7 @@ class DokkaGenerator(val logger: DokkaLogger,
logger.info("Module: $moduleName")
logger.info("Output: ${File(outputDir).absolutePath}")
- logger.info("Sources: ${environment.sources.join()}")
+ logger.info("Sources: ${environment.sources.joinToString()}")
logger.info("Classpath: ${environment.classpath.joinToString()}")
logger.info("Analysing sources and libraries... ")
@@ -160,7 +160,7 @@ class DokkaGenerator(val logger: DokkaLogger,
val timeBuild = measureTimeMillis {
logger.info("Generating pages... ")
- Guice.createInjector(GuiceModule(this)).getInstance(javaClass<Generator>()).buildAll(documentation)
+ Guice.createInjector(GuiceModule(this)).getInstance(Generator::class.java).buildAll(documentation)
}
logger.info("done in ${timeBuild / 1000} secs")