|
| 1 | +overlay[local] |
| 2 | +module; |
| 3 | + |
| 4 | +/** |
| 5 | + * A local predicate that always holds for the overlay variant and never holds for the base variant. |
| 6 | + * This is used to define local predicates that behave differently for the base and overlay variant. |
| 7 | + */ |
| 8 | +private predicate isOverlay() { databaseMetadata("isOverlay", "true") } |
| 9 | + |
| 10 | +private string getXmlFile(@xmllocatable locatable) { |
| 11 | + exists(@location_default location, @file file | xmllocations(locatable, location) | |
| 12 | + locations_default(location, file, _, _, _, _) and |
| 13 | + files(file, result) |
| 14 | + ) |
| 15 | +} |
| 16 | + |
| 17 | +private string getXmlFileInBase(@xmllocatable locatable) { |
| 18 | + not isOverlay() and |
| 19 | + result = getXmlFile(locatable) |
| 20 | +} |
| 21 | + |
| 22 | +/** |
| 23 | + * Holds if the given `file` was extracted as part of the overlay and was extracted by the HTML/XML |
| 24 | + * extractor. |
| 25 | + */ |
| 26 | +private predicate overlayXmlExtracted(string file) { |
| 27 | + isOverlay() and |
| 28 | + exists(@xmllocatable locatable | |
| 29 | + not files(locatable, _) and not xmlNs(locatable, _, _, _) and file = getXmlFile(locatable) |
| 30 | + ) |
| 31 | +} |
| 32 | + |
| 33 | +/** |
| 34 | + * Holds if the given XML `locatable` should be discarded, because it is part of the overlay base |
| 35 | + * and is in a file that was also extracted as part of the overlay database. |
| 36 | + */ |
| 37 | +overlay[discard_entity] |
| 38 | +private predicate discardXmlLocatable(@xmllocatable locatable) { |
| 39 | + exists(string file | file = getXmlFileInBase(locatable) | |
| 40 | + overlayChangedFiles(file) |
| 41 | + or |
| 42 | + // The HTML/XML extractor is currently not incremental and may extract more files than those |
| 43 | + // included in overlayChangedFiles. |
| 44 | + overlayXmlExtracted(file) |
| 45 | + ) |
| 46 | +} |
0 commit comments