Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DynamicTypeDeserializer #2645

Merged
merged 2 commits into from Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,6 +1,8 @@
@file:Suppress("unused")

import org.w3c.dom.url.URLSearchParams
import org.w3c.dom.HTMLAnchorElement
import react.dom.html.AnchorHTMLAttributes
import react.Props
import react.State

Expand All @@ -18,4 +20,7 @@ fun test(list: MutableList<Int>) = "list"

@JsModule("is-sorted")
@JsNonModule
external fun <T> sorted(a: Array<T>): Boolean
external fun <T> sorted(a: Array<T>): Boolean

// this declaration can be used to check deserialization of dynamic type
external interface TextLinkProps: AnchorHTMLAttributes<HTMLAnchorElement>
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
@@ -1,7 +1,7 @@
package org.jetbrains.dokka.analysis.resolve

import org.jetbrains.kotlin.analyzer.*
import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns
import org.jetbrains.kotlin.builtins.DefaultBuiltIns
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.container.StorageComponentContainer
import org.jetbrains.kotlin.container.get
Expand All @@ -14,14 +14,15 @@ import org.jetbrains.kotlin.idea.klib.createKlibPackageFragmentProvider
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.js.resolve.JsPlatformAnalyzerServices
import org.jetbrains.kotlin.konan.util.KlibMetadataFactories
import org.jetbrains.kotlin.library.metadata.NullFlexibleTypeDeserializer
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
import org.jetbrains.kotlin.resolve.SealedClassInheritorsProvider
import org.jetbrains.kotlin.resolve.TargetEnvironment
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactoryService
import org.jetbrains.kotlin.serialization.js.DynamicTypeDeserializer
import org.jetbrains.kotlin.serialization.js.KotlinJavascriptSerializationUtil
import org.jetbrains.kotlin.serialization.js.createKotlinJavascriptPackageFragmentProvider
import org.jetbrains.kotlin.serialization.konan.impl.KlibMetadataModuleDescriptorFactoryImpl
import org.jetbrains.kotlin.utils.KotlinJavascriptMetadataUtils
import java.io.File

Expand All @@ -30,7 +31,14 @@ internal class DokkaJsResolverForModuleFactory(
private val targetEnvironment: TargetEnvironment
) : ResolverForModuleFactory() {
companion object {
private val metadataFactories = KlibMetadataFactories(::KonanBuiltIns, NullFlexibleTypeDeserializer)
private val metadataFactories = KlibMetadataFactories({ DefaultBuiltIns.Instance }, DynamicTypeDeserializer)

private val metadataModuleDescriptorFactory = KlibMetadataModuleDescriptorFactoryImpl(
metadataFactories.DefaultDescriptorFactory,
metadataFactories.DefaultPackageFragmentsFactory,
metadataFactories.flexibleTypeDeserializer,
metadataFactories.platformDependentTypeTransformer
)
}

override fun <M : ModuleInfo> createResolverForModule(
Expand Down Expand Up @@ -82,7 +90,7 @@ internal class DokkaJsResolverForModuleFactory(
moduleInfo.kotlinLibrary
.createKlibPackageFragmentProvider(
storageManager = moduleContext.storageManager,
metadataModuleDescriptorFactory = metadataFactories.DefaultDeserializedDescriptorFactory,
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
metadataModuleDescriptorFactory = metadataModuleDescriptorFactory,
languageVersionSettings = languageVersionSettings,
moduleDescriptor = moduleDescriptor,
lookupTracker = LookupTracker.DO_NOTHING
Expand Down