From e6bd34b6711e25422f2682e57ed03a6494eaf616 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Tue, 29 Aug 2023 20:50:10 +0200 Subject: [PATCH] [Analysis API Standalone] refactoring, use `Path` instead of `String` for path representation ^KT-60884 --- .../project/structure/impl/KtModuleUtils.kt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/project/structure/impl/KtModuleUtils.kt b/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/project/structure/impl/KtModuleUtils.kt index 908df6ac276..bce9263d7a3 100644 --- a/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/project/structure/impl/KtModuleUtils.kt +++ b/analysis/analysis-api-standalone/src/org/jetbrains/kotlin/analysis/project/structure/impl/KtModuleUtils.kt @@ -63,7 +63,7 @@ internal fun TargetPlatform.getAnalyzerServices(): PlatformDependentAnalyzerServ internal fun getSourceFilePaths( compilerConfig: CompilerConfiguration, includeDirectoryRoot: Boolean = false, -): Set { +): Set { return buildSet { compilerConfig.javaSourceRoots.forEach { srcRoot -> val path = Paths.get(srcRoot) @@ -71,11 +71,11 @@ internal fun getSourceFilePaths( // E.g., project/app/src collectSourceFilePaths(path, this) if (includeDirectoryRoot) { - add(srcRoot) + add(path) } } else { // E.g., project/app/src/some/pkg/main.kt - add(srcRoot) + add(path) } } } @@ -91,7 +91,7 @@ internal fun getSourceFilePaths( */ private fun collectSourceFilePaths( root: Path, - result: MutableSet + result: MutableSet ) { // NB: [Files#walk] throws an exception if there is an issue during IO. // With [Files#walkFileTree] with a custom visitor, we can take control of exception handling. @@ -113,7 +113,7 @@ private fun collectSourceFilePaths( ext == KotlinParserDefinition.STD_SCRIPT_SUFFIX || ext == JavaFileType.DEFAULT_EXTENSION ) { - result.add(file.toString()) + result.add(file) } return FileVisitResult.CONTINUE } @@ -131,13 +131,13 @@ private fun collectSourceFilePaths( internal inline fun getPsiFilesFromPaths( project: Project, - paths: Collection, + paths: Collection, ): List { val fs = StandardFileSystems.local() val psiManager = PsiManager.getInstance(project) return buildList { for (path in paths) { - val vFile = fs.findFileByPath(path) ?: continue + val vFile = fs.findFileByPath(path.toString()) ?: continue val psiFileSystemItem = if (vFile.isDirectory) psiManager.findDirectory(vFile) as? T