-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathModules.qll
More file actions
199 lines (169 loc) · 5.3 KB
/
Modules.qll
File metadata and controls
199 lines (169 loc) · 5.3 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/**
* Provides classes for working with Java modules.
*/
overlay[local?]
module;
import CompilationUnit
/**
* A module.
*/
class Module extends @module {
Module() { modules(this, _) }
/**
* Gets the name of this module.
*/
string getName() { modules(this, result) }
/**
* Holds if this module is an `open` module, that is,
* it grants access _at run time_ to types in all its packages,
* as if all packages had been exported.
*/
predicate isOpen() { isOpen(this) }
/**
* Gets a directive of this module.
*/
Directive getADirective() { directives(this, result) }
/**
* Gets a compilation unit associated with this module.
*/
CompilationUnit getACompilationUnit() { cumodule(result, this) }
/** Gets a textual representation of this module. */
string toString() { modules(this, result) }
}
/**
* A directive in a module declaration.
*/
abstract class Directive extends @directive {
/** Gets a textual representation of this directive. */
abstract string toString();
}
/**
* A `requires` directive in a module declaration.
*/
class RequiresDirective extends Directive, @requires {
RequiresDirective() { requires(this, _) }
/**
* Holds if this `requires` directive is `transitive`,
* that is, any module that depends on this module
* has an implicitly declared dependency on the
* module specified in this `requires` directive.
*/
predicate isTransitive() { isTransitive(this) }
/**
* Holds if this `requires` directive is `static`,
* that is, the dependence specified by this `requires`
* directive is only mandatory at compile time but
* optional at run time.
*/
predicate isStatic() { isStatic(this) }
/**
* Gets the module on which this module depends.
*/
Module getTargetModule() { requires(this, result) }
override string toString() {
exists(string transitive, string static |
(if this.isTransitive() then transitive = "transitive " else transitive = "") and
(if this.isStatic() then static = "static " else static = "")
|
result = "requires " + transitive + static + this.getTargetModule() + ";"
)
}
}
/**
* An `exports` directive in a module declaration.
*/
class ExportsDirective extends Directive, @exports {
ExportsDirective() { exports(this, _) }
/**
* Gets the package exported by this `exports` directive.
*/
Package getExportedPackage() { exports(this, result) }
/**
* Holds if this `exports` directive is qualified, that is,
* it contains a `to` clause.
*
* For qualified `exports` directives, exported types and members
* are accessible only to code in the specified modules.
* For unqualified `exports` directives, they are accessible
* to code in any module.
*/
predicate isQualified() { exportsTo(this, _) }
/**
* Gets a module specified in the `to` clause of this
* `exports` directive, if any.
*/
Module getATargetModule() { exportsTo(this, result) }
override string toString() {
exists(string toClause |
if this.isQualified()
then toClause = (" to " + concat(this.getATargetModule().getName(), ", "))
else toClause = ""
|
result = "exports " + this.getExportedPackage() + toClause + ";"
)
}
}
/**
* An `opens` directive in a module declaration.
*/
class OpensDirective extends Directive, @opens {
OpensDirective() { opens(this, _) }
/**
* Gets the package opened by this `opens` directive.
*/
Package getOpenedPackage() { opens(this, result) }
/**
* Holds if this `opens` directive is qualified, that is,
* it contains a `to` clause.
*
* For qualified `opens` directives, opened types and members
* are accessible only to code in the specified modules.
* For unqualified `opens` directives, they are accessible
* to code in any module.
*/
predicate isQualified() { opensTo(this, _) }
/**
* Gets a module specified in the `to` clause of this
* `opens` directive, if any.
*/
Module getATargetModule() { opensTo(this, result) }
override string toString() {
exists(string toClause |
if this.isQualified()
then toClause = (" to " + concat(this.getATargetModule().getName(), ", "))
else toClause = ""
|
result = "opens " + this.getOpenedPackage() + toClause + ";"
)
}
}
/**
* A `uses` directive in a module declaration.
*/
class UsesDirective extends Directive, @uses {
UsesDirective() { uses(this, _) }
/**
* Gets the qualified name of the service interface specified in this `uses` directive.
*/
string getServiceInterfaceName() { uses(this, result) }
override string toString() { result = "uses " + this.getServiceInterfaceName() + ";" }
}
/**
* A `provides` directive in a module declaration.
*/
class ProvidesDirective extends Directive, @provides {
ProvidesDirective() { provides(this, _) }
/**
* Gets the qualified name of the service interface specified in this `provides` directive.
*/
string getServiceInterfaceName() { provides(this, result) }
/**
* Gets the qualified name of a service implementation specified in this `provides` directive.
*/
string getServiceImplementationName() { providesWith(this, result) }
override string toString() {
result =
"provides " + this.getServiceInterfaceName() + " with " +
concat(this.getServiceImplementationName(), ", ") + ";"
}
}