Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,18 @@ fun getDirectoriesForSysPath(
if (element != null) {
val directory = element.parent
if (directory is PsiDirectory) {
sources.add(directory.virtualFile)
if (sources.any { source ->
val sourcePath = source.canonicalPath
if (source.isDirectory && sourcePath != null) {
directory.virtualFile.canonicalPath?.startsWith(sourcePath) ?: false
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider improving the code

} else {
false
}
}) {
sources.add(directory.virtualFile)
}
}
}

}
}

Expand All @@ -298,7 +306,7 @@ fun getDirectoriesForSysPath(
importPath += "."

return Pair(
sources.map { it.path }.toSet(),
sources.map { it.path.replace("\\", "\\\\") }.toSet(),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please extract such things as a utility function. And consider situations when we are already have two back slashes in the path.

"${importPath}${file.name}".removeSuffix(".py").toPath().joinToString(".").replace("/", File.separator)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object TemporaryFileManager {
}

fun assignTemporaryFile(fileName_: String? = null, tag: String? = null, addToCleaner: Boolean = true): File {
val fileName = fileName_ ?: ("${nextId++}_" + (tag ?: ""))
val fileName = fileName_ ?: ("tmp_${nextId++}_" + (tag ?: ""))
val fullpath = Paths.get(tmpDirectory.toString(), fileName)
val result = fullpath.toFile()
if (addToCleaner)
Expand Down