From 4a5823c5bb53c13624714599774745aaacb93791 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 20 Feb 2014 22:14:35 +0400 Subject: [PATCH] Rename "import jet.*" to "import kotlin.*" on ant dist Yet another hack for moving built-ins from package "jet" to "kotlin" --- build.xml | 20 ++++++++++++++++++++ renameImportJet.kt | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 renameImportJet.kt diff --git a/build.xml b/build.xml index cab8bd8cd2b..1438501c068 100644 --- a/build.xml +++ b/build.xml @@ -284,6 +284,26 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/renameImportJet.kt b/renameImportJet.kt new file mode 100644 index 00000000000..25f4f988002 --- /dev/null +++ b/renameImportJet.kt @@ -0,0 +1,34 @@ +import java.io.File +import com.intellij.util.Processor +import com.intellij.openapi.util.io.FileUtil +import java.util.ArrayList + +fun main(args: Array) { + println("renameImportJet") + + fun processFile(file: File) { + if (!file.getName().endsWith(".java") || file.isDirectory()) return + + val lines = ArrayList() + var rewrite = false + file.reader().forEachLine { line -> + if (line.startsWith("import jet.") && !line.startsWith("import jet.runtime.typeinfo")) { + lines.add("import kotlin." + line.substring("import jet.".length)) + rewrite = true + } + else { + lines.add(line) + } + } + + if (rewrite) { + println("renaming imports in $file") + file.writeText(lines reduce { (a, b) -> "$a\n$b" }) + } + } + + val processor = Processor { if (it != null) processFile(it); true } + val directoryFilter = Processor { it?.getName() != "testData" } + + FileUtil.processFilesRecursively(File("."), processor, directoryFilter) +}