mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #17794 from owen-mc/go/ast-viewer-typeparamdecl
Go: Fix type param declarations in AST viewer
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The AST viewer now shows type parameter declarations in the correct place in the AST.
|
||||
@@ -55,6 +55,8 @@ class AstNode extends @node, Locatable {
|
||||
kind = "commentgroup" and result = this.(File).getCommentGroup(i)
|
||||
or
|
||||
kind = "comment" and result = this.(CommentGroup).getComment(i)
|
||||
or
|
||||
kind = "typeparamdecl" and result = this.(TypeParamDeclParent).getTypeParameterDecl(i)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -639,6 +639,11 @@ other.go:
|
||||
# 11| Type = int
|
||||
# 11| 0: [Ident, VariableName] myNested
|
||||
# 11| Type = func() int
|
||||
# 8| 3: [TypeParamDecl] type parameter declaration
|
||||
# 8| 0: [Ident, TypeName] int
|
||||
# 8| Type = int
|
||||
# 8| 1: [Ident, TypeName] U
|
||||
# 8| Type = U
|
||||
# 15| 5: [VarDecl] variable declaration
|
||||
# 15| 0: [ValueSpec] value declaration specifier
|
||||
# 15| 0: [Ident, VariableName] x
|
||||
@@ -648,3 +653,32 @@ other.go:
|
||||
# 15| 2: [IntLit] 0
|
||||
# 15| Type = int
|
||||
# 15| Value = [IntLit] 0
|
||||
# 17| 6: [TypeDecl] type declaration
|
||||
# 17| 0: [TypeSpec] type declaration specifier
|
||||
# 17| 0: [Ident, TypeName] myType
|
||||
# 17| Type = myType
|
||||
# 17| 1: [ArrayTypeExpr] array type
|
||||
# 17| Type = []T
|
||||
# 17| 0: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
# 17| 2: [TypeParamDecl] type parameter declaration
|
||||
# 17| 0: [TypeSetLiteralExpr] type set literal
|
||||
# 17| Type = ~string
|
||||
# 17| 0: [Ident, TypeName] string
|
||||
# 17| Type = string
|
||||
# 17| 1: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
# 19| 7: [MethodDecl] function declaration
|
||||
# 19| 0: [FunctionName, Ident] f
|
||||
# 19| Type = func()
|
||||
# 19| 1: [FuncTypeExpr] function type
|
||||
# 19| 2: [ReceiverDecl] receiver declaration
|
||||
# 19| 0: [GenericTypeInstantiationExpr] generic type instantiation expression
|
||||
# 19| Type = myType
|
||||
# 19| 0: [Ident, TypeName] myType
|
||||
# 19| Type = myType
|
||||
# 19| 1: [Ident, TypeName] U
|
||||
# 19| Type = U
|
||||
# 19| 1: [Ident, VariableName] m
|
||||
# 19| Type = myType
|
||||
# 19| 3: [BlockStmt] block statement
|
||||
|
||||
@@ -619,6 +619,11 @@ other.go:
|
||||
# 11| Type = int
|
||||
# 11| 0: [Ident, VariableName] myNested
|
||||
# 11| Type = func() int
|
||||
# 8| 3: [TypeParamDecl] type parameter declaration
|
||||
# 8| 0: [Ident, TypeName] int
|
||||
# 8| Type = int
|
||||
# 8| 1: [Ident, TypeName] U
|
||||
# 8| Type = U
|
||||
# 15| 5: [VarDecl] variable declaration
|
||||
# 15| 0: [ValueSpec] value declaration specifier
|
||||
# 15| 0: [Ident, VariableName] x
|
||||
@@ -628,3 +633,32 @@ other.go:
|
||||
# 15| 2: [IntLit] 0
|
||||
# 15| Type = int
|
||||
# 15| Value = [IntLit] 0
|
||||
# 17| 6: [TypeDecl] type declaration
|
||||
# 17| 0: [TypeSpec] type declaration specifier
|
||||
# 17| 0: [Ident, TypeName] myType
|
||||
# 17| Type = myType
|
||||
# 17| 1: [ArrayTypeExpr] array type
|
||||
# 17| Type = []T
|
||||
# 17| 0: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
# 17| 2: [TypeParamDecl] type parameter declaration
|
||||
# 17| 0: [TypeSetLiteralExpr] type set literal
|
||||
# 17| Type = ~string
|
||||
# 17| 0: [Ident, TypeName] string
|
||||
# 17| Type = string
|
||||
# 17| 1: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
# 19| 7: [MethodDecl] function declaration
|
||||
# 19| 0: [FunctionName, Ident] f
|
||||
# 19| Type = func()
|
||||
# 19| 1: [FuncTypeExpr] function type
|
||||
# 19| 2: [ReceiverDecl] receiver declaration
|
||||
# 19| 0: [GenericTypeInstantiationExpr] generic type instantiation expression
|
||||
# 19| Type = myType
|
||||
# 19| 0: [Ident, TypeName] myType
|
||||
# 19| Type = myType
|
||||
# 19| 1: [Ident, TypeName] U
|
||||
# 19| Type = U
|
||||
# 19| 1: [Ident, VariableName] m
|
||||
# 19| Type = myType
|
||||
# 19| 3: [BlockStmt] block statement
|
||||
|
||||
@@ -56,6 +56,11 @@ other.go:
|
||||
# 11| Type = int
|
||||
# 11| 0: [Ident, VariableName] myNested
|
||||
# 11| Type = func() int
|
||||
# 8| 3: [TypeParamDecl] type parameter declaration
|
||||
# 8| 0: [Ident, TypeName] int
|
||||
# 8| Type = int
|
||||
# 8| 1: [Ident, TypeName] U
|
||||
# 8| Type = U
|
||||
# 15| 2: [VarDecl] variable declaration
|
||||
# 15| 0: [ValueSpec] value declaration specifier
|
||||
# 15| 0: [Ident, VariableName] x
|
||||
@@ -65,3 +70,18 @@ other.go:
|
||||
# 15| 2: [IntLit] 0
|
||||
# 15| Type = int
|
||||
# 15| Value = [IntLit] 0
|
||||
# 17| 3: [TypeDecl] type declaration
|
||||
# 17| 0: [TypeSpec] type declaration specifier
|
||||
# 17| 0: [Ident, TypeName] myType
|
||||
# 17| Type = myType
|
||||
# 17| 1: [ArrayTypeExpr] array type
|
||||
# 17| Type = []T
|
||||
# 17| 0: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
# 17| 2: [TypeParamDecl] type parameter declaration
|
||||
# 17| 0: [TypeSetLiteralExpr] type set literal
|
||||
# 17| Type = ~string
|
||||
# 17| 0: [Ident, TypeName] string
|
||||
# 17| Type = string
|
||||
# 17| 1: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
|
||||
@@ -41,6 +41,11 @@ other.go:
|
||||
# 11| Type = int
|
||||
# 11| 0: [Ident, VariableName] myNested
|
||||
# 11| Type = func() int
|
||||
# 8| 3: [TypeParamDecl] type parameter declaration
|
||||
# 8| 0: [Ident, TypeName] int
|
||||
# 8| Type = int
|
||||
# 8| 1: [Ident, TypeName] U
|
||||
# 8| Type = U
|
||||
# 15| 5: [VarDecl] variable declaration
|
||||
# 15| 0: [ValueSpec] value declaration specifier
|
||||
# 15| 0: [Ident, VariableName] x
|
||||
@@ -50,3 +55,32 @@ other.go:
|
||||
# 15| 2: [IntLit] 0
|
||||
# 15| Type = int
|
||||
# 15| Value = [IntLit] 0
|
||||
# 17| 6: [TypeDecl] type declaration
|
||||
# 17| 0: [TypeSpec] type declaration specifier
|
||||
# 17| 0: [Ident, TypeName] myType
|
||||
# 17| Type = myType
|
||||
# 17| 1: [ArrayTypeExpr] array type
|
||||
# 17| Type = []T
|
||||
# 17| 0: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
# 17| 2: [TypeParamDecl] type parameter declaration
|
||||
# 17| 0: [TypeSetLiteralExpr] type set literal
|
||||
# 17| Type = ~string
|
||||
# 17| 0: [Ident, TypeName] string
|
||||
# 17| Type = string
|
||||
# 17| 1: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
# 19| 7: [MethodDecl] function declaration
|
||||
# 19| 0: [FunctionName, Ident] f
|
||||
# 19| Type = func()
|
||||
# 19| 1: [FuncTypeExpr] function type
|
||||
# 19| 2: [ReceiverDecl] receiver declaration
|
||||
# 19| 0: [GenericTypeInstantiationExpr] generic type instantiation expression
|
||||
# 19| Type = myType
|
||||
# 19| 0: [Ident, TypeName] myType
|
||||
# 19| Type = myType
|
||||
# 19| 1: [Ident, TypeName] U
|
||||
# 19| Type = U
|
||||
# 19| 1: [Ident, VariableName] m
|
||||
# 19| Type = myType
|
||||
# 19| 3: [BlockStmt] block statement
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
other.go:
|
||||
# 8| [TypeParamDecl] type parameter declaration
|
||||
# 8| 0: [Ident, TypeName] int
|
||||
# 8| Type = int
|
||||
# 8| 1: [Ident, TypeName] U
|
||||
# 8| Type = U
|
||||
go.mod:
|
||||
# 0| [GoModFile] go.mod
|
||||
# 1| 0: [GoModModuleLine] go.mod module line
|
||||
@@ -45,3 +51,18 @@ other.go:
|
||||
# 15| 2: [IntLit] 0
|
||||
# 15| Type = int
|
||||
# 15| Value = [IntLit] 0
|
||||
# 17| 3: [TypeDecl] type declaration
|
||||
# 17| 0: [TypeSpec] type declaration specifier
|
||||
# 17| 0: [Ident, TypeName] myType
|
||||
# 17| Type = myType
|
||||
# 17| 1: [ArrayTypeExpr] array type
|
||||
# 17| Type = []T
|
||||
# 17| 0: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
# 17| 2: [TypeParamDecl] type parameter declaration
|
||||
# 17| 0: [TypeSetLiteralExpr] type set literal
|
||||
# 17| Type = ~string
|
||||
# 17| 0: [Ident, TypeName] string
|
||||
# 17| Type = string
|
||||
# 17| 1: [Ident, TypeName] T
|
||||
# 17| Type = T
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
module codeql-go-tests/printast
|
||||
|
||||
go 1.14
|
||||
|
||||
go 1.18
|
||||
|
||||
@@ -5,7 +5,7 @@ func main() {}
|
||||
func f() {}
|
||||
func g() {}
|
||||
|
||||
func hasNested() {
|
||||
func hasNested[U int]() {
|
||||
|
||||
myNested := func() int { return 1 }
|
||||
myNested()
|
||||
@@ -13,3 +13,7 @@ func hasNested() {
|
||||
}
|
||||
|
||||
var x int = 0
|
||||
|
||||
type myType[T ~string] []T
|
||||
|
||||
func (m myType[U]) f() {}
|
||||
|
||||
Reference in New Issue
Block a user