Rename ICReporter.report/reportVerbose to info/debug

to make it clear what severity levels they are mapped to.

^KT-52839 Fixed
This commit is contained in:
Hung Nguyen
2022-06-24 14:33:39 +01:00
committed by teamcity
parent e01c2bc651
commit 5b6afef67d
17 changed files with 58 additions and 47 deletions
@@ -18,17 +18,16 @@ interface ICReporter {
fun report(message: () -> String, severity: ReportSeverity) fun report(message: () -> String, severity: ReportSeverity)
// TODO: Move these 3 functions outside of this interface and make them extension functions so they can't be overridden
fun warn(message: () -> String) = report(message, severity = ReportSeverity.WARNING)
fun report(message: () -> String) = report(message, severity = ReportSeverity.INFO)
fun reportVerbose(message: () -> String) = report(message, severity = ReportSeverity.DEBUG)
fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode) fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode)
fun reportMarkDirtyClass(affectedFiles: Iterable<File>, classFqName: String) fun reportMarkDirtyClass(affectedFiles: Iterable<File>, classFqName: String)
fun reportMarkDirtyMember(affectedFiles: Iterable<File>, scope: String, name: String) fun reportMarkDirtyMember(affectedFiles: Iterable<File>, scope: String, name: String)
fun reportMarkDirty(affectedFiles: Iterable<File>, reason: String) fun reportMarkDirty(affectedFiles: Iterable<File>, reason: String)
} }
fun ICReporter.warn(message: () -> String) = report(message, severity = ICReporter.ReportSeverity.WARNING)
fun ICReporter.info(message: () -> String) = report(message, severity = ICReporter.ReportSeverity.INFO)
fun ICReporter.debug(message: () -> String) = report(message, severity = ICReporter.ReportSeverity.DEBUG)
object DoNothingICReporter : ICReporter { object DoNothingICReporter : ICReporter {
override fun report(message: () -> String, severity: ICReporter.ReportSeverity) {} override fun report(message: () -> String, severity: ICReporter.ReportSeverity) {}
override fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode) {} override fun reportCompileIteration(incremental: Boolean, sourceFiles: Collection<File>, exitCode: ExitCode) {}
@@ -18,7 +18,7 @@ abstract class ICReporterBase(private val pathsBase: File? = null) : ICReporter
override fun reportMarkDirty(affectedFiles: Iterable<File>, reason: String) { override fun reportMarkDirty(affectedFiles: Iterable<File>, reason: String) {
affectedFiles.forEach { file -> affectedFiles.forEach { file ->
reportVerbose { "${pathsAsString(file)} is marked dirty: $reason" } debug { "${pathsAsString(file)} is marked dirty: $reason" }
} }
} }
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.build.GeneratedJvmClass
import org.jetbrains.kotlin.build.JvmSourceRoot import org.jetbrains.kotlin.build.JvmSourceRoot
import org.jetbrains.kotlin.build.isModuleMappingFile import org.jetbrains.kotlin.build.isModuleMappingFile
import org.jetbrains.kotlin.build.report.ICReporter import org.jetbrains.kotlin.build.report.ICReporter
import org.jetbrains.kotlin.build.report.debug
import org.jetbrains.kotlin.config.Services import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
@@ -152,7 +153,7 @@ fun ChangesCollector.getDirtyData(
val sealedParents = HashSet<FqName>() val sealedParents = HashSet<FqName>()
for (change in changes()) { for (change in changes()) {
reporter.reportVerbose { "Process $change" } reporter.debug { "Process $change" }
if (change is ChangeInfo.SignatureChanged) { if (change is ChangeInfo.SignatureChanged) {
val fqNames = if (!change.areSubclassesAffected) listOf(change.fqName) else withSubtypes(change.fqName, caches) val fqNames = if (!change.areSubclassesAffected) listOf(change.fqName) else withSubtypes(change.fqName, caches)
@@ -22,6 +22,7 @@ import com.intellij.openapi.vfs.impl.ZipHandler
import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem import com.intellij.openapi.vfs.impl.jar.CoreJarFileSystem
import org.jetbrains.kotlin.build.DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS import org.jetbrains.kotlin.build.DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
import org.jetbrains.kotlin.build.report.RemoteBuildReporter import org.jetbrains.kotlin.build.report.RemoteBuildReporter
import org.jetbrains.kotlin.build.report.info
import org.jetbrains.kotlin.cli.common.CLICompiler import org.jetbrains.kotlin.cli.common.CLICompiler
import org.jetbrains.kotlin.cli.common.CompilerSystemProperties import org.jetbrains.kotlin.cli.common.CompilerSystemProperties
import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.ExitCode
@@ -35,8 +36,6 @@ import org.jetbrains.kotlin.cli.common.repl.ReplEvalResult
import org.jetbrains.kotlin.cli.js.K2JSCompiler import org.jetbrains.kotlin.cli.js.K2JSCompiler
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.cli.jvm.compiler.jarfs.FastJarFileSystem
import org.jetbrains.kotlin.cli.jvm.compiler.jarfs.FastJarHandler
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler
import org.jetbrains.kotlin.config.KotlinCompilerVersion import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlin.config.Services import org.jetbrains.kotlin.config.Services
@@ -600,7 +599,7 @@ abstract class CompileServiceImplBase(
val workingDir = incrementalCompilationOptions.workingDir val workingDir = incrementalCompilationOptions.workingDir
val modulesApiHistory = incrementalCompilationOptions.run { val modulesApiHistory = incrementalCompilationOptions.run {
reporter.report { "Use module detection: ${multiModuleICSettings.useModuleDetection}" } reporter.info { "Use module detection: ${multiModuleICSettings.useModuleDetection}" }
if (!multiModuleICSettings.useModuleDetection) { if (!multiModuleICSettings.useModuleDetection) {
ModulesApiHistoryJvm(modulesInfo) ModulesApiHistoryJvm(modulesInfo)
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.incremental package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.build.report.BuildReporter import org.jetbrains.kotlin.build.report.BuildReporter
import org.jetbrains.kotlin.build.report.info
import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmNameResolver import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmNameResolver
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil
@@ -153,7 +154,7 @@ class AbiSnapshotImpl(override val protos: MutableMap<FqName, ProtoData>) : AbiS
fun read(file: File, reporter: BuildReporter): AbiSnapshot? { fun read(file: File, reporter: BuildReporter): AbiSnapshot? {
if (!file.exists()) { if (!file.exists()) {
reporter.report { "jar snapshot $file is found for jar" } reporter.info { "jar snapshot $file is found for jar" }
return null return null
} }
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.annotations.TestOnly import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.build.report.ICReporter import org.jetbrains.kotlin.build.report.ICReporter
import org.jetbrains.kotlin.build.report.info
import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqName
import java.io.File import java.io.File
import java.io.IOException import java.io.IOException
@@ -36,7 +37,7 @@ data class BuildDiffsStorage(val buildDiffs: List<BuildDifference>) {
fun readDiffsFromFile(file: File, reporter: ICReporter?): MutableList<BuildDifference>? { fun readDiffsFromFile(file: File, reporter: ICReporter?): MutableList<BuildDifference>? {
fun reportFail(reason: String) { fun reportFail(reason: String) {
reporter?.report { "Could not read diff from file $file: $reason" } reporter?.info { "Could not read diff from file $file: $reason" }
} }
if (!file.exists()) return null if (!file.exists()) return null
@@ -77,7 +78,7 @@ data class BuildDiffsStorage(val buildDiffs: List<BuildDifference>) {
} }
} }
} catch (e: IOException) { } catch (e: IOException) {
reporter?.report { "Could not write diff to file $file: $e" } reporter?.info { "Could not write diff to file $file: $e" }
} }
} }
@@ -20,6 +20,7 @@ import com.intellij.psi.PsiClass
import com.intellij.psi.PsiFile import com.intellij.psi.PsiFile
import com.intellij.psi.PsiJavaFile import com.intellij.psi.PsiJavaFile
import org.jetbrains.kotlin.build.report.ICReporter import org.jetbrains.kotlin.build.report.ICReporter
import org.jetbrains.kotlin.build.report.info
import org.jetbrains.kotlin.build.report.metrics.BuildAttribute import org.jetbrains.kotlin.build.report.metrics.BuildAttribute
import java.io.File import java.io.File
import java.util.* import java.util.*
@@ -38,7 +39,7 @@ internal class ChangedJavaFilesProcessor(
val removedJava = filesDiff.removed.filter(File::isJavaFile) val removedJava = filesDiff.removed.filter(File::isJavaFile)
if (removedJava.any()) { if (removedJava.any()) {
reporter.report { "Some java files are removed: [${removedJava.joinToString()}]" } reporter.info { "Some java files are removed: [${removedJava.joinToString()}]" }
return ChangesEither.Unknown(BuildAttribute.JAVA_CHANGE_UNTRACKED_FILE_IS_REMOVED) return ChangesEither.Unknown(BuildAttribute.JAVA_CHANGE_UNTRACKED_FILE_IS_REMOVED)
} }
@@ -48,7 +49,7 @@ internal class ChangedJavaFilesProcessor(
val psiFile = psiFileFactory(javaFile) val psiFile = psiFileFactory(javaFile)
if (psiFile !is PsiJavaFile) { if (psiFile !is PsiJavaFile) {
reporter.report { "Expected PsiJavaFile, got ${psiFile?.javaClass}" } reporter.info { "Expected PsiJavaFile, got ${psiFile?.javaClass}" }
return ChangesEither.Unknown(BuildAttribute.JAVA_CHANGE_UNEXPECTED_PSI) return ChangesEither.Unknown(BuildAttribute.JAVA_CHANGE_UNEXPECTED_PSI)
} }
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.incremental package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.build.report.ICReporter import org.jetbrains.kotlin.build.report.ICReporter
import org.jetbrains.kotlin.build.report.info
import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner
import org.jetbrains.kotlin.incremental.storage.IncrementalFileToPathConverter import org.jetbrains.kotlin.incremental.storage.IncrementalFileToPathConverter
import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol import org.jetbrains.kotlin.serialization.SerializerExtensionProtocol
@@ -62,7 +63,7 @@ abstract class IncrementalCachesManager<PlatformCache : AbstractIncrementalCache
cache.flush(false) cache.flush(false)
} catch (e: Throwable) { } catch (e: Throwable) {
isSuccessfulyClosed = false isSuccessfulyClosed = false
reporter.report { "Exception when flushing cache ${cache.javaClass}: $e" } reporter.info { "Exception when flushing cache ${cache.javaClass}: $e" }
} }
} }
@@ -70,7 +71,7 @@ abstract class IncrementalCachesManager<PlatformCache : AbstractIncrementalCache
cache.close() cache.close()
} catch (e: Throwable) { } catch (e: Throwable) {
isSuccessfulyClosed = false isSuccessfulyClosed = false
reporter.report { "Exception when closing cache ${cache.javaClass}: $e" } reporter.info { "Exception when closing cache ${cache.javaClass}: $e" }
} }
} }
@@ -19,10 +19,13 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.build.DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS import org.jetbrains.kotlin.build.DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
import org.jetbrains.kotlin.build.GeneratedFile import org.jetbrains.kotlin.build.GeneratedFile
import org.jetbrains.kotlin.build.report.BuildReporter import org.jetbrains.kotlin.build.report.BuildReporter
import org.jetbrains.kotlin.build.report.debug
import org.jetbrains.kotlin.build.report.info
import org.jetbrains.kotlin.build.report.metrics.BuildAttribute import org.jetbrains.kotlin.build.report.metrics.BuildAttribute
import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric
import org.jetbrains.kotlin.build.report.metrics.BuildTime import org.jetbrains.kotlin.build.report.metrics.BuildTime
import org.jetbrains.kotlin.build.report.metrics.measure import org.jetbrains.kotlin.build.report.metrics.measure
import org.jetbrains.kotlin.build.report.warn
import org.jetbrains.kotlin.cli.common.* import org.jetbrains.kotlin.cli.common.*
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.MessageCollector import org.jetbrains.kotlin.cli.common.messages.MessageCollector
@@ -98,7 +101,7 @@ abstract class IncrementalCompilerRunner<
projectDir: File? = null, projectDir: File? = null,
classpathAbiSnapshot: Map<String, AbiSnapshot> classpathAbiSnapshot: Map<String, AbiSnapshot>
): ExitCode { ): ExitCode {
reporter.report { "Non-incremental compilation will be performed: $reason" } reporter.info { "Non-incremental compilation will be performed: $reason" }
reporter.measure(BuildTime.CLEAR_OUTPUT_ON_REBUILD) { reporter.measure(BuildTime.CLEAR_OUTPUT_ON_REBUILD) {
cleanOutputsAndLocalStateOnRebuild(args) cleanOutputsAndLocalStateOnRebuild(args)
} }
@@ -133,7 +136,7 @@ abstract class IncrementalCompilerRunner<
val classpathAbiSnapshot = val classpathAbiSnapshot =
if (withAbiSnapshot) { if (withAbiSnapshot) {
reporter.report { "Incremental compilation with ABI snapshot enabled" } reporter.info { "Incremental compilation with ABI snapshot enabled" }
reporter.measure(BuildTime.SET_UP_ABI_SNAPSHOTS) { reporter.measure(BuildTime.SET_UP_ABI_SNAPSHOTS) {
setupJarDependencies(args, withAbiSnapshot, reporter) setupJarDependencies(args, withAbiSnapshot, reporter)
} }
@@ -196,7 +199,7 @@ abstract class IncrementalCompilerRunner<
} }
} finally { } finally {
if (!caches.close(flush = true)) { if (!caches.close(flush = true)) {
reporter.report { "Unable to close IC caches. Cleaning internal state" } reporter.info { "Unable to close IC caches. Cleaning internal state" }
cleanOutputsAndLocalStateOnRebuild(args) cleanOutputsAndLocalStateOnRebuild(args)
} }
} }
@@ -212,15 +215,15 @@ abstract class IncrementalCompilerRunner<
// Use Set as additionalOutputFiles may already contain destinationDir and workingDir // Use Set as additionalOutputFiles may already contain destinationDir and workingDir
val outputFiles = setOf(destinationDir(args), workingDir) + additionalOutputFiles val outputFiles = setOf(destinationDir(args), workingDir) + additionalOutputFiles
reporter.reportVerbose { "Cleaning outputs on rebuild" } reporter.debug { "Cleaning outputs on rebuild" }
outputFiles.forEach { outputFiles.forEach {
when { when {
it.isDirectory -> { it.isDirectory -> {
reporter.reportVerbose { " Deleting contents of directory '${it.path}'" } reporter.debug { " Deleting contents of directory '${it.path}'" }
it.cleanDirectoryContents() it.cleanDirectoryContents()
} }
it.isFile -> { it.isFile -> {
reporter.reportVerbose { " Deleting file '${it.path}'" } reporter.debug { " Deleting file '${it.path}'" }
it.deleteRecursivelyOrThrow() it.deleteRecursivelyOrThrow()
} }
} }
@@ -322,7 +325,7 @@ abstract class IncrementalCompilerRunner<
classpathAbiSnapshot: Map<String, AbiSnapshot> = HashMap() classpathAbiSnapshot: Map<String, AbiSnapshot> = HashMap()
): ExitCode { ): ExitCode {
if (compilationMode is CompilationMode.Rebuild) { if (compilationMode is CompilationMode.Rebuild) {
reporter.report { "Non-incremental compilation will be performed: ${compilationMode.reason}" } reporter.info { "Non-incremental compilation will be performed: ${compilationMode.reason}" }
} }
preBuildHook(args, compilationMode) preBuildHook(args, compilationMode)
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.build.GeneratedFile
import org.jetbrains.kotlin.build.report.BuildReporter import org.jetbrains.kotlin.build.report.BuildReporter
import org.jetbrains.kotlin.build.report.DoNothingICReporter import org.jetbrains.kotlin.build.report.DoNothingICReporter
import org.jetbrains.kotlin.build.report.ICReporter import org.jetbrains.kotlin.build.report.ICReporter
import org.jetbrains.kotlin.build.report.info
import org.jetbrains.kotlin.build.report.metrics.BuildAttribute import org.jetbrains.kotlin.build.report.metrics.BuildAttribute
import org.jetbrains.kotlin.build.report.metrics.DoNothingBuildMetricsReporter import org.jetbrains.kotlin.build.report.metrics.DoNothingBuildMetricsReporter
import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.ExitCode
@@ -139,7 +140,7 @@ class IncrementalJsCompilerRunner(
when (classpathChanges) { when (classpathChanges) {
is ChangesEither.Unknown -> { is ChangesEither.Unknown -> {
reporter.report { "Could not get classpath's changes: ${classpathChanges.reason}" } reporter.info { "Could not get classpath's changes: ${classpathChanges.reason}" }
return CompilationMode.Rebuild(classpathChanges.reason) return CompilationMode.Rebuild(classpathChanges.reason)
} }
is ChangesEither.Known -> { is ChangesEither.Known -> {
@@ -26,9 +26,7 @@ import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.build.DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS import org.jetbrains.kotlin.build.DEFAULT_KOTLIN_SOURCE_FILES_EXTENSIONS
import org.jetbrains.kotlin.build.GeneratedFile import org.jetbrains.kotlin.build.GeneratedFile
import org.jetbrains.kotlin.build.GeneratedJvmClass import org.jetbrains.kotlin.build.GeneratedJvmClass
import org.jetbrains.kotlin.build.report.BuildReporter import org.jetbrains.kotlin.build.report.*
import org.jetbrains.kotlin.build.report.DoNothingICReporter
import org.jetbrains.kotlin.build.report.ICReporter
import org.jetbrains.kotlin.build.report.metrics.* import org.jetbrains.kotlin.build.report.metrics.*
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.ExitCode
@@ -236,7 +234,7 @@ open class IncrementalJvmCompilerRunner(
val dirtyFiles = DirtyFilesContainer(caches, reporter, kotlinSourceFilesExtensions) val dirtyFiles = DirtyFilesContainer(caches, reporter, kotlinSourceFilesExtensions)
initDirtyFiles(dirtyFiles, changedFiles) initDirtyFiles(dirtyFiles, changedFiles)
reporter.reportVerbose { "Classpath changes info passed from Gradle task: ${classpathChanges::class.simpleName}" } reporter.debug { "Classpath changes info passed from Gradle task: ${classpathChanges::class.simpleName}" }
val classpathChanges = when (classpathChanges) { val classpathChanges = when (classpathChanges) {
// Note: classpathChanges is deserialized, so they are no longer singleton objects and need to be compared using `is` (not `==`) // Note: classpathChanges is deserialized, so they are no longer singleton objects and need to be compared using `is` (not `==`)
is NoChanges -> ChangesEither.Known(emptySet(), emptySet()) is NoChanges -> ChangesEither.Known(emptySet(), emptySet())
@@ -266,7 +264,7 @@ open class IncrementalJvmCompilerRunner(
return CompilationMode.Rebuild(BuildAttribute.NO_BUILD_HISTORY) return CompilationMode.Rebuild(BuildAttribute.NO_BUILD_HISTORY)
} }
val lastBuildInfo = BuildInfo.read(lastBuildInfoFile) val lastBuildInfo = BuildInfo.read(lastBuildInfoFile)
reporter.reportVerbose { "Last Kotlin Build info -- $lastBuildInfo" } reporter.debug { "Last Kotlin Build info -- $lastBuildInfo" }
val scopes = caches.lookupCache.lookupSymbols.map { it.scope.ifBlank { it.name } }.distinct() val scopes = caches.lookupCache.lookupSymbols.map { it.scope.ifBlank { it.name } }.distinct()
getClasspathChanges( getClasspathChanges(
@@ -280,7 +278,7 @@ open class IncrementalJvmCompilerRunner(
@Suppress("UNUSED_VARIABLE") // for sealed when @Suppress("UNUSED_VARIABLE") // for sealed when
val unused = when (classpathChanges) { val unused = when (classpathChanges) {
is ChangesEither.Unknown -> { is ChangesEither.Unknown -> {
reporter.report { reporter.info {
"Could not get classpath's changes: ${classpathChanges.reason}" "Could not get classpath's changes: ${classpathChanges.reason}"
} }
return CompilationMode.Rebuild(classpathChanges.reason) return CompilationMode.Rebuild(classpathChanges.reason)
@@ -327,20 +325,20 @@ open class IncrementalJvmCompilerRunner(
if (!caches.platformCache.isTrackedFile(javaFile)) { if (!caches.platformCache.isTrackedFile(javaFile)) {
if (!javaFile.exists()) { if (!javaFile.exists()) {
// todo: can we do this more optimal? // todo: can we do this more optimal?
reporter.report { "Could not get changed for untracked removed java file $javaFile" } reporter.info { "Could not get changed for untracked removed java file $javaFile" }
return BuildAttribute.JAVA_CHANGE_UNTRACKED_FILE_IS_REMOVED return BuildAttribute.JAVA_CHANGE_UNTRACKED_FILE_IS_REMOVED
} }
val psiFile = psiFileProvider.javaFile(javaFile) val psiFile = psiFileProvider.javaFile(javaFile)
if (psiFile !is PsiJavaFile) { if (psiFile !is PsiJavaFile) {
reporter.report { "[Precise Java tracking] Expected PsiJavaFile, got ${psiFile?.javaClass}" } reporter.info { "[Precise Java tracking] Expected PsiJavaFile, got ${psiFile?.javaClass}" }
return BuildAttribute.JAVA_CHANGE_UNEXPECTED_PSI return BuildAttribute.JAVA_CHANGE_UNEXPECTED_PSI
} }
for (psiClass in psiFile.classes) { for (psiClass in psiFile.classes) {
val qualifiedName = psiClass.qualifiedName val qualifiedName = psiClass.qualifiedName
if (qualifiedName == null) { if (qualifiedName == null) {
reporter.report { "[Precise Java tracking] Class with unknown qualified name in $javaFile" } reporter.info { "[Precise Java tracking] Class with unknown qualified name in $javaFile" }
return BuildAttribute.JAVA_CHANGE_UNKNOWN_QUALIFIER return BuildAttribute.JAVA_CHANGE_UNKNOWN_QUALIFIER
} }
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.incremental
import com.intellij.util.containers.MultiMap import com.intellij.util.containers.MultiMap
import org.jetbrains.kotlin.build.GeneratedFile import org.jetbrains.kotlin.build.GeneratedFile
import org.jetbrains.kotlin.build.report.ICReporter import org.jetbrains.kotlin.build.report.ICReporter
import org.jetbrains.kotlin.build.report.debug
import org.jetbrains.kotlin.incremental.snapshots.FileSnapshotMap import org.jetbrains.kotlin.incremental.snapshots.FileSnapshotMap
import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner
import org.jetbrains.kotlin.incremental.storage.FileToPathConverter import org.jetbrains.kotlin.incremental.storage.FileToPathConverter
@@ -41,7 +42,7 @@ class InputsCache(
fun removeOutputForSourceFiles(sources: Iterable<File>) { fun removeOutputForSourceFiles(sources: Iterable<File>) {
for (sourceFile in sources) { for (sourceFile in sources) {
sourceToOutputMap.remove(sourceFile).forEach { sourceToOutputMap.remove(sourceFile).forEach {
reporter.reportVerbose { "Deleting $it on clearing cache for $sourceFile" } reporter.debug { "Deleting $it on clearing cache for $sourceFile" }
it.delete() it.delete()
} }
} }
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.incremental package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.build.report.BuildReporter import org.jetbrains.kotlin.build.report.BuildReporter
import org.jetbrains.kotlin.build.report.info
import org.jetbrains.kotlin.build.report.metrics.BuildTime import org.jetbrains.kotlin.build.report.metrics.BuildTime
import org.jetbrains.kotlin.build.report.metrics.BuildAttribute import org.jetbrains.kotlin.build.report.metrics.BuildAttribute
import org.jetbrains.kotlin.build.report.metrics.measure import org.jetbrains.kotlin.build.report.metrics.measure
@@ -38,7 +39,7 @@ internal fun getClasspathChanges(
// todo: removed classes could be processed normally // todo: removed classes could be processed normally
if (removedClasspath.isNotEmpty()) { if (removedClasspath.isNotEmpty()) {
reporter.report { "Some files are removed from classpath: $removedClasspath" } reporter.info { "Some files are removed from classpath: $removedClasspath" }
return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_REMOVED_ENTRY) return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_REMOVED_ENTRY)
} }
@@ -53,7 +54,7 @@ internal fun getClasspathChanges(
val actualAbiSnapshot = lastBuildInfo.dependencyToAbiSnapshot[module] val actualAbiSnapshot = lastBuildInfo.dependencyToAbiSnapshot[module]
if (actualAbiSnapshot == null) { if (actualAbiSnapshot == null) {
reporter.report { "Some jar are removed from classpath $module" } reporter.info { "Some jar are removed from classpath $module" }
return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_REMOVED_ENTRY) return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_REMOVED_ENTRY)
} }
val diffData = AbiSnapshotDiffService.doCompute(abiSnapshot, actualAbiSnapshot, caches, scopes) val diffData = AbiSnapshotDiffService.doCompute(abiSnapshot, actualAbiSnapshot, caches, scopes)
@@ -80,7 +81,7 @@ internal fun getClasspathChanges(
val historyFiles = when (historyFilesEither) { val historyFiles = when (historyFilesEither) {
is Either.Success<Set<File>> -> historyFilesEither.value is Either.Success<Set<File>> -> historyFilesEither.value
is Either.Error -> { is Either.Error -> {
reporter.report { "Could not find history files: ${historyFilesEither.reason}" } reporter.info { "Could not find history files: ${historyFilesEither.reason}" }
return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_HISTORY_IS_NOT_FOUND) return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_HISTORY_IS_NOT_FOUND)
} }
} }
@@ -89,20 +90,20 @@ internal fun getClasspathChanges(
for (historyFile in historyFiles) { for (historyFile in historyFiles) {
val allBuilds = BuildDiffsStorage.readDiffsFromFile(historyFile, reporter = reporter) val allBuilds = BuildDiffsStorage.readDiffsFromFile(historyFile, reporter = reporter)
?: return run { ?: return run {
reporter.report { "Could not read diffs from $historyFile" } reporter.info { "Could not read diffs from $historyFile" }
ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_HISTORY_CANNOT_BE_READ) ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_HISTORY_CANNOT_BE_READ)
} }
val (knownBuilds, newBuilds) = allBuilds.partition { it.ts <= lastBuildTS } val (knownBuilds, newBuilds) = allBuilds.partition { it.ts <= lastBuildTS }
if (knownBuilds.isEmpty()) { if (knownBuilds.isEmpty()) {
reporter.report { "No previously known builds for $historyFile" } reporter.info { "No previously known builds for $historyFile" }
return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_HISTORY_NO_KNOWN_BUILDS) return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_HISTORY_NO_KNOWN_BUILDS)
} }
for (buildDiff in newBuilds) { for (buildDiff in newBuilds) {
if (!buildDiff.isIncremental) { if (!buildDiff.isIncremental) {
reporter.report { "Non-incremental build from dependency $historyFile" } reporter.info { "Non-incremental build from dependency $historyFile" }
return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_NON_INCREMENTAL_BUILD_IN_DEP) return ChangesEither.Unknown(BuildAttribute.DEP_CHANGE_NON_INCREMENTAL_BUILD_IN_DEP)
} }
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.incremental.classpathDiff
import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.build.report.DoNothingICReporter import org.jetbrains.kotlin.build.report.DoNothingICReporter
import org.jetbrains.kotlin.build.report.debug
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
import org.jetbrains.kotlin.build.report.metrics.BuildTime import org.jetbrains.kotlin.build.report.metrics.BuildTime
import org.jetbrains.kotlin.build.report.metrics.measure import org.jetbrains.kotlin.build.report.metrics.measure
@@ -52,7 +53,7 @@ object ClasspathChangesComputer {
) )
) )
} }
reporter.reportVerbose { reporter.debug {
"Shrunk current classpath snapshot for diffing," + "Shrunk current classpath snapshot for diffing," +
" retained ${shrunkCurrentClasspathAgainstPreviousLookups.size} / ${currentClasspathSnapshot.size} classes" " retained ${shrunkCurrentClasspathAgainstPreviousLookups.size} / ${currentClasspathSnapshot.size} classes"
} }
@@ -61,7 +62,7 @@ object ClasspathChangesComputer {
val shrunkPreviousClasspathSnapshot = reporter.measure(BuildTime.LOAD_SHRUNK_PREVIOUS_CLASSPATH_SNAPSHOT) { val shrunkPreviousClasspathSnapshot = reporter.measure(BuildTime.LOAD_SHRUNK_PREVIOUS_CLASSPATH_SNAPSHOT) {
ListExternalizer(AccessibleClassSnapshotExternalizer).loadFromFile(classpathSnapshotFiles.shrunkPreviousClasspathSnapshotFile) ListExternalizer(AccessibleClassSnapshotExternalizer).loadFromFile(classpathSnapshotFiles.shrunkPreviousClasspathSnapshotFile)
} }
reporter.reportVerbose { reporter.debug {
"Loaded shrunk previous classpath snapshot for diffing, found ${shrunkPreviousClasspathSnapshot.size} classes" "Loaded shrunk previous classpath snapshot for diffing, found ${shrunkPreviousClasspathSnapshot.size} classes"
} }
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.incremental.classpathDiff
import org.jetbrains.kotlin.build.report.BuildReporter import org.jetbrains.kotlin.build.report.BuildReporter
import org.jetbrains.kotlin.build.report.ICReporter import org.jetbrains.kotlin.build.report.ICReporter
import org.jetbrains.kotlin.build.report.debug
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
class ClasspathSnapshotBuildReporter(private val buildReporter: BuildReporter) : class ClasspathSnapshotBuildReporter(private val buildReporter: BuildReporter) :
@@ -17,7 +18,7 @@ class ClasspathSnapshotBuildReporter(private val buildReporter: BuildReporter) :
} }
fun reportVerboseWithLimit(maxLength: Int = 1000, message: () -> String) { fun reportVerboseWithLimit(maxLength: Int = 1000, message: () -> String) {
reportVerbose { debug {
message().let { message().let {
if (it.length > maxLength) { if (it.length > maxLength) {
it.substring(0, maxLength) + "... (string too long, showing $maxLength / ${it.length} chars)" it.substring(0, maxLength) + "... (string too long, showing $maxLength / ${it.length} chars)"
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.incremental.classpathDiff package org.jetbrains.kotlin.incremental.classpathDiff
import org.jetbrains.kotlin.build.report.debug
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric
import org.jetbrains.kotlin.build.report.metrics.BuildTime import org.jetbrains.kotlin.build.report.metrics.BuildTime
@@ -308,7 +309,7 @@ internal fun shrinkAndSaveClasspathSnapshot(
} }
} }
reporter.reportVerbose { reporter.debug {
"Shrunk current classpath snapshot after compilation (shrink mode = ${shrinkMode::class.simpleName})" + when (shrinkMode) { "Shrunk current classpath snapshot after compilation (shrink mode = ${shrinkMode::class.simpleName})" + when (shrinkMode) {
is ShrinkMode.UnchangedLookupsUnchangedClasspath -> ", no updates since previous run" is ShrinkMode.UnchangedLookupsUnchangedClasspath -> ", no updates since previous run"
else -> ", retained ${shrunkCurrentClasspath!!.size} / ${currentClasspath!!.size} classes" else -> ", retained ${shrunkCurrentClasspath!!.size} / ${currentClasspath!!.size} classes"
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.build.GeneratedFile
import org.jetbrains.kotlin.build.GeneratedJvmClass import org.jetbrains.kotlin.build.GeneratedJvmClass
import org.jetbrains.kotlin.build.report.ICReporter.ReportSeverity import org.jetbrains.kotlin.build.report.ICReporter.ReportSeverity
import org.jetbrains.kotlin.build.report.ICReporterBase import org.jetbrains.kotlin.build.report.ICReporterBase
import org.jetbrains.kotlin.build.report.debug
import org.jetbrains.kotlin.cli.common.ExitCode import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
@@ -750,7 +751,7 @@ private fun ChangesCollector.processChangesUsingLookups(
val allCaches = caches.flatMap { it.thisWithDependentCaches } val allCaches = caches.flatMap { it.thisWithDependentCaches }
val reporter = JpsICReporter() val reporter = JpsICReporter()
reporter.reportVerbose { "Start processing changes" } reporter.debug { "Start processing changes" }
val dirtyFiles = getDirtyFiles(allCaches, lookupStorageManager) val dirtyFiles = getDirtyFiles(allCaches, lookupStorageManager)
// if list of inheritors of sealed class has changed it should be recompiled with all the inheritors // if list of inheritors of sealed class has changed it should be recompiled with all the inheritors
@@ -764,7 +765,7 @@ private fun ChangesCollector.processChangesUsingLookups(
excludeFiles = excludeFiles excludeFiles = excludeFiles
) )
reporter.reportVerbose { "End of processing changes" } reporter.debug { "End of processing changes" }
} }
data class FilesToRecompile(val dirtyFiles: Set<File>, val forceRecompileTogether: Set<File>) data class FilesToRecompile(val dirtyFiles: Set<File>, val forceRecompileTogether: Set<File>)