Minor: fix warnings in AbstractIncrementalJpsTest.kt

* used new property access syntax
* splitBy -> split
* used string template instead of concatenation

Original commit: 6bed076228
This commit is contained in:
Zalim Bashorov
2015-08-13 22:12:16 +03:00
parent b983e9c868
commit b068d19bd2
@@ -82,8 +82,8 @@ public abstract class AbstractIncrementalJpsTest(
TestLoggerFactory.enableDebugLogging(myTestRootDisposable, "#org") TestLoggerFactory.enableDebugLogging(myTestRootDisposable, "#org")
val console = ConsoleAppender() val console = ConsoleAppender()
console.setLayout(PatternLayout("%d [%p|%c|%C{1}] %m%n")); console.layout = PatternLayout("%d [%p|%c|%C{1}] %m%n");
console.setThreshold(Level.ALL) console.threshold = Level.ALL
console.activateOptions() console.activateOptions()
Logger.getRootLogger().addAppender(console) Logger.getRootLogger().addAppender(console)
} }
@@ -110,7 +110,7 @@ public abstract class AbstractIncrementalJpsTest(
protected open fun checkLookups(@suppress("UNUSED_PARAMETER") lookupTracker: LookupTracker) {} protected open fun checkLookups(@suppress("UNUSED_PARAMETER") lookupTracker: LookupTracker) {}
fun build(scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().all()): MakeResult { fun build(scope: CompileScopeTestBuilder = CompileScopeTestBuilder.make().all()): MakeResult {
val workDirPath = FileUtil.toSystemIndependentName(workDir.getAbsolutePath()) val workDirPath = FileUtil.toSystemIndependentName(workDir.absolutePath)
val logger = MyLogger(workDirPath) val logger = MyLogger(workDirPath)
val descriptor = createProjectDescriptor(BuildLoggingManager(logger)) val descriptor = createProjectDescriptor(BuildLoggingManager(logger))
@@ -126,11 +126,11 @@ public abstract class AbstractIncrementalJpsTest(
checkLookups(lookupTracker) checkLookups(lookupTracker)
if (!buildResult.isSuccessful()) { if (!buildResult.isSuccessful) {
val errorMessages = val errorMessages =
buildResult buildResult
.getMessages(BuildMessage.Kind.ERROR) .getMessages(BuildMessage.Kind.ERROR)
.map { it.getMessageText() } .map { it.messageText }
.map { it.replace("^.+:\\d+:\\s+".toRegex(), "").trim() } .map { it.replace("^.+:\\d+:\\s+".toRegex(), "").trim() }
.joinToString("\n") .joinToString("\n")
return MakeResult(logger.log + "$COMPILATION_FAILED\n" + errorMessages + "\n", true, null) return MakeResult(logger.log + "$COMPILATION_FAILED\n" + errorMessages + "\n", true, null)
@@ -170,7 +170,7 @@ public abstract class AbstractIncrementalJpsTest(
assert(moduleNames != null) { "File name has module prefix, but multi-module environment is absent" } assert(moduleNames != null) { "File name has module prefix, but multi-module environment is absent" }
assert(module in moduleNames!!) { "Module not found for file with prefix: $fileName" } assert(module in moduleNames!!) { "Module not found for file with prefix: $fileName" }
return module + "/src" return "$module/src"
} }
assert(moduleNames == null) { "Test is multi-module, but file has no module prefix: $fileName" } assert(moduleNames == null) { "Test is multi-module, but file has no module prefix: $fileName" }
@@ -240,7 +240,7 @@ public abstract class AbstractIncrementalJpsTest(
} }
private fun clearCachesRebuildAndCheckOutput(makeOverallResult: MakeResult) { private fun clearCachesRebuildAndCheckOutput(makeOverallResult: MakeResult) {
FileUtil.delete(BuildDataPathsImpl(myDataStorageRoot).getDataStorageRoot()!!) FileUtil.delete(BuildDataPathsImpl(myDataStorageRoot).dataStorageRoot!!)
rebuildAndCheckOutput(makeOverallResult) rebuildAndCheckOutput(makeOverallResult)
} }
@@ -251,10 +251,10 @@ public abstract class AbstractIncrementalJpsTest(
val result = HashMap<String, List<String>>() val result = HashMap<String, List<String>>()
for (line in dependenciesTxt.readLines()) { for (line in dependenciesTxt.readLines()) {
val split = line.splitBy("->") val split = line.split("->")
val module = split[0] val module = split[0]
val dependencies = if (split.size() > 1) split[1] else "" val dependencies = if (split.size() > 1) split[1] else ""
val dependencyList = dependencies.splitBy(",").filterNot { it.isEmpty() } val dependencyList = dependencies.split(",").filterNot { it.isEmpty() }
result[module] = dependencyList result[module] = dependencyList
} }
@@ -289,7 +289,7 @@ public abstract class AbstractIncrementalJpsTest(
private fun createKotlinIncrementalCacheDump(project: ProjectDescriptor): String { private fun createKotlinIncrementalCacheDump(project: ProjectDescriptor): String {
return StringBuilder { return StringBuilder {
for (target in project.getBuildTargetIndex().getAllTargets().sortBy { it.getPresentableName() }) { for (target in project.buildTargetIndex.allTargets.sortBy { it.presentableName }) {
append("<target $target>\n") append("<target $target>\n")
append(project.dataManager.getKotlinCache(target).dump()) append(project.dataManager.getKotlinCache(target).dump())
append("</target $target>\n\n\n") append("</target $target>\n\n\n")
@@ -304,15 +304,15 @@ public abstract class AbstractIncrementalJpsTest(
result.println("Begin of SourceToOutputMap") result.println("Begin of SourceToOutputMap")
result.pushIndent() result.pushIndent()
for (target in project.getBuildTargetIndex().getAllTargets()) { for (target in project.buildTargetIndex.allTargets) {
result.println(target) result.println(target)
result.pushIndent() result.pushIndent()
val mapping = project.dataManager.getSourceToOutputMap(target) val mapping = project.dataManager.getSourceToOutputMap(target)
mapping.getSources().forEach { mapping.sources.forEach {
val outputs = mapping.getOutputs(it)!!.sort() val outputs = mapping.getOutputs(it)!!.sort()
if (outputs.isNotEmpty()) { if (outputs.isNotEmpty()) {
result.println("source $it -> " + outputs) result.println("source $it -> $outputs")
} }
} }
@@ -328,7 +328,7 @@ public abstract class AbstractIncrementalJpsTest(
private fun createJavaMappingsDump(project: ProjectDescriptor): String { private fun createJavaMappingsDump(project: ProjectDescriptor): String {
val byteArrayOutputStream = ByteArrayOutputStream() val byteArrayOutputStream = ByteArrayOutputStream()
PrintStream(byteArrayOutputStream).use { PrintStream(byteArrayOutputStream).use {
project.dataManager.getMappings().toStream(it) project.dataManager.mappings.toStream(it)
} }
return byteArrayOutputStream.toString() return byteArrayOutputStream.toString()
} }
@@ -353,8 +353,7 @@ public abstract class AbstractIncrementalJpsTest(
// null means one module // null means one module
private fun configureModules(): Set<String>? { private fun configureModules(): Set<String>? {
var moduleNames: Set<String>? var moduleNames: Set<String>?
JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject) JpsJavaExtensionService.getInstance().getOrCreateProjectExtension(myProject).outputUrl = JpsPathUtil.pathToUrl(getAbsolutePath("out"))
.setOutputUrl(JpsPathUtil.pathToUrl(getAbsolutePath("out")))
val jdk = addJdk("my jdk") val jdk = addJdk("my jdk")
val moduleDependencies = readModuleDependencies() val moduleDependencies = readModuleDependencies()
@@ -370,7 +369,7 @@ public abstract class AbstractIncrementalJpsTest(
} }
else { else {
val nameToModule = moduleDependencies.keySet() val nameToModule = moduleDependencies.keySet()
.keysToMap { addModule(it, arrayOf(getAbsolutePath(it + "/src")), null, null, jdk)!! } .keysToMap { addModule(it, arrayOf(getAbsolutePath("$it/src")), null, null, jdk)!! }
for ((moduleName, dependencies) in moduleDependencies) { for ((moduleName, dependencies) in moduleDependencies) {
val module = nameToModule[moduleName]!! val module = nameToModule[moduleName]!!
@@ -380,9 +379,9 @@ public abstract class AbstractIncrementalJpsTest(
} }
for (module in nameToModule.values()) { for (module in nameToModule.values()) {
val moduleName = module.getName() val moduleName = module.name
val srcDir = File(workDir, moduleName + "/src") val srcDir = File(workDir, "$moduleName/src")
FileUtil.copyDir(testDataDir, srcDir, FileUtil.copyDir(testDataDir, srcDir,
{ it.getName().startsWith(moduleName + "_") && (it.getName().endsWith(".kt") || it.getName().endsWith(".java")) }) { it.getName().startsWith(moduleName + "_") && (it.getName().endsWith(".kt") || it.getName().endsWith(".java")) })
@@ -408,14 +407,14 @@ public abstract class AbstractIncrementalJpsTest(
override fun isEnabled(): Boolean = true override fun isEnabled(): Boolean = true
override fun logLine(message: String?) { override fun logLine(message: String?) {
logBuf.append(JetTestUtils.replaceHashWithStar(message!!.removePrefix(rootPath + "/"))).append('\n') logBuf.append(JetTestUtils.replaceHashWithStar(message!!.removePrefix("$rootPath/"))).append('\n')
} }
} }
private abstract class Modification(val path: String) { private abstract class Modification(val path: String) {
abstract fun perform(workDir: File) abstract fun perform(workDir: File)
override fun toString(): String = "${javaClass.getSimpleName()} $path" override fun toString(): String = "${javaClass.simpleName} $path"
} }
private class ModifyContent(path: String, val dataFile: File) : Modification(path) { private class ModifyContent(path: String, val dataFile: File) : Modification(path) {