@@ -35,3 +35,46 @@ predicate extractedInOverlay(string file) {
35
35
// ignore skeleton extracted files in the overlay
36
36
exists ( @locatable l | numlines ( l , _, _, _) and file = getRawFile ( l ) )
37
37
}
38
+
39
+ /**
40
+ * A `@locatable` in the base variant that should be discarded if its file is
41
+ * extracted in the overlay variant.
42
+ */
43
+ overlay [ local]
44
+ abstract class DiscardableLocatable extends @locatable {
45
+ /** Gets the raw file for a locatable in base. */
46
+ string getRawFileInBase ( ) { not isOverlay ( ) and result = getRawFile ( this ) }
47
+
48
+ /** Gets a textual representation of this discardable locatable. */
49
+ string toString ( ) { none ( ) }
50
+ }
51
+
52
+ overlay [ discard_entity]
53
+ private predicate discardLocatable ( @locatable el ) {
54
+ extractedInOverlay ( el .( DiscardableLocatable ) .getRawFileInBase ( ) )
55
+ }
56
+
57
+ /**
58
+ * A `@locatable` in the base variant that should be discarded if its file is
59
+ * extracted in the overlay variant and it is itself not extracted in the
60
+ * overlay, that is, it is deleted in the overlay.
61
+ */
62
+ overlay [ local]
63
+ abstract class DiscardableReferableLocatable extends @locatable {
64
+ /** Gets the raw file for a locatable in base. */
65
+ string getRawFileInBase ( ) { not isOverlay ( ) and result = getRawFile ( this ) }
66
+
67
+ /** Holds if the locatable exists in the overlay. */
68
+ predicate existsInOverlay ( ) { isOverlay ( ) and exists ( this ) }
69
+
70
+ /** Gets a textual representation of this discardable locatable. */
71
+ string toString ( ) { none ( ) }
72
+ }
73
+
74
+ overlay [ discard_entity]
75
+ private predicate discardReferableLocatable ( @locatable el ) {
76
+ exists ( DiscardableReferableLocatable drl | drl = el |
77
+ extractedInOverlay ( drl .getRawFileInBase ( ) ) and
78
+ not drl .existsInOverlay ( )
79
+ )
80
+ }
0 commit comments