[Analysis API] use createSearchScopeByLibraryRoots for test libraries

As it is more similar to production. Also, fixed scope search for klib.
Now we register main binary modules before to avoid duplication with
libraries from createLibrariesByCompilerConfigurators as now we can
have a declared library and regular sources

^KT-62888
^KT-62651
This commit is contained in:
Dmitrii Gridin
2024-01-02 18:58:12 +01:00
committed by Space Team
parent 02d99769ff
commit 8de9d42b0d
6 changed files with 45 additions and 14 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -53,6 +53,7 @@ import org.jetbrains.kotlin.cli.jvm.modules.CliJavaModuleResolver
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem
import org.jetbrains.kotlin.cli.jvm.modules.JavaModuleGraph
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.library.KLIB_FILE_EXTENSION
import org.jetbrains.kotlin.load.java.structure.impl.source.JavaElementSourceFactory
import org.jetbrains.kotlin.load.kotlin.MetadataFinderFactory
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
@@ -374,7 +375,7 @@ object StandaloneProjectFactory {
return roots.mapNotNull { path ->
val pathString = FileUtil.toSystemIndependentName(path.toAbsolutePath().toString())
when {
pathString.endsWith(JAR_PROTOCOL) -> {
pathString.endsWith(JAR_PROTOCOL) || pathString.endsWith(KLIB_FILE_EXTENSION) -> {
environment.environment.jarFileSystem.findFileByPath(pathString + JAR_SEPARATOR)
}