Source file src/go/ast/ast_typeparams.go
Documentation: go/ast
1 // Copyright 2021 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build typeparams 6 // +build typeparams 7 8 package ast 9 10 import "go/token" 11 12 type ( 13 // A FuncType node represents a function type. 14 FuncType struct { 15 Func token.Pos // position of "func" keyword (token.NoPos if there is no "func") 16 TParams *FieldList // type parameters; or nil 17 Params *FieldList // (incoming) parameters; non-nil 18 Results *FieldList // (outgoing) results; or nil 19 } 20 21 // A TypeSpec node represents a type declaration (TypeSpec production). 22 TypeSpec struct { 23 Doc *CommentGroup // associated documentation; or nil 24 Name *Ident // type name 25 TParams *FieldList // type parameters; or nil 26 Assign token.Pos // position of '=', if any 27 Type Expr // *Ident, *ParenExpr, *SelectorExpr, *StarExpr, or any of the *XxxTypes 28 Comment *CommentGroup // line comments; or nil 29 } 30 31 // A ListExpr node represents a list of expressions separated by commas. 32 // ListExpr nodes are used as index in IndexExpr nodes representing type 33 // or function instantiations with more than one type argument. 34 ListExpr struct { 35 ElemList []Expr 36 } 37 ) 38 39 func (*ListExpr) exprNode() {} 40 func (x *ListExpr) Pos() token.Pos { 41 if len(x.ElemList) > 0 { 42 return x.ElemList[0].Pos() 43 } 44 return token.NoPos 45 } 46 func (x *ListExpr) End() token.Pos { 47 if len(x.ElemList) > 0 { 48 return x.ElemList[len(x.ElemList)-1].End() 49 } 50 return token.NoPos 51 } 52