Created
December 16, 2020 01:05
-
-
Save swankjesse/0ca615560230db405234fc275f3cfad0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import okio.buffer | |
import okio.source | |
/** | |
* Converts a Kotlin file with `backtick method names` to camelCaseMethodNames. | |
*/ | |
fun main() { | |
val source = System.`in`.source().buffer() | |
while (true) { | |
val line = source.readUtf8Line() ?: break | |
val prefix = " fun `" | |
val suffix = "`() {" | |
if (!line.startsWith(prefix) || !line.endsWith(suffix)) { | |
System.out.println(line) | |
continue | |
} | |
val words = line.substring(prefix.length, line.length - suffix.length).split(" ") | |
val camelWords = words[0] + (words.subList(1, words.size).joinToString(separator = "") { word -> | |
word.substring(0, 1).toUpperCase() + word.substring(1) | |
}) | |
System.out.println(" fun ${camelWords}() {") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment