diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2020-12-03 11:28:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-03 11:28:59 +0100 |
commit | 80d8991fc572bd145e873ae368dca0b201e069cf (patch) | |
tree | 56addb1dec1817087dafbe9e55bbe6149c577073 | |
parent | 166b4e69854e238c5b7f0a0d999825312129c24f (diff) | |
download | dokka-80d8991fc572bd145e873ae368dca0b201e069cf.tar.gz dokka-80d8991fc572bd145e873ae368dca0b201e069cf.tar.bz2 dokka-80d8991fc572bd145e873ae368dca0b201e069cf.zip |
Bump compiler to 1.4.20, IJ to 201 and coroutines to 1.4.1 (#1641)
9 files changed, 37 insertions, 148 deletions
diff --git a/gradle.properties b/gradle.properties index fb6b6c8e..d38be368 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,11 +3,11 @@ dokka_version_base=1.4.20 dokka_publication_channels=bintray-kotlin-dev&space-dokka-dev dokka_integration_test_parallelism=2 # Versions -kotlin_version=1.4.10 -coroutines_version=1.3.9 +kotlin_version=1.4.20 +coroutines_version=1.4.1 kotlinx_html_version=0.7.2 -kotlin_plugin_version=1.4.10-release-411 -idea_version=193.6494.35 +kotlin_plugin_version=1.4.20-release-327 +idea_version=201.7223.91 language_version=1.4 # Code style kotlin.code.style=official diff --git a/kotlin-analysis/intellij-dependency/build.gradle.kts b/kotlin-analysis/intellij-dependency/build.gradle.kts index 8e080374..c82248ec 100644 --- a/kotlin-analysis/intellij-dependency/build.gradle.kts +++ b/kotlin-analysis/intellij-dependency/build.gradle.kts @@ -16,13 +16,13 @@ repositories { val intellijCore: Configuration by configurations.creating fun intellijCoreAnalysis() = zipTree(intellijCore.singleFile).matching { - include("intellij-core-analysis.jar") + include("intellij-core-analysis-deprecated.jar") } dependencies { val kotlin_plugin_version: String by project - api("org.jetbrains.kotlin:ide-common-ij193:$kotlin_plugin_version") - api("org.jetbrains.kotlin:kotlin-plugin-ij193:$kotlin_plugin_version") { + api("org.jetbrains.kotlin:ide-common-ij201:$kotlin_plugin_version") + api("org.jetbrains.kotlin:kotlin-plugin-ij201:$kotlin_plugin_version") { //TODO: parametrize ij version after 1.3.70 isTransitive = false } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt index cb65b168..d516d57d 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/AnalysisEnvironment.kt @@ -170,7 +170,8 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl JvmIdePlatformKind, JsIdePlatformKind, NativeIdePlatformKind - ) + ), + this ) registerExtensionPoint( @@ -180,7 +181,8 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl JvmPlatformKindResolution(), JsPlatformKindResolution(), NativePlatformKindResolution() - ) + ), + this ) return environment @@ -563,13 +565,14 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl companion object { private fun <T : Any> registerExtensionPoint( appExtension: ApplicationExtensionDescriptor<T>, - instances: List<T> + instances: List<T>, + disposable: Disposable ) { if (Extensions.getRootArea().hasExtensionPoint(appExtension.extensionPointName)) return appExtension.registerExtensionPoint() - instances.forEach(appExtension::registerExtension) + instances.forEach { extension -> appExtension.registerExtension(extension, disposable) } } } } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreProjectFileIndex.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreProjectFileIndex.kt index 346a305e..77be818c 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreProjectFileIndex.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreProjectFileIndex.kt @@ -508,6 +508,10 @@ class CoreProjectRootManager(val projectFileIndex: CoreProjectFileIndex) : Proje throw UnsupportedOperationException() } + override fun setProjectSdkName(p0: String, p1: String) { + throw UnsupportedOperationException() + } + override fun getModuleSourceRoots(p0: MutableSet<out JpsModuleSourceRootType<*>>): MutableList<VirtualFile> { throw UnsupportedOperationException() } @@ -522,6 +526,10 @@ class CoreProjectRootManager(val projectFileIndex: CoreProjectFileIndex) : Proje throw UnsupportedOperationException() } + override fun getProjectSdkTypeName(): String? { + throw UnsupportedOperationException() + } + override fun getProjectSdk(): Sdk? { throw UnsupportedOperationException() } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaNativeKlibLibraryInfo.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaNativeKlibLibraryInfo.kt index a5ee5217..0b56f187 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaNativeKlibLibraryInfo.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaNativeKlibLibraryInfo.kt @@ -5,6 +5,7 @@ import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.konan.DeserializedKlibModuleOrigin import org.jetbrains.kotlin.descriptors.konan.KlibModuleOrigin +import org.jetbrains.kotlin.descriptors.ModuleCapability import org.jetbrains.kotlin.idea.klib.safeRead import org.jetbrains.kotlin.library.KotlinLibrary import org.jetbrains.kotlin.library.isInterop @@ -38,11 +39,11 @@ internal class DokkaNativeKlibLibraryInfo( override fun dependencies(): List<ModuleInfo> = listOf(this) + dependencyResolver.resolveDependencies(this) override fun getLibraryRoots(): Collection<String> = listOf(libraryRoot) - override val capabilities: Map<ModuleDescriptor.Capability<*>, Any?> + override val capabilities: Map<ModuleCapability<*>, Any?> get() { val capabilities = super.capabilities.toMutableMap() - capabilities += KlibModuleOrigin.CAPABILITY to DeserializedKlibModuleOrigin(kotlinLibrary) - capabilities += ImplicitIntegerCoercion.MODULE_CAPABILITY to kotlinLibrary.safeRead(false) { isInterop } + capabilities[KlibModuleOrigin.CAPABILITY] = DeserializedKlibModuleOrigin(kotlinLibrary) + capabilities[ImplicitIntegerCoercion.MODULE_CAPABILITY] = kotlinLibrary.safeRead(false) { isInterop } return capabilities } } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaResolutionFacade.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaResolutionFacade.kt index 6bf4990c..2c19fb9f 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaResolutionFacade.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DokkaResolutionFacade.kt @@ -1,3 +1,5 @@ +@file:OptIn(FrontendInternals::class) + package org.jetbrains.dokka.analysis import com.google.common.collect.ImmutableMap @@ -11,6 +13,7 @@ import org.jetbrains.kotlin.container.getService import org.jetbrains.kotlin.container.tryGetService import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor +import org.jetbrains.kotlin.idea.FrontendInternals import org.jetbrains.kotlin.idea.resolve.ResolutionFacade import org.jetbrains.kotlin.psi.KtDeclaration import org.jetbrains.kotlin.psi.KtElement @@ -34,6 +37,7 @@ class DokkaResolutionFacade( throw UnsupportedOperationException() } + @OptIn(FrontendInternals::class) override fun <T : Any> tryGetFrontendService(element: PsiElement, serviceClass: Class<T>): T? { return resolverForModule.componentProvider.tryGetService(serviceClass) } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/JavaResolveExtension.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/JavaResolveExtension.kt deleted file mode 100644 index ab6bec9c..00000000 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/JavaResolveExtension.kt +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2010-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:JvmName("JavaResolutionUtils") - -package org.jetbrains.dokka.analysis - -import com.intellij.psi.* -import org.jetbrains.kotlin.asJava.unwrapped -import org.jetbrains.kotlin.caches.resolve.KotlinCacheService -import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.idea.resolve.ResolutionFacade -import org.jetbrains.kotlin.incremental.components.NoLookupLocation -import org.jetbrains.kotlin.load.java.sources.JavaSourceElement -import org.jetbrains.kotlin.load.java.structure.* -import org.jetbrains.kotlin.load.java.structure.impl.* -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.platform.jvm.JvmPlatforms -import org.jetbrains.kotlin.psi.KtDeclaration -import org.jetbrains.kotlin.resolve.jvm.JavaDescriptorResolver -import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter -import org.jetbrains.kotlin.resolve.scopes.MemberScope - -// TODO: Remove that file - -@JvmOverloads -fun PsiMethod.getJavaMethodDescriptor(resolutionFacade: ResolutionFacade = javaResolutionFacade()): DeclarationDescriptor? { - val method = originalElement as? PsiMethod ?: return null - if (method.containingClass == null || !Name.isValidIdentifier(method.name)) return null - val resolver = method.getJavaDescriptorResolver(resolutionFacade) - return when { - method.isConstructor -> resolver?.resolveConstructor(JavaConstructorImpl(method)) - else -> resolver?.resolveMethod(JavaMethodImpl(method)) - } -} - -@JvmOverloads -fun PsiClass.getJavaClassDescriptor(resolutionFacade: ResolutionFacade = javaResolutionFacade()): ClassDescriptor? { - val psiClass = originalElement as? PsiClass ?: return null - return psiClass.getJavaDescriptorResolver(resolutionFacade)?.resolveClass(JavaClassImpl(psiClass)) -} - -@JvmOverloads -fun PsiField.getJavaFieldDescriptor(resolutionFacade: ResolutionFacade = javaResolutionFacade()): PropertyDescriptor? { - val field = originalElement as? PsiField ?: return null - return field.getJavaDescriptorResolver(resolutionFacade)?.resolveField(JavaFieldImpl(field)) -} - -@JvmOverloads -fun PsiMember.getJavaMemberDescriptor(resolutionFacade: ResolutionFacade = javaResolutionFacade()): DeclarationDescriptor? { - return when (this) { - is PsiEnumConstant -> containingClass?.getJavaClassDescriptor(resolutionFacade) - is PsiClass -> getJavaClassDescriptor(resolutionFacade) - is PsiMethod -> getJavaMethodDescriptor(resolutionFacade) - is PsiField -> getJavaFieldDescriptor(resolutionFacade) - else -> null - } -} - -@JvmOverloads -fun PsiMember.getJavaOrKotlinMemberDescriptor(resolutionFacade: ResolutionFacade = javaResolutionFacade()): DeclarationDescriptor? { - val callable = unwrapped - return when (callable) { - is PsiMember -> getJavaMemberDescriptor(resolutionFacade) - is KtDeclaration -> { - val descriptor = resolutionFacade.resolveToDescriptor(callable) - if (descriptor is ClassDescriptor && this is PsiMethod) descriptor.unsubstitutedPrimaryConstructor else descriptor - } - else -> null - } -} - -private fun PsiElement.getJavaDescriptorResolver(resolutionFacade: ResolutionFacade): JavaDescriptorResolver? { - return resolutionFacade.tryGetFrontendService(this, JavaDescriptorResolver::class.java) -} - -private fun JavaDescriptorResolver.resolveMethod(method: JavaMethod): DeclarationDescriptor? { - return getContainingScope(method) - ?.getContributedDescriptors(nameFilter = { true }, kindFilter = DescriptorKindFilter.CALLABLES) - ?.filterIsInstance<DeclarationDescriptorWithSource>() - ?.findByJavaElement(method) -} - -private fun JavaDescriptorResolver.resolveConstructor(constructor: JavaConstructor): ConstructorDescriptor? { - return resolveClass(constructor.containingClass)?.constructors?.findByJavaElement(constructor) -} - -private fun JavaDescriptorResolver.resolveField(field: JavaField): PropertyDescriptor? { - return getContainingScope(field)?.getContributedVariables(field.name, NoLookupLocation.FROM_IDE)?.findByJavaElement(field) -} - -private fun JavaDescriptorResolver.getContainingScope(member: JavaMember): MemberScope? { - val containingClass = resolveClass(member.containingClass) - return if (member.isStatic) - containingClass?.staticScope - else - containingClass?.defaultType?.memberScope -} - -private fun <T : DeclarationDescriptorWithSource> Collection<T>.findByJavaElement(javaElement: JavaElement): T? { - return firstOrNull { member -> - val memberJavaElement = (member.original.source as? JavaSourceElement)?.javaElement - when { - memberJavaElement == javaElement -> - true - memberJavaElement is JavaElementImpl<*> && javaElement is JavaElementImpl<*> -> - memberJavaElement.psi.isEquivalentTo(javaElement.psi) - else -> - false - } - } -} - -fun PsiElement.javaResolutionFacade() = - KotlinCacheService.getInstance(project).getResolutionFacadeByFile(this.originalElement.containingFile, JvmPlatforms.defaultJvmPlatform)!! diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 17cd493a..642f991f 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -994,11 +994,11 @@ private class DokkaDescriptorVisitor( get() = ancestry.exceptionsInSupertypes() } - private fun Visibility.toDokkaVisibility(): org.jetbrains.dokka.model.Visibility = when (this) { - Visibilities.PUBLIC -> KotlinVisibility.Public - Visibilities.PROTECTED -> KotlinVisibility.Protected - Visibilities.INTERNAL -> KotlinVisibility.Internal - Visibilities.PRIVATE -> KotlinVisibility.Private + private fun DescriptorVisibility.toDokkaVisibility(): org.jetbrains.dokka.model.Visibility = when (this.delegate) { + Visibilities.Public -> KotlinVisibility.Public + Visibilities.Protected -> KotlinVisibility.Protected + Visibilities.Internal -> KotlinVisibility.Internal + Visibilities.Private -> KotlinVisibility.Private else -> KotlinVisibility.Public } diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt index bf7fbe7d..61af1db1 100644 --- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt @@ -38,6 +38,7 @@ import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot import org.jetbrains.kotlin.descriptors.Visibilities +import org.jetbrains.kotlin.descriptors.java.JavaVisibilities import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaClassDescriptor import org.jetbrains.kotlin.idea.refactoring.fqName.getKotlinFqName import org.jetbrains.kotlin.load.java.JvmAbi @@ -185,7 +186,7 @@ class DefaultPsiToDocumentableTranslator( it.methods.forEach { method -> val hash = method.hash if (!method.isConstructor && !superMethodsKeys.contains(hash) && - method.getVisibility() != Visibilities.PRIVATE + method.getVisibility() != JavaVisibility.Private ) { superMethodsKeys.add(hash) superMethods.add(Pair(method, definedAt)) |