Avoid rebuilds after changes of layouts xml-files

This commit makes IC react more granularly on these changes
Precisely, it marks dirty only kt-files that having lookups into
synthetic package built upon a changed layout-file

 #KT-21622 Fixed
This commit is contained in:
Denis Zharkov
2017-12-05 17:52:21 +03:00
parent 58123f2103
commit e24e711208
11 changed files with 99 additions and 19 deletions
@@ -212,10 +212,9 @@ class IncrementalJvmCompilerRunner(
}
}
if ((changedFiles.modified + changedFiles.removed).any { it.extension.toLowerCase() == "xml" }) {
return CompilationMode.Rebuild { "XML resource files were changed" }
}
val androidLayoutChanges = processLookupSymbolsForAndroidLayouts(changedFiles)
markDirtyBy(androidLayoutChanges)
markDirtyBy(classpathChanges.lookupSymbols)
markDirtyBy(classpathChanges.fqNames)
@@ -260,6 +259,17 @@ class IncrementalJvmCompilerRunner(
}
}
private fun processLookupSymbolsForAndroidLayouts(changedFiles: ChangedFiles.Known): Collection<LookupSymbol> {
val result = mutableListOf<LookupSymbol>()
for (file in changedFiles.modified + changedFiles.removed) {
if (file.extension.toLowerCase() != "xml") continue
val layoutName = file.name.substringBeforeLast('.')
result.add(LookupSymbol(ANDROID_LAYOUT_CONTENT_LOOKUP_NAME, layoutName))
}
return result
}
private fun getClasspathChanges(
modifiedClasspath: List<File>,
lastBuildInfo: BuildInfo?