Sanitize names for script class files

Use the same process that is done for package parts in the JVM back-end, except
adding the "Kt" suffix

 #KT-15225 Fixed
This commit is contained in:
Alexander Udalov
2017-01-11 14:31:22 +03:00
parent 6ffa56b640
commit abe2ad155c
7 changed files with 17 additions and 38 deletions
@@ -45,4 +45,9 @@ object NameUtils {
str.substring(0, 1).toUpperCase(Locale.ENGLISH) + str.substring(1)
else
"_$str"
// "pkg/someScript.kts" -> "SomeScript"
@JvmStatic
fun getScriptNameForFile(filePath: String): Name =
Name.identifier(NameUtils.getPackagePartClassNamePrefix(filePath.substringAfterLast('/').substringBeforeLast('.')))
}