diff options
author | Goooler <wangzongler@gmail.com> | 2022-02-21 22:01:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-21 17:01:06 +0300 |
commit | f5b7797255576e5f1c230e2ca3fcb5f4e602387c (patch) | |
tree | 25fd98250066c4ed6c2fff1104be533604bbf1b9 /kotlin-analysis/src | |
parent | df4780c31026aaa626746f49f0e6fa3fa0278a05 (diff) | |
download | dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.gz dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.tar.bz2 dokka-f5b7797255576e5f1c230e2ca3fcb5f4e602387c.zip |
Code cleanups (#2165)
Diffstat (limited to 'kotlin-analysis/src')
7 files changed, 18 insertions, 16 deletions
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 909bc0c9..0d159374 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 @@ -428,10 +428,10 @@ class AnalysisEnvironment(val messageCollector: MessageCollector, val analysisPl builtIns: KotlinBuiltIns ): ResolverForProject<ModuleInfo> { val javaRoots = classpath - .mapNotNull { - val rootFile = when (it.extension) { - "jar" -> StandardFileSystems.jar().findFileByPath("${it.absolutePath}$JAR_SEPARATOR") - else -> StandardFileSystems.local().findFileByPath(it.absolutePath) + .mapNotNull { file -> + val rootFile = when (file.extension) { + "jar" -> StandardFileSystems.jar().findFileByPath("${file.absolutePath}$JAR_SEPARATOR") + else -> StandardFileSystems.local().findFileByPath(file.absolutePath) } rootFile?.let { JavaRoot(it, JavaRoot.RootType.BINARY) } } 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 bebbc705..d560feff 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 @@ -1,7 +1,6 @@ package org.jetbrains.dokka.analysis import com.intellij.psi.PsiFile -import org.jetbrains.dokka.analysis.DokkaResolutionFacade import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.caches.resolve.KotlinCacheService import org.jetbrains.kotlin.caches.resolve.PlatformAnalysisSettings @@ -25,21 +24,21 @@ class CoreKotlinCacheService(private val resolutionFacade: DokkaResolutionFacade override fun getResolutionFacadeByFile( file: PsiFile, platform: org.jetbrains.kotlin.platform.TargetPlatform - ): ResolutionFacade? { + ): ResolutionFacade { return resolutionFacade } override fun getResolutionFacadeByModuleInfo( moduleInfo: ModuleInfo, settings: PlatformAnalysisSettings - ): ResolutionFacade? { + ): ResolutionFacade { return resolutionFacade } override fun getResolutionFacadeByModuleInfo( moduleInfo: ModuleInfo, platform: org.jetbrains.kotlin.platform.TargetPlatform - ): ResolutionFacade? { + ): ResolutionFacade { return resolutionFacade } diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt index 33c99275..73b20885 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt @@ -11,7 +11,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs fun DRI.Companion.from(descriptor: DeclarationDescriptor) = descriptor.parentsWithSelf.run { val parameter = firstIsInstanceOrNull<ValueParameterDescriptor>() - val callable = parameter?.containingDeclaration ?: firstIsInstanceOrNull<CallableDescriptor>() + val callable = parameter?.containingDeclaration ?: firstIsInstanceOrNull() DRI( packageName = firstIsInstanceOrNull<PackageFragmentDescriptor>()?.fqName?.asString() ?: "", 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 9726e5b7..90958ff3 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 @@ -3,10 +3,12 @@ package org.jetbrains.dokka.analysis import org.jetbrains.dokka.DokkaConfiguration import org.jetbrains.dokka.Platform import org.jetbrains.dokka.utilities.DokkaLogger -import org.jetbrains.kotlin.cli.common.messages.* +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.utils.PathUtil -import java.io.File internal fun createEnvironmentAndFacade( logger: DokkaLogger, 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 021c6292..3632337a 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 @@ -121,11 +121,12 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>) : JvmDependenciesIndex { // NOTE: indices manipulation instead of using caches.reversed() is here for performance reasons for (cacheIndex in caches.lastIndex downTo 0) { val cacheRootIndices = caches[cacheIndex].rootIndices - for (i in 0..cacheRootIndices.size() - 1) { + for (i in 0 until cacheRootIndices.size()) { val rootIndex = cacheRootIndices[i] if (rootIndex <= processedRootsUpTo) continue // roots with those indices have been processed by now - val directoryInRoot = travelPath(rootIndex, request.packageFqName, packagesPath, cacheIndex, caches) ?: continue + val directoryInRoot = + travelPath(rootIndex, request.packageFqName, packagesPath, cacheIndex, caches) ?: continue val root = roots[rootIndex] if (root.type in request.acceptedRootTypes) { val result = handler(directoryInRoot, root.type) @@ -156,7 +157,7 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>) : JvmDependenciesIndex { cachesPath: List<Cache> ): VirtualFile? { if (rootIndex >= maxIndex) { - for (i in (fillCachesAfter + 1)..(cachesPath.size - 1)) { + for (i in (fillCachesAfter + 1) until cachesPath.size) { // we all know roots that contain this package by now cachesPath[i].rootIndices.add(maxIndex) cachesPath[i].rootIndices.trimToSize() 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 e62548d7..336b7566 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 @@ -20,7 +20,7 @@ fun TypeReference.Companion.from(d: ReceiverParameterDescriptor): TypeReference? } } -fun TypeReference.Companion.from(d: ValueParameterDescriptor): TypeReference? = +fun TypeReference.Companion.from(d: ValueParameterDescriptor): TypeReference = fromPossiblyNullable(d.type, emptyList()) fun TypeReference.Companion.from(p: PsiClass) = TypeReference diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/resolve/DokkaNativeKlibLibraryInfo.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/resolve/DokkaNativeKlibLibraryInfo.kt index 5e936533..e2b388a9 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/resolve/DokkaNativeKlibLibraryInfo.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/resolve/DokkaNativeKlibLibraryInfo.kt @@ -1,9 +1,9 @@ package org.jetbrains.dokka.analysis.resolve import org.jetbrains.kotlin.analyzer.ModuleInfo +import org.jetbrains.kotlin.descriptors.ModuleCapability 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 |