Merge pull request #20505 from kaspersv/kaspersv/future-proof-java-discarding2

Overlay: Discard Java config and XML base entities in overlay extracted files
This commit is contained in:
Kasper Svendsen
2025-09-29 13:01:08 +02:00
committed by GitHub
2 changed files with 43 additions and 5 deletions

View File

@@ -88,7 +88,45 @@ private string baseConfigLocatable(@configLocatable el) {
not isOverlay() and result = getRawFileForConfig(el) not isOverlay() and result = getRawFileForConfig(el)
} }
overlay[local]
private predicate overlayConfigExtracted(string file) {
isOverlay() and
exists(@configLocatable el | file = getRawFileForConfig(el))
}
overlay[discard_entity] overlay[discard_entity]
private predicate discardBaseConfigLocatable(@configLocatable el) { private predicate discardBaseConfigLocatable(@configLocatable el) {
overlayChangedFiles(baseConfigLocatable(el)) overlayChangedFiles(baseConfigLocatable(el))
or
// The config extractor is currently not incremental and may extract more
// property files than those included in overlayChangedFiles.
overlayConfigExtracted(baseConfigLocatable(el))
}
/**
* An `@xmllocatable` that should be discarded in the base variant if its file is
* extracted in the overlay variant.
*/
overlay[local]
abstract class DiscardableXmlLocatable extends @xmllocatable {
/** Gets the raw file for an xmllocatable in base. */
string getRawFileInBase() { not isOverlay() and result = getRawFile(this) }
/** Gets a textual representation of this discardable xmllocatable. */
string toString() { none() }
}
overlay[local]
private predicate overlayXmlExtracted(string file) {
isOverlay() and
exists(@xmllocatable el | not files(el, _) and not xmlNs(el, _, _, _) and file = getRawFile(el))
}
overlay[discard_entity]
private predicate discardXmlLocatable(@xmllocatable el) {
overlayChangedFiles(el.(DiscardableXmlLocatable).getRawFileInBase())
or
// The XML extractor is currently not incremental and may extract more
// XML files than those included in overlayChangedFiles.
overlayXmlExtracted(el.(DiscardableXmlLocatable).getRawFileInBase())
} }

View File

@@ -71,12 +71,12 @@ private module Input implements InputSig<File, Location> {
import Make<File, Location, Input> import Make<File, Location, Input>
private class DiscardableXmlAttribute extends DiscardableLocatable, @xmlattribute { } private class DiscardableXmlAttribute extends DiscardableXmlLocatable, @xmlattribute { }
private class DiscardableXmlElement extends DiscardableLocatable, @xmlelement { } private class DiscardableXmlElement extends DiscardableXmlLocatable, @xmlelement { }
private class DiscardableXmlComment extends DiscardableLocatable, @xmlcomment { } private class DiscardableXmlComment extends DiscardableXmlLocatable, @xmlcomment { }
private class DiscardableXmlCharacters extends DiscardableLocatable, @xmlcharacters { } private class DiscardableXmlCharacters extends DiscardableXmlLocatable, @xmlcharacters { }
private class DiscardableXmlDtd extends DiscardableLocatable, @xmldtd { } private class DiscardableXmlDtd extends DiscardableXmlLocatable, @xmldtd { }