From 1c245ba6365603efe4dee3b95549c3d13e060023 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Thu, 14 Oct 2021 11:37:05 +0200 Subject: [PATCH 1/2] Fix getAPrimaryQlClass for File classes --- ql/lib/semmle/go/Files.qll | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ql/lib/semmle/go/Files.qll b/ql/lib/semmle/go/Files.qll index 28cb395beb3..dab47fdc81e 100644 --- a/ql/lib/semmle/go/Files.qll +++ b/ql/lib/semmle/go/Files.qll @@ -253,7 +253,7 @@ class ExtractedOrExternalFile extends Container, @file, Documentable, ExprParent /** Gets the number of child comment groups of this file. */ int getNumCommentGroups() { result = count(getACommentGroup()) } - override string getAPrimaryQlClass() { result = "File" } + override string getAPrimaryQlClass() { result = "ExtractedOrExternalFile" } } /** A file that has been extracted. */ @@ -265,14 +265,20 @@ class File extends ExtractedOrExternalFile { or exists(this.getAChild()) } + + override string getAPrimaryQlClass() { result = "File" } } /** A Go file. */ class GoFile extends File { GoFile() { this.getExtension() = "go" } + + override string getAPrimaryQlClass() { result = "GoFile" } } /** An HTML file. */ class HtmlFile extends File { HtmlFile() { this.getExtension().regexpMatch("x?html?") } + + override string getAPrimaryQlClass() { result = "HtmlFile" } } From 61a0c44ef60aedba0edd79d1f59b9bb9816db968 Mon Sep 17 00:00:00 2001 From: Jonas Jensen Date: Fri, 15 Oct 2021 08:04:58 +0200 Subject: [PATCH 2/2] Accept test changes: File -> GoFile --- ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected | 4 ++-- .../semmle/go/PrintAst/PrintAstExcludeComments.expected | 4 ++-- .../semmle/go/PrintAst/PrintAstNestedFunction.expected | 4 ++-- .../semmle/go/PrintAst/PrintAstRestrictFile.expected | 2 +- .../semmle/go/PrintAst/PrintAstRestrictFunction.expected | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected b/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected index eefefcc1d84..fdc0a503483 100644 --- a/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected +++ b/ql/test/library-tests/semmle/go/PrintAst/PrintAst.expected @@ -3,7 +3,7 @@ go.mod: # 1| 0: [GoModModuleLine] go.mod module line # 3| 1: [GoModGoLine] go.mod go line input.go: -# 0| [File] library-tests/semmle/go/PrintAst/input.go +# 0| [GoFile] library-tests/semmle/go/PrintAst/input.go # 1| package: [Ident] main # 5| 1: [CommentGroup] comment group # 5| 0: [SlashSlashComment] comment @@ -597,7 +597,7 @@ input.go: # 145| Type = []int # 145| 1: [BlockStmt] block statement other.go: -# 0| [File] library-tests/semmle/go/PrintAst/other.go +# 0| [GoFile] library-tests/semmle/go/PrintAst/other.go # 1| package: [Ident] main # 3| 1: [FuncDecl] function declaration # 3| 0: [FunctionName, Ident] main diff --git a/ql/test/library-tests/semmle/go/PrintAst/PrintAstExcludeComments.expected b/ql/test/library-tests/semmle/go/PrintAst/PrintAstExcludeComments.expected index 4445baaf957..d682fa60763 100644 --- a/ql/test/library-tests/semmle/go/PrintAst/PrintAstExcludeComments.expected +++ b/ql/test/library-tests/semmle/go/PrintAst/PrintAstExcludeComments.expected @@ -3,7 +3,7 @@ go.mod: # 1| 0: [GoModModuleLine] go.mod module line # 3| 1: [GoModGoLine] go.mod go line input.go: -# 0| [File] library-tests/semmle/go/PrintAst/input.go +# 0| [GoFile] library-tests/semmle/go/PrintAst/input.go # 1| package: [Ident] main # 3| 1: [ImportDecl] import declaration # 3| 0: [ImportSpec] import specifier @@ -577,7 +577,7 @@ input.go: # 145| Type = []int # 145| 1: [BlockStmt] block statement other.go: -# 0| [File] library-tests/semmle/go/PrintAst/other.go +# 0| [GoFile] library-tests/semmle/go/PrintAst/other.go # 1| package: [Ident] main # 3| 1: [FuncDecl] function declaration # 3| 0: [FunctionName, Ident] main diff --git a/ql/test/library-tests/semmle/go/PrintAst/PrintAstNestedFunction.expected b/ql/test/library-tests/semmle/go/PrintAst/PrintAstNestedFunction.expected index a9b58c3741d..7a04ffd637c 100644 --- a/ql/test/library-tests/semmle/go/PrintAst/PrintAstNestedFunction.expected +++ b/ql/test/library-tests/semmle/go/PrintAst/PrintAstNestedFunction.expected @@ -3,7 +3,7 @@ go.mod: # 1| 0: [GoModModuleLine] go.mod module line # 3| 1: [GoModGoLine] go.mod go line input.go: -# 0| [File] library-tests/semmle/go/PrintAst/input.go +# 0| [GoFile] library-tests/semmle/go/PrintAst/input.go # 1| package: [Ident] main # 5| 1: [CommentGroup] comment group # 5| 0: [SlashSlashComment] comment @@ -29,7 +29,7 @@ input.go: # 3| 0: [ImportSpec] import specifier # 3| 0: [StringLit] "fmt" other.go: -# 0| [File] library-tests/semmle/go/PrintAst/other.go +# 0| [GoFile] library-tests/semmle/go/PrintAst/other.go # 1| package: [Ident] main # 8| 1: [FuncDecl] function declaration # 8| 0: [FunctionName, Ident] hasNested diff --git a/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFile.expected b/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFile.expected index f58fc8a876e..3df7749557d 100644 --- a/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFile.expected +++ b/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFile.expected @@ -1,5 +1,5 @@ other.go: -# 0| [File] library-tests/semmle/go/PrintAst/other.go +# 0| [GoFile] library-tests/semmle/go/PrintAst/other.go # 1| package: [Ident] main # 3| 1: [FuncDecl] function declaration # 3| 0: [FunctionName, Ident] main diff --git a/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFunction.expected b/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFunction.expected index 9302312cc49..85f2335d5b0 100644 --- a/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFunction.expected +++ b/ql/test/library-tests/semmle/go/PrintAst/PrintAstRestrictFunction.expected @@ -3,7 +3,7 @@ go.mod: # 1| 0: [GoModModuleLine] go.mod module line # 3| 1: [GoModGoLine] go.mod go line input.go: -# 0| [File] library-tests/semmle/go/PrintAst/input.go +# 0| [GoFile] library-tests/semmle/go/PrintAst/input.go # 1| package: [Ident] main # 5| 1: [CommentGroup] comment group # 5| 0: [SlashSlashComment] comment @@ -29,7 +29,7 @@ input.go: # 3| 0: [ImportSpec] import specifier # 3| 0: [StringLit] "fmt" other.go: -# 0| [File] library-tests/semmle/go/PrintAst/other.go +# 0| [GoFile] library-tests/semmle/go/PrintAst/other.go # 1| package: [Ident] main # 6| 1: [FuncDecl] function declaration # 6| 0: [FunctionName, Ident] g