Report messages only after IC scope expansion converged
Incremental compilation scope (set of files to be compiled) could be expanded, even if the frontend reported some errors to a message collector. The next iteration of IC could produce a different set of compiler messages, so we want to report them only after scope expansion converged.
This commit is contained in:
+29
-3
@@ -20,6 +20,8 @@ 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.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.CompilerMessageLocation
|
||||||
|
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.compilerRunner.MessageCollectorToOutputItemsCollectorAdapter
|
import org.jetbrains.kotlin.compilerRunner.MessageCollectorToOutputItemsCollectorAdapter
|
||||||
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
|
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
|
||||||
@@ -233,14 +235,13 @@ abstract class IncrementalCompilerRunner<
|
|||||||
|
|
||||||
args.reportOutputFiles = true
|
args.reportOutputFiles = true
|
||||||
val outputItemsCollector = OutputItemsCollectorImpl()
|
val outputItemsCollector = OutputItemsCollectorImpl()
|
||||||
val messageCollectorAdapter = MessageCollectorToOutputItemsCollectorAdapter(messageCollector, outputItemsCollector)
|
val temporaryMessageCollector = TemporaryMessageCollector(messageCollector)
|
||||||
|
val messageCollectorAdapter = MessageCollectorToOutputItemsCollectorAdapter(temporaryMessageCollector, outputItemsCollector)
|
||||||
|
|
||||||
exitCode = runCompiler(sourcesToCompile.toSet(), args, caches, services, messageCollectorAdapter)
|
exitCode = runCompiler(sourcesToCompile.toSet(), args, caches, services, messageCollectorAdapter)
|
||||||
postCompilationHook(exitCode)
|
postCompilationHook(exitCode)
|
||||||
|
|
||||||
reporter.reportCompileIteration(compilationMode is CompilationMode.Incremental, sourcesToCompile, exitCode)
|
|
||||||
val generatedFiles = outputItemsCollector.outputs.map(SimpleOutputItem::toGeneratedFile)
|
val generatedFiles = outputItemsCollector.outputs.map(SimpleOutputItem::toGeneratedFile)
|
||||||
|
|
||||||
if (compilationMode is CompilationMode.Incremental) {
|
if (compilationMode is CompilationMode.Incremental) {
|
||||||
// todo: feels dirty, can this be refactored?
|
// todo: feels dirty, can this be refactored?
|
||||||
val dirtySourcesSet = dirtySources.toHashSet()
|
val dirtySourcesSet = dirtySources.toHashSet()
|
||||||
@@ -250,6 +251,10 @@ abstract class IncrementalCompilerRunner<
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reporter.reportCompileIteration(compilationMode is CompilationMode.Incremental, sourcesToCompile, exitCode)
|
||||||
|
temporaryMessageCollector.flush()
|
||||||
|
|
||||||
if (exitCode != ExitCode.OK) break
|
if (exitCode != ExitCode.OK) break
|
||||||
|
|
||||||
dirtySourcesSinceLastTimeFile.delete()
|
dirtySourcesSinceLastTimeFile.delete()
|
||||||
@@ -347,3 +352,24 @@ abstract class IncrementalCompilerRunner<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class TemporaryMessageCollector(private val delegate: MessageCollector) : MessageCollector {
|
||||||
|
private class Message(val severity: CompilerMessageSeverity, val message: String, val location: CompilerMessageLocation?)
|
||||||
|
|
||||||
|
private val messages = ArrayList<Message>()
|
||||||
|
|
||||||
|
override fun clear() {
|
||||||
|
messages.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun report(severity: CompilerMessageSeverity, message: String, location: CompilerMessageLocation?) {
|
||||||
|
messages.add(Message(severity, message, location))
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hasErrors(): Boolean =
|
||||||
|
messages.any { it.severity.isError }
|
||||||
|
|
||||||
|
fun flush() {
|
||||||
|
messages.forEach { delegate.report(it.severity, it.message, it.location) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user