FIR CLI: use VFS for LT files loading

may improve performance in some cases and is consistent with handling
of PSI files
This commit is contained in:
Ilya Chernikov
2022-02-03 08:44:11 +01:00
committed by teamcity
parent 506152020d
commit 018782f0c7
4 changed files with 19 additions and 5 deletions
@@ -107,6 +107,9 @@ open class VfsBasedProjectEnvironment(
baseModuleData: FirModuleData,
fileSearchScope: AbstractProjectFileSearchScope
) = FirJavaFacade(firSession, baseModuleData, project.createJavaClassFinder(fileSearchScope.asPsiSearchScope()))
override fun getFileText(filePath: String): String? =
localFileSystem.findFileByPath(filePath)?.inputStream?.reader(Charsets.UTF_8)?.readText()
}
private fun AbstractProjectFileSearchScope.asPsiSearchScope() =
@@ -311,8 +311,14 @@ fun compileModuleToAnalyzedFir(
val countFilesAndLines = if (performanceManager == null) null else performanceManager::addSourcesStats
// raw fir
val commonRawFir = commonSession?.buildFirViaLightTree(input.commonSources, diagnosticsReporter, countFilesAndLines)
val rawFir = session.buildFirViaLightTree(input.platformSources, diagnosticsReporter, countFilesAndLines)
val commonRawFir = commonSession?.buildFirViaLightTree(
input.commonSources,
environment.projectEnvironment,
diagnosticsReporter,
countFilesAndLines
)
val rawFir =
session.buildFirViaLightTree(input.platformSources, environment.projectEnvironment, diagnosticsReporter, countFilesAndLines)
// resolution
commonSession?.apply {