MCPcopy Index your code
hub / github.com/google/go-github / addSimpleValueIdent

Method addSimpleValueIdent

github/gen-accessors.go:315–345  ·  view source on GitHub ↗
(x *ast.Ident, receiverType, fieldName string)

Source from the content-addressed store, hash-verified

313}
314
315func (t *templateData) addSimpleValueIdent(x *ast.Ident, receiverType, fieldName string) {
316 getter := genIdentGetter(x, receiverType, fieldName)
317 getter.IsSimpleValue = true
318 logf("addSimpleValueIdent: Processing %q - fieldName=%q, getter.ZeroValue=%q, x.Obj=%#v", x.String(), fieldName, getter.ZeroValue, x.Obj)
319 if getter.ZeroValue == "nil" {
320 if x.Obj == nil {
321 switch x.String() {
322 case "any": // NOOP - leave as `nil`
323 default:
324 getter.ZeroValue = x.String() + "{}"
325 }
326 } else {
327 if ts, ok := x.Obj.Decl.(*ast.TypeSpec); ok {
328 logf("addSimpleValueIdent: Processing %q of type %T", x.String(), ts.Type)
329 switch xX := ts.Type.(type) {
330 case *ast.Ident:
331 logf("addSimpleValueIdent: Processing %q of type %T - zero value is %q", x.String(), ts.Type, getter.ZeroValue)
332 getter.ZeroValue = zeroValueOfIdent(xX)
333 case *ast.StructType:
334 getter.ZeroValue = x.String() + "{}"
335 logf("addSimpleValueIdent: Processing %q of type %T - zero value is %q", x.String(), ts.Type, getter.ZeroValue)
336 case *ast.InterfaceType, *ast.ArrayType: // NOOP - leave as `nil`
337 logf("addSimpleValueIdent: Processing %q of type %T - zero value is %q", x.String(), ts.Type, getter.ZeroValue)
338 default:
339 log.Fatalf("addSimpleValueIdent: unhandled case %T", xX)
340 }
341 }
342 }
343 }
344 t.Getters = append(t.Getters, getter)
345}
346
347func (t *templateData) addIdent(x *ast.Ident, receiverType, fieldName string) {
348 getter := genIdentGetter(x, receiverType, fieldName)

Callers 1

processASTMethod · 0.95

Calls 4

genIdentGetterFunction · 0.85
zeroValueOfIdentFunction · 0.85
logfFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected