@@ -182,6 +182,14 @@ class Folder extends Container, @folder {
182
182
override string getURL ( ) { result = "folder://" + this .getAbsolutePath ( ) }
183
183
}
184
184
185
+ bindingset [ flag]
186
+ private predicate fileHasExtractionFlag ( File f , int flag ) {
187
+ exists ( int i |
188
+ file_extraction_mode ( f , i ) and
189
+ i .bitAnd ( flag ) = flag
190
+ )
191
+ }
192
+
185
193
/** A file. */
186
194
class File extends Container , @file {
187
195
override string getAbsolutePath ( ) { files ( this , result ) }
@@ -199,7 +207,10 @@ class File extends Container, @file {
199
207
200
208
/** Holds if this file is a QL test stub file. */
201
209
pragma [ noinline]
202
- private predicate isStub ( ) { this .getAbsolutePath ( ) .matches ( "%resources/stubs/%" ) }
210
+ private predicate isStub ( ) {
211
+ this .extractedQlTest ( ) and
212
+ this .getAbsolutePath ( ) .matches ( "%resources/stubs/%" )
213
+ }
203
214
204
215
/** Holds if this file contains source code. */
205
216
final predicate fromSource ( ) {
@@ -218,12 +229,12 @@ class File extends Container, @file {
218
229
* A source file can come from a PDB and from regular extraction
219
230
* in the same snapshot.
220
231
*/
221
- predicate isPdbSourceFile ( ) {
222
- exists ( int i |
223
- file_extraction_mode ( this , i ) and
224
- i . bitAnd ( 2 ) = 2
225
- )
226
- }
232
+ predicate isPdbSourceFile ( ) { fileHasExtractionFlag ( this , 2 ) }
233
+
234
+ /**
235
+ * Holds if this file was extracted using `codeql test run`.
236
+ */
237
+ predicate extractedQlTest ( ) { fileHasExtractionFlag ( this , 4 ) }
227
238
}
228
239
229
240
/**
@@ -233,10 +244,5 @@ class SourceFile extends File {
233
244
SourceFile ( ) { this .fromSource ( ) }
234
245
235
246
/** Holds if the file was extracted without building the source code. */
236
- predicate extractedStandalone ( ) {
237
- exists ( int i |
238
- file_extraction_mode ( this , i ) and
239
- i .bitAnd ( 1 ) = 1
240
- )
241
- }
247
+ predicate extractedStandalone ( ) { fileHasExtractionFlag ( this , 1 ) }
242
248
}
0 commit comments