Refactoring: introduce IncReporter to report IC progress
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.incremental
|
||||
|
||||
import java.io.File
|
||||
|
||||
abstract class IncReporter {
|
||||
abstract fun report(message: ()->String)
|
||||
abstract fun pathsAsString(files: Iterable<File>): String
|
||||
|
||||
fun pathsAsString(vararg files: File): String =
|
||||
pathsAsString(files.toList())
|
||||
}
|
||||
@@ -187,13 +187,13 @@ data class DirtyData(
|
||||
|
||||
fun <Target> CompilationResult.getDirtyData(
|
||||
caches: Iterable<IncrementalCacheImpl<Target>>,
|
||||
log: (String)->Unit
|
||||
reporter: IncReporter
|
||||
): DirtyData {
|
||||
val dirtyLookupSymbols = HashSet<LookupSymbol>()
|
||||
val dirtyClassesFqNames = HashSet<FqName>()
|
||||
|
||||
for (change in changes) {
|
||||
log("Process $change")
|
||||
reporter.report { "Process $change" }
|
||||
|
||||
if (change is ChangeInfo.SignatureChanged) {
|
||||
val fqNames = if (!change.areSubclassesAffected) listOf(change.fqName) else withSubtypes(change.fqName, caches)
|
||||
@@ -225,15 +225,14 @@ fun <Target> CompilationResult.getDirtyData(
|
||||
fun mapLookupSymbolsToFiles(
|
||||
lookupStorage: LookupStorage,
|
||||
lookupSymbols: Iterable<LookupSymbol>,
|
||||
log: (String)->Unit,
|
||||
getLogFilePath: (File)->String = { it.canonicalPath },
|
||||
reporter: IncReporter,
|
||||
excludes: Set<File> = emptySet()
|
||||
): Set<File> {
|
||||
val dirtyFiles = HashSet<File>()
|
||||
|
||||
for (lookup in lookupSymbols) {
|
||||
val affectedFiles = lookupStorage.get(lookup).map(::File).filter { it !in excludes }
|
||||
log("${lookup.scope}#${lookup.name} caused recompilation of: ${affectedFiles.map(getLogFilePath)}")
|
||||
reporter.report { "${lookup.scope}#${lookup.name} caused recompilation of: ${reporter.pathsAsString(affectedFiles)}" }
|
||||
dirtyFiles.addAll(affectedFiles)
|
||||
}
|
||||
|
||||
@@ -243,8 +242,7 @@ fun mapLookupSymbolsToFiles(
|
||||
fun <Target> mapClassesFqNamesToFiles(
|
||||
caches: Iterable<IncrementalCacheImpl<Target>>,
|
||||
classesFqNames: Iterable<FqName>,
|
||||
log: (String)->Unit,
|
||||
getLogFilePath: (File)->String = { it.canonicalPath },
|
||||
reporter: IncReporter,
|
||||
excludes: Set<File> = emptySet()
|
||||
): Set<File> {
|
||||
val dirtyFiles = HashSet<File>()
|
||||
@@ -254,7 +252,7 @@ fun <Target> mapClassesFqNamesToFiles(
|
||||
val srcFile = cache.getSourceFileIfClass(dirtyClassFqName)
|
||||
if (srcFile == null || srcFile in excludes) continue
|
||||
|
||||
log("Class $dirtyClassFqName caused recompilation of: ${getLogFilePath(srcFile)}")
|
||||
reporter.report { ("Class $dirtyClassFqName caused recompilation of: ${reporter.pathsAsString(srcFile)}") }
|
||||
dirtyFiles.add(srcFile)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user