Use ModuleInfo in VirtualFileFinder to add script dependencies in search scope
Otherwise it prevent to inline functions from those dependencies during scratch compilation
This commit is contained in:
@@ -149,7 +149,7 @@ internal fun getMethodNode(
|
||||
}
|
||||
|
||||
internal fun findVirtualFile(state: GenerationState, classId: ClassId): VirtualFile? {
|
||||
return VirtualFileFinder.getInstance(state.project).findVirtualFileWithHeader(classId)
|
||||
return VirtualFileFinder.getInstance(state.project, state.module).findVirtualFileWithHeader(classId)
|
||||
}
|
||||
|
||||
internal fun findVirtualFileImprecise(state: GenerationState, internalClassName: String): VirtualFile? {
|
||||
|
||||
@@ -16,12 +16,17 @@
|
||||
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesIndex
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinderFactory
|
||||
|
||||
// TODO: create different JvmDependenciesIndex instances for different sets of source roots to improve performance
|
||||
class CliVirtualFileFinderFactory(private val index: JvmDependenciesIndex) : VirtualFileFinderFactory {
|
||||
override fun create(scope: GlobalSearchScope): VirtualFileFinder = CliVirtualFileFinder(index, scope)
|
||||
|
||||
override fun create(project: Project, module: ModuleDescriptor): VirtualFileFinder =
|
||||
CliVirtualFileFinder(index, GlobalSearchScope.allScope(project))
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.load.kotlin
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaClass
|
||||
import org.jetbrains.kotlin.load.java.structure.impl.VirtualFileBoundJavaClass
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
@@ -51,7 +53,11 @@ abstract class VirtualFileFinder : KotlinClassFinder {
|
||||
}
|
||||
|
||||
companion object SERVICE {
|
||||
fun getInstance(project: Project, module: ModuleDescriptor): VirtualFileFinder =
|
||||
VirtualFileFinderFactory.getInstance(project).create(project, module)
|
||||
|
||||
@TestOnly
|
||||
fun getInstance(project: Project): VirtualFileFinder =
|
||||
VirtualFileFinderFactory.getInstance(project).create(GlobalSearchScope.allScope(project))
|
||||
VirtualFileFinderFactory.getInstance(project).create(GlobalSearchScope.allScope(project))
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -19,9 +19,11 @@ package org.jetbrains.kotlin.load.kotlin
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
|
||||
interface VirtualFileFinderFactory : MetadataFinderFactory {
|
||||
override fun create(scope: GlobalSearchScope): VirtualFileFinder
|
||||
override fun create(project: Project, module: ModuleDescriptor): VirtualFileFinder
|
||||
|
||||
companion object SERVICE {
|
||||
fun getInstance(project: Project): VirtualFileFinderFactory =
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.serialization.deserialization.KotlinMetadataFinder
|
||||
|
||||
interface MetadataFinderFactory {
|
||||
fun create(scope: GlobalSearchScope): KotlinMetadataFinder
|
||||
fun create(project: Project, module: ModuleDescriptor): KotlinMetadataFinder
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user