@@ -182,6 +182,14 @@ class Folder extends Container, @folder {
182182 override string getURL ( ) { result = "folder://" + this .getAbsolutePath ( ) }
183183}
184184
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+
185193/** A file. */
186194class File extends Container , @file {
187195 override string getAbsolutePath ( ) { files ( this , result ) }
@@ -199,7 +207,10 @@ class File extends Container, @file {
199207
200208 /** Holds if this file is a QL test stub file. */
201209 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+ }
203214
204215 /** Holds if this file contains source code. */
205216 final predicate fromSource ( ) {
@@ -218,12 +229,12 @@ class File extends Container, @file {
218229 * A source file can come from a PDB and from regular extraction
219230 * in the same snapshot.
220231 */
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 ) }
227238}
228239
229240/**
@@ -233,10 +244,5 @@ class SourceFile extends File {
233244 SourceFile ( ) { this .fromSource ( ) }
234245
235246 /** 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 ) }
242248}
0 commit comments