-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathOverlay.qll
More file actions
105 lines (90 loc) · 3.12 KB
/
Overlay.qll
File metadata and controls
105 lines (90 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/**
* Defines entity discard predicates for Java overlay analysis.
*/
overlay[local?]
module;
import java
private import internal.OverlayXml
/**
* A local predicate that always holds for the overlay variant and
* never holds for the base variant. This is used to define local
* predicates that behave differently for the base and overlay variant.
*/
overlay[local]
predicate isOverlay() { databaseMetadata("isOverlay", "true") }
/** Gets the raw file for a locatable. */
overlay[local]
string getRawFile(@locatable el) {
exists(@location loc, @file file |
hasLocation(el, loc) and
locations_default(loc, file, _, _, _, _) and
files(file, result)
)
}
/** Gets the raw file for a location. */
overlay[local]
string getRawFileForLoc(@location l) {
exists(@file f | locations_default(l, f, _, _, _, _) and files(f, result))
}
/**
* A `@locatable` that should be discarded in the base variant if its file is
* extracted in the overlay variant.
*/
overlay[local]
abstract class DiscardableLocatable extends @locatable {
/** Gets the raw file for a locatable in base. */
string getRawFileInBase() { not isOverlay() and result = getRawFile(this) }
/** Gets a textual representation of this discardable locatable. */
string toString() { none() }
}
overlay[discard_entity]
private predicate discardLocatable(@locatable el) {
overlayChangedFiles(el.(DiscardableLocatable).getRawFileInBase())
}
/**
* A `@locatable` that should be discarded in the base variant if its file is
* extracted in the overlay variant and it is itself not extracted in the
* overlay, that is, it is deleted in the overlay.
*/
overlay[local]
abstract class DiscardableReferableLocatable extends @locatable {
/** Gets the raw file for a locatable in base. */
string getRawFileInBase() { not isOverlay() and result = getRawFile(this) }
/** Holds if the locatable exists in the overlay. */
predicate existsInOverlay() { isOverlay() and exists(this) }
/** Gets a textual representation of this discardable locatable. */
string toString() { none() }
}
overlay[discard_entity]
private predicate discardReferableLocatable(@locatable el) {
exists(DiscardableReferableLocatable drl | drl = el |
overlayChangedFiles(drl.getRawFileInBase()) and
not drl.existsInOverlay()
)
}
/** Gets the raw file for a configLocatable. */
overlay[local]
private string getRawFileForConfig(@configLocatable el) {
exists(@location loc, @file file |
configLocations(el, loc) and
locations_default(loc, file, _, _, _, _) and
files(file, result)
)
}
overlay[local]
private string baseConfigLocatable(@configLocatable 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]
private predicate discardBaseConfigLocatable(@configLocatable 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))
}