mirror of
https://github.com/github/codeql.git
synced 2026-01-29 14:23:03 +01:00
Extractor: tolerate ast.File structures without a package declaration
In earlier versions of golang/x/tools these would be omitted entirely; now they can result in ast.File structures whose ast.Package field is zero (NoPos), and in my experience these contain no information in their other fields either.
This commit is contained in:
@@ -379,6 +379,10 @@ func normalizedPath(ast *ast.File, fset *token.FileSet) string {
|
||||
// extractFile extracts AST information for the given file
|
||||
func extractFile(ast *ast.File, pkg *packages.Package, fdSem *semaphore) error {
|
||||
fset := pkg.Fset
|
||||
if ast.Package == token.NoPos {
|
||||
log.Printf("Skipping extracting a file without a 'package' declaration")
|
||||
return nil
|
||||
}
|
||||
path := normalizedPath(ast, fset)
|
||||
|
||||
fdSem.acquire(3)
|
||||
|
||||
Reference in New Issue
Block a user