From 9ebc6a18a1dd3c57681be3ed04db593c6b14f382 Mon Sep 17 00:00:00 2001 From: Alexey Tsvetkov Date: Mon, 3 Oct 2016 21:35:41 +0300 Subject: [PATCH] Refactoring: introduce IncReporter to report IC progress Original commit: fafde1e9488a2b335f505bffe3eedbbcb97adb82 --- .../kotlin/jps/build/KotlinBuilder.kt | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt index 6a57f769cb3..1c9d32d930c 100644 --- a/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt +++ b/jps/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -788,6 +788,17 @@ private fun CompilationResult.doProcessChanges( } } +private class JpsIncReporter : IncReporter() { + override fun report(message: ()->String) { + if (KotlinBuilder.LOG.isDebugEnabled) { + KotlinBuilder.LOG.debug(message()) + } + } + + override fun pathsAsString(files: Iterable): String = + files.map { it.canonicalPath }.joinToString() +} + private fun CompilationResult.doProcessChangesUsingLookups( compiledFiles: Set, dataManager: BuildDataManager, @@ -796,16 +807,16 @@ private fun CompilationResult.doProcessChangesUsingLookups( ) { val lookupStorage = dataManager.getStorage(KotlinDataContainerTarget, JpsLookupStorageProvider) val allCaches = caches.flatMap { it.thisWithDependentCaches } - val logAction = { logStr: String -> KotlinBuilder.LOG.debug(logStr) } + val reporter = JpsIncReporter() - logAction("Start processing changes") + reporter.report { "Start processing changes" } - val (dirtyLookupSymbols, dirtyClassFqNames) = getDirtyData(allCaches, logAction) - val dirtyFiles = mapLookupSymbolsToFiles(lookupStorage, dirtyLookupSymbols, logAction) + - mapClassesFqNamesToFiles(allCaches, dirtyClassFqNames, logAction) + val (dirtyLookupSymbols, dirtyClassFqNames) = getDirtyData(allCaches, reporter) + val dirtyFiles = mapLookupSymbolsToFiles(lookupStorage, dirtyLookupSymbols, reporter) + + mapClassesFqNamesToFiles(allCaches, dirtyClassFqNames, reporter) fsOperations.markFiles(dirtyFiles.asIterable(), excludeFiles = compiledFiles) - logAction("End of processing changes") + reporter.report { "End of processing changes" } } private fun getLookupTracker(project: JpsProject): LookupTracker {