Invalidate usages of removed classes before round

#KT-23165 fixed

Original commit: 3eb968807e
This commit is contained in:
Alexey Tsvetkov
2018-03-27 16:29:09 +03:00
parent 3174c9b05e
commit 88c4f73e3c
31 changed files with 324 additions and 204 deletions
@@ -425,8 +425,8 @@ abstract class AbstractIncrementalJpsTest(
override fun doGetProjectDir(): File? = workDir
private class MyLogger(val rootPath: String) : ProjectBuilderLoggerBase(), BuildLogger {
private val dirtyFiles = ArrayList<File>()
private val markedDirtyBeforeRound = ArrayList<File>()
private val markedDirtyAfterRound = ArrayList<File>()
override fun actionsOnCacheVersionChanged(actions: List<CacheVersion.Action>) {
if (actions.size > 1 && actions.any { it != CacheVersion.Action.DO_NOTHING }) {
@@ -434,8 +434,12 @@ abstract class AbstractIncrementalJpsTest(
}
}
override fun markedAsDirty(files: Iterable<File>) {
dirtyFiles.addAll(files)
override fun markedAsDirtyBeforeRound(files: Iterable<File>) {
markedDirtyBeforeRound.addAll(files)
}
override fun markedAsDirtyAfterRound(files: Iterable<File>) {
markedDirtyAfterRound.addAll(files)
}
override fun buildStarted(context: CompileContext, chunk: ModuleChunk) {
@@ -444,20 +448,29 @@ abstract class AbstractIncrementalJpsTest(
}
}
override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {
override fun afterBuildStarted(context: CompileContext, chunk: ModuleChunk) {
logDirtyFiles(markedDirtyBeforeRound)
}
if (dirtyFiles.isNotEmpty()) {
logLine("Marked as dirty by Kotlin:")
dirtyFiles
.map { FileUtil.toSystemIndependentName(it.path) }
.sorted()
.forEach { logLine(it) }
dirtyFiles.clear()
}
override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {
logDirtyFiles(markedDirtyAfterRound)
logLine("Exit code: $exitCode")
logLine("------------------------------------------")
}
private fun logDirtyFiles(files: MutableList<File>) {
if (files.isEmpty()) return
logLine("Marked as dirty by Kotlin:")
files.apply {
map { FileUtil.toSystemIndependentName(it.path) }
.sorted()
.forEach { logLine(it) }
clear()
}
}
private val logBuf = StringBuilder()
val log: String
get() = logBuf.toString()
@@ -1494,6 +1494,12 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
doTest(fileName);
}
@TestMetadata("classMovedIntoOtherClass")
public void testClassMovedIntoOtherClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/classHierarchyAffected/classMovedIntoOtherClass/");
doTest(fileName);
}
@TestMetadata("classRemoved")
public void testClassRemoved() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/classHierarchyAffected/classRemoved/");
@@ -956,16 +956,18 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
val actual = StringBuilder()
buildCustom(CanceledStatus.NULL, TestProjectBuilderLogger(), BuildResult()) {
project.setTestingContext(TestingContext(LookupTracker.DO_NOTHING, object: BuildLogger {
project.setTestingContext(TestingContext(LookupTracker.DO_NOTHING, object : BuildLogger {
override fun buildStarted(context: CompileContext, chunk: ModuleChunk) {
actual.append("Targets dependent on ${chunk.targets.joinToString() }:\n")
actual.append(getDependentTargets(chunk, context).map { it.toString() }.sorted().joinToString("\n"))
actual.append("\n---------\n")
}
override fun afterBuildStarted(context: CompileContext, chunk: ModuleChunk) {}
override fun actionsOnCacheVersionChanged(actions: List<CacheVersion.Action>) {}
override fun buildFinished(exitCode: ModuleLevelBuilder.ExitCode) {}
override fun markedAsDirty(files: Iterable<File>) {}
override fun markedAsDirtyBeforeRound(files: Iterable<File>) {}
override fun markedAsDirtyAfterRound(files: Iterable<File>) {}
}))
}