MCPcopy Create free account
hub / github.com/despiteallobjections/amigo / SelectionString

Function SelectionString

types/selection.go:122–146  ·  view source on GitHub ↗

SelectionString returns the string form of s. The Qualifier controls the printing of package-level objects, and may be nil. Examples: "field (T) f int" "method (T) f(X) Y" "method expr (T) f(X) Y"

(s *Selection, qf Qualifier)

Source from the content-addressed store, hash-verified

120// "method expr (T) f(X) Y"
121//
122func SelectionString(s *Selection, qf Qualifier) string {
123 var k string
124 switch s.kind {
125 case FieldVal:
126 k = "field "
127 case MethodVal:
128 k = "method "
129 case MethodExpr:
130 k = "method expr "
131 default:
132 unreachable()
133 }
134 var buf bytes.Buffer
135 buf.WriteString(k)
136 buf.WriteByte('(')
137 WriteType(&buf, s.Recv(), qf)
138 fmt.Fprintf(&buf, ") %s", s.obj.Name())
139 if T := s.Type(); s.kind == FieldVal {
140 buf.WriteByte(' ')
141 WriteType(&buf, T, qf)
142 } else {
143 WriteSignature(&buf, T.(*Signature), qf)
144 }
145 return buf.String()
146}

Callers 1

StringMethod · 0.85

Calls 7

StringMethod · 0.95
unreachableFunction · 0.85
WriteTypeFunction · 0.85
WriteSignatureFunction · 0.85
NameMethod · 0.65
TypeMethod · 0.65
RecvMethod · 0.45

Tested by

no test coverage detected