diff options
Diffstat (limited to 'kotlin-analysis')
8 files changed, 34 insertions, 10 deletions
diff --git a/kotlin-analysis/compiler-dependency/build.gradle.kts b/kotlin-analysis/compiler-dependency/build.gradle.kts index 779fbfd2..63e0fb5a 100644 --- a/kotlin-analysis/compiler-dependency/build.gradle.kts +++ b/kotlin-analysis/compiler-dependency/build.gradle.kts @@ -16,7 +16,7 @@ tasks { val dokka_version: String by project archiveFileName.set("dokka-kotlin-analysis-compiler-$dokka_version.jar") archiveClassifier.set("") - exclude("**/intellij**") + exclude("com/intellij/") } } diff --git a/kotlin-analysis/intellij-dependency/build.gradle.kts b/kotlin-analysis/intellij-dependency/build.gradle.kts index b2ee35e1..09c47ef5 100644 --- a/kotlin-analysis/intellij-dependency/build.gradle.kts +++ b/kotlin-analysis/intellij-dependency/build.gradle.kts @@ -19,7 +19,14 @@ repositories { val intellijCore: Configuration by configurations.creating fun intellijCoreAnalysis() = zipTree(intellijCore.singleFile).matching { - include("intellij-core-analysis-deprecated.jar") + include("intellij-core.jar") +} + +val jpsStandalone: Configuration by configurations.creating + +fun jpsModel() = zipTree(jpsStandalone.singleFile).matching { + include("jps-model.jar") + include("aalto-xml-*.jar") } dependencies { @@ -34,6 +41,9 @@ dependencies { val idea_version: String by project intellijCore("com.jetbrains.intellij.idea:intellij-core:$idea_version") implementation(intellijCoreAnalysis()) + + jpsStandalone("com.jetbrains.intellij.idea:jps-standalone:$idea_version") + implementation(jpsModel()) } tasks { 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 48162097..9efa66fb 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 @@ -542,6 +542,8 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl } } + // Set up JDK classpath roots explicitly because of https://github.com/JetBrains/kotlin/commit/f89765eb33dd95c8de33a919cca83651b326b246 + fun configureJdkClasspathRoots() = configuration.configureJdkClasspathRoots() /** * Adds path to classpath. * $path: path to add diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreKotlinCacheService.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreKotlinCacheService.kt index 12cc3351..e2cd328a 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreKotlinCacheService.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/CoreKotlinCacheService.kt @@ -15,6 +15,10 @@ class CoreKotlinCacheService(private val resolutionFacade: DokkaResolutionFacade return resolutionFacade } + override fun getResolutionFacade(element: KtElement): ResolutionFacade { + return resolutionFacade + } + override fun getResolutionFacadeByFile( file: PsiFile, platform: org.jetbrains.kotlin.platform.TargetPlatform diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt index 90958ff3..60ad3315 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/EnvironmentAndFacade.kt @@ -17,7 +17,7 @@ internal fun createEnvironmentAndFacade( ): EnvironmentAndFacade = AnalysisEnvironment(DokkaMessageCollector(logger), sourceSet.analysisPlatform).run { if (analysisPlatform == Platform.jvm) { - addClasspath(PathUtil.getJdkClassesRootsFromCurrentJre()) + configureJdkClasspathRoots() } val parentSourceSets = sourceSets.filter { it.sourceSetID in sourceSet.dependentSourceSets } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/JvmDependenciesIndexImpl.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/JvmDependenciesIndexImpl.kt index c64f2fab..1075665e 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/JvmDependenciesIndexImpl.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/JvmDependenciesIndexImpl.kt @@ -209,6 +209,7 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>) : JvmDependenciesIndex { val fileExtension = when (rootType) { JavaRoot.RootType.BINARY -> JavaClassFileType.INSTANCE.defaultExtension + JavaRoot.RootType.BINARY_SIG -> "sig" JavaRoot.RootType.SOURCE -> JavaFileType.INSTANCE.defaultExtension } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinCliJavaFileManagerImpl.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinCliJavaFileManagerImpl.kt index 5955c3e4..37a5e3f7 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinCliJavaFileManagerImpl.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/KotlinCliJavaFileManagerImpl.kt @@ -90,7 +90,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ val (classId, classFileContentFromRequest, outerClassFromRequest) = request val virtualFile = findVirtualFileForTopLevelClass(classId, searchScope) ?: return null - if (!usePsiClassFilesReading && virtualFile.extension == "class") { + if (!usePsiClassFilesReading && (virtualFile.extension == "class" || virtualFile.extension == "sig")) { synchronized(binaryCache){ // We return all class files' names in the directory in knownClassNamesInPackage method, so one may request an inner class return binaryCache.getOrPut(classId) { @@ -215,6 +215,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ val vFile = when (rootType) { JavaRoot.RootType.BINARY -> packageDir.findChild("$topLevelClassName.class") + JavaRoot.RootType.BINARY_SIG -> packageDir.findChild("$topLevelClassName.sig") JavaRoot.RootType.SOURCE -> packageDir.findChild("$topLevelClassName.java") } ?: return null @@ -235,7 +236,7 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ val result = THashSet<String>() index.traverseDirectoriesInPackage(packageFqName, continueSearch = { dir, _ -> for (child in dir.children) { - if (child.extension == "class" || child.extension == "java") { + if (child.extension == "class" || child.extension == "java" || child.extension == "sig") { result.add(child.nameWithoutExtension) } } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/TypeReferenceFactory.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/TypeReferenceFactory.kt index 22660ecc..091e54ce 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/TypeReferenceFactory.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/TypeReferenceFactory.kt @@ -9,7 +9,9 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.scopes.receivers.ExtensionReceiver import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeProjection -import org.jetbrains.kotlin.types.UnresolvedType +import org.jetbrains.kotlin.types.error.ErrorType +import org.jetbrains.kotlin.types.error.ErrorTypeConstructor +import org.jetbrains.kotlin.types.error.ErrorTypeKind fun TypeReference.Companion.from(d: ReceiverParameterDescriptor): TypeReference? = when (d.value) { @@ -35,10 +37,14 @@ private fun TypeReference.Companion.fromPossiblyRecursive(t: KotlinType, paramTr ?: from(t, paramTrace) private fun TypeReference.Companion.from(t: KotlinType, paramTrace: List<KotlinType>): TypeReference { - if (t is UnresolvedType) { - return TypeConstructor( - t.presentableName, t.arguments.map { fromProjection(it, paramTrace) } - ) + if (t is ErrorType) { + val errorConstructor = t.constructor as? ErrorTypeConstructor + val presentableName = + if (errorConstructor?.kind == ErrorTypeKind.UNRESOLVED_TYPE && errorConstructor.parameters.isNotEmpty()) + errorConstructor.getParam(0) + else + t.constructor.toString() + return TypeConstructor(presentableName, t.arguments.map { fromProjection(it, paramTrace) }) } return when (val d = t.constructor.declarationDescriptor) { is TypeParameterDescriptor -> TypeParam( |