@@ -177,25 +177,12 @@ class Folder extends Container, @folder {
177
177
override string getURL ( ) { result = "folder://" + getAbsolutePath ( ) }
178
178
}
179
179
180
- /** A file. */
181
- class File extends Container , @file, Documentable , ExprParent , GoModExprParent , DeclParent ,
182
- ScopeNode {
183
- string path ;
184
-
185
- File ( ) {
186
- files ( this , path , _, _, _) and
187
- (
188
- // Exclude `.go` files that have not been extracted. Non-extracted files only exist in the `files`
189
- // table if we are reporting compilation errors relating to them in the `diagnostics` table.
190
- not path .matches ( "%.go" )
191
- or
192
- exists ( this .getAChild ( ) )
193
- )
194
- }
195
-
180
+ /** Any file, including files that have not been extracted but are referred to as locations for errors. */
181
+ class ExtractedOrExternalFile extends Container , @file, Documentable , ExprParent , GoModExprParent ,
182
+ DeclParent , ScopeNode {
196
183
override Location getLocation ( ) { has_location ( this , result ) }
197
184
198
- override string getAbsolutePath ( ) { result = path }
185
+ override string getAbsolutePath ( ) { files ( this , result , _ , _ , _ ) }
199
186
200
187
/** Gets the number of lines in this file. */
201
188
int getNumberOfLines ( ) { numlines ( this , result , _, _) }
@@ -266,3 +253,14 @@ class File extends Container, @file, Documentable, ExprParent, GoModExprParent,
266
253
267
254
override string getAPrimaryQlClass ( ) { result = "File" }
268
255
}
256
+
257
+ /** A file that has been extracted. */
258
+ class File extends ExtractedOrExternalFile {
259
+ File ( ) {
260
+ // getAChild is specifically for the Go AST and so does not apply to non-go files
261
+ // we care about all non-go extracted files, as only go files can have `@file` entries due to requiring a file entry for diagnostic errors
262
+ not this .getExtension ( ) = "go"
263
+ or
264
+ exists ( this .getAChild ( ) )
265
+ }
266
+ }
0 commit comments