@@ -307,40 +307,51 @@ final private class DiscardableComment extends Discardable instanceof @py_commen
307307
308308/*- XML -*/
309309overlay [ local]
310- private predicate baseXmlLocatable ( @xmllocatable l ) {
311- not isOverlay ( ) and not files ( l , _) and not xmlNs ( l , _, _, _)
310+ final private class DiscardableXmlLocatable extends Discardable instanceof @xmllocatable {
311+ override string getPath ( ) {
312+ exists ( @location loc | xmllocations ( this , loc ) | result = getPathForLocation ( loc ) )
313+ }
312314}
313315
314316overlay [ local]
315- private predicate overlayHasXmlLocatable ( ) {
316- isOverlay ( ) and
317- exists ( @xmllocatable l | not files ( l , _) and not xmlNs ( l , _, _, _) )
317+ private predicate overlayXmlExtracted ( string path ) {
318+ exists ( DiscardableXmlLocatable d | not files ( d , _) and not xmlNs ( d , _, _, _) |
319+ d .existsInOverlay ( ) and
320+ path = d .getPath ( )
321+ )
318322}
319323
320324overlay [ discard_entity]
321- private predicate discardBaseXmlLocatable ( @xmllocatable el ) {
322- // The XML extractor is currently not incremental, so if
323- // the overlay contains any XML locatables, the overlay should
324- // contain a full extraction and all XML locatables from base
325- // should be discarded.
326- baseXmlLocatable ( el ) and overlayHasXmlLocatable ( )
325+ private predicate discardXmlLocatable ( @xmllocatable el ) {
326+ exists ( DiscardableXmlLocatable d | d = el |
327+ // The XML extractor is currently not incremental and may extract more
328+ // XML files than those included in `overlayChangedFiles`, so this discard predicate
329+ // handles those files alongside the normal `discardStarEntity` logic.
330+ overlayXmlExtracted ( d .getPath ( ) ) and
331+ d .existsInBase ( )
332+ )
327333}
328334
329335/*- YAML -*/
330336overlay [ local]
331- private predicate baseYamlLocatable ( @yaml_locatable l ) { not isOverlay ( ) and exists ( l ) }
337+ final private class DiscardableYamlLocatable extends Discardable instanceof @yaml_locatable {
338+ override string getPath ( ) {
339+ exists ( @location loc | yaml_locations ( this , loc ) | result = getPathForLocation ( loc ) )
340+ }
341+ }
332342
333343overlay [ local]
334- private predicate overlayHasYamlLocatable ( ) {
335- isOverlay ( ) and
336- exists ( @yaml_locatable l )
344+ private predicate overlayYamlExtracted ( string path ) {
345+ exists ( DiscardableYamlLocatable l | l .existsInOverlay ( ) | path = l .getPath ( ) )
337346}
338347
339348overlay [ discard_entity]
340349private predicate discardBaseYamlLocatable ( @yaml_locatable el ) {
341- // The Yaml extractor is currently not incremental, so if
342- // the overlay contains any Yaml locatables, the overlay should
343- // contain a full extraction and all Yaml locatables from base
344- // should be discarded.
345- baseYamlLocatable ( el ) and overlayHasYamlLocatable ( )
350+ exists ( DiscardableYamlLocatable d | d = el |
351+ // The Yaml extractor is currently not incremental and may extract more
352+ // Yaml files than those included in `overlayChangedFiles`, so this discard predicate
353+ // handles those files alongside the normal `discardStarEntity` logic.
354+ overlayYamlExtracted ( d .getPath ( ) ) and
355+ d .existsInBase ( )
356+ )
346357}
0 commit comments