aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-20 09:39:50 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-20 12:02:45 +0200
commit68cba1e81a6bc971e0cd0be535232cc99756cd81 (patch)
tree6e78aa1aecac8d718c42db926a2ac1bd0ce402f6 /core/src/main/kotlin
parent13edb873db122e2088207ca10b94382e30875636 (diff)
downloaddokka-68cba1e81a6bc971e0cd0be535232cc99756cd81.tar.gz
dokka-68cba1e81a6bc971e0cd0be535232cc99756cd81.tar.bz2
dokka-68cba1e81a6bc971e0cd0be535232cc99756cd81.zip
Align json representation of filepaths
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r--core/src/main/kotlin/utilities/json.kt26
1 files changed, 18 insertions, 8 deletions
diff --git a/core/src/main/kotlin/utilities/json.kt b/core/src/main/kotlin/utilities/json.kt
index d2e70d75..2096879a 100644
--- a/core/src/main/kotlin/utilities/json.kt
+++ b/core/src/main/kotlin/utilities/json.kt
@@ -1,19 +1,26 @@
package org.jetbrains.dokka.utilities
import com.fasterxml.jackson.core.JsonGenerator
-import com.fasterxml.jackson.databind.*
-import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper
+import com.fasterxml.jackson.core.JsonParser
+import com.fasterxml.jackson.databind.DeserializationContext
+import com.fasterxml.jackson.databind.DeserializationFeature
+import com.fasterxml.jackson.databind.SerializerProvider
+import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer
import com.fasterxml.jackson.databind.module.SimpleModule
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
+import org.jetbrains.dokka.DokkaConfiguration.SourceRoot
+import org.jetbrains.dokka.SourceRootImpl
import java.io.File
-import java.lang.reflect.Type
import com.fasterxml.jackson.core.type.TypeReference as JacksonTypeReference
private val objectMapper = run {
val module = SimpleModule().apply {
addSerializer(FileSerializer)
+ addSerializer(SourceRoot::class.java, SourceRootSerializer)
+ addDeserializer(SourceRootImpl::class.java, SourceRootImplDeserializer)
+ addDeserializer(SourceRoot::class.java, SourceRootImplDeserializer)
}
jacksonObjectMapper()
.registerModule(module)
@@ -47,13 +54,16 @@ private object FileSerializer : StdScalarSerializer<File>(File::class.java) {
override fun serialize(value: File, g: JsonGenerator, provider: SerializerProvider) {
g.writeString(value.path)
}
+}
- override fun getSchema(provider: SerializerProvider, typeHint: Type): JsonNode {
- return createSchemaNode("string", true)
+private object SourceRootSerializer : StdScalarSerializer<SourceRoot>(SourceRoot::class.java) {
+ override fun serialize(value: SourceRoot, g: JsonGenerator, provider: SerializerProvider) {
+ g.writeString(value.path)
}
+}
- @Throws(JsonMappingException::class)
- override fun acceptJsonFormatVisitor(visitor: JsonFormatVisitorWrapper, typeHint: JavaType) {
- visitStringFormat(visitor, typeHint)
+private object SourceRootImplDeserializer : StdScalarDeserializer<SourceRootImpl>(SourceRootImpl::class.java) {
+ override fun deserialize(p: JsonParser, ctxt: DeserializationContext): SourceRootImpl {
+ return SourceRootImpl(p.text)
}
}