package types
import (
)
func ( *token.FileSet, Qualifier, bool, string, ...any) string {
for , := range {
switch a := .(type) {
case nil:
= "<nil>"
case operand:
panic("got operand instead of *operand")
case *operand:
= operandString(, )
case token.Pos:
if != nil {
= .Position().String()
}
case ast.Expr:
= ExprString()
case []ast.Expr:
var bytes.Buffer
.WriteByte('[')
writeExprList(&, )
.WriteByte(']')
= .String()
case Object:
= ObjectString(, )
case Type:
var bytes.Buffer
:= newTypeWriter(&, )
.tpSubscripts =
.typ()
= .String()
case []Type:
var bytes.Buffer
:= newTypeWriter(&, )
.tpSubscripts =
.WriteByte('[')
for , := range {
if > 0 {
.WriteString(", ")
}
.typ()
}
.WriteByte(']')
= .String()
case []*TypeParam:
var bytes.Buffer
:= newTypeWriter(&, )
.tpSubscripts =
.WriteByte('[')
for , := range {
if > 0 {
.WriteString(", ")
}
.typ()
}
.WriteByte(']')
= .String()
}
[] =
}
return fmt.Sprintf(, ...)
}
func ( *Checker) ( string, ...any) string {
var *token.FileSet
var Qualifier
if != nil {
= .fset
= .qualifier
}
return sprintf(, , false, , ...)
}
func ( *Checker) ( token.Pos, string, ...any) {
fmt.Printf("%s:\t%s%s\n",
.fset.Position(),
strings.Repeat(". ", .indent),
sprintf(.fset, .qualifier, true, , ...),
)
}
func ( *Checker) ( string, ...any) {
fmt.Println(sprintf(.fset, .qualifier, true, , ...))
}
func ( *Checker) ( *Package) string {
if != .pkg {
if .pkgPathMap == nil {
.pkgPathMap = make(map[string]map[string]bool)
.seenPkgMap = make(map[*Package]bool)
.markImports(.pkg)
}
if len(.pkgPathMap[.name]) > 1 {
return strconv.Quote(.path)
}
return .name
}
return ""
}
func ( *Checker) ( *Package) {
if .seenPkgMap[] {
return
}
.seenPkgMap[] = true
, := .pkgPathMap[.name]
if ! {
= make(map[string]bool)
.pkgPathMap[.name] =
}
[.path] = true
for , := range .imports {
.()
}
}
func ( string) string {
var strings.Builder
for , := range {
if < '₀' || '₀'+10 <= {
.WriteRune()
}
}
if .Len() < len() {
return .String()
}
return
}