service/dap: make interface variable to dap.Variable conversion more readable (#2184)
* Add underlying type when printing interface type * Add todo to remove one level from interface printing Co-authored-by: Polina Sokolova <polinasok@users.noreply.github.com>
This commit is contained in:
parent
1c4c1fd7fd
commit
551c541737
@ -962,7 +962,21 @@ func (s *Server) convertVariable(v *proc.Variable) (value string, variablesRefer
|
|||||||
} else if len(v.Children) == 0 || v.Children[0].Kind == reflect.Invalid && v.Children[0].Addr == 0 {
|
} else if len(v.Children) == 0 || v.Children[0].Kind == reflect.Invalid && v.Children[0].Addr == 0 {
|
||||||
value = "nil <" + typeName + ">"
|
value = "nil <" + typeName + ">"
|
||||||
} else {
|
} else {
|
||||||
value = "<" + typeName + ">"
|
value = "<" + typeName + "(" + v.Children[0].TypeString() + ")" + ">"
|
||||||
|
// TODO(polina): should we remove one level of indirection and skip "data"?
|
||||||
|
// Then we will have:
|
||||||
|
// Before:
|
||||||
|
// i: <interface{}(int)>
|
||||||
|
// data: 123
|
||||||
|
// After:
|
||||||
|
// i: <interface{}(int)> 123
|
||||||
|
// Before:
|
||||||
|
// i: <interface{}(main.MyStruct)>
|
||||||
|
// data: <main.MyStruct>
|
||||||
|
// field1: ...
|
||||||
|
// After:
|
||||||
|
// i: <interface{}(main.MyStruct)>
|
||||||
|
// field1: ...
|
||||||
variablesReference = s.variableHandles.create(v)
|
variablesReference = s.variableHandles.create(v)
|
||||||
}
|
}
|
||||||
case reflect.Complex64, reflect.Complex128:
|
case reflect.Complex64, reflect.Complex128:
|
||||||
|
@ -909,14 +909,14 @@ func TestScopesAndVariablesRequests2(t *testing.T) {
|
|||||||
expectVarExact(t, locals, -1, "fn2", "<main.functype>", noChildren)
|
expectVarExact(t, locals, -1, "fn2", "<main.functype>", noChildren)
|
||||||
// reflect.Kind == Interface
|
// reflect.Kind == Interface
|
||||||
expectVarExact(t, locals, -1, "ifacenil", "nil <interface {}>", noChildren)
|
expectVarExact(t, locals, -1, "ifacenil", "nil <interface {}>", noChildren)
|
||||||
ref = expectVarExact(t, locals, -1, "iface2", "<interface {}>", hasChildren)
|
ref = expectVarExact(t, locals, -1, "iface2", "<interface {}(string)>", hasChildren)
|
||||||
if ref > 0 {
|
if ref > 0 {
|
||||||
client.VariablesRequest(ref)
|
client.VariablesRequest(ref)
|
||||||
iface2 := client.ExpectVariablesResponse(t)
|
iface2 := client.ExpectVariablesResponse(t)
|
||||||
expectChildren(t, iface2, "iface2", 1)
|
expectChildren(t, iface2, "iface2", 1)
|
||||||
expectVarExact(t, iface2, 0, "data", `"test"`, noChildren)
|
expectVarExact(t, iface2, 0, "data", `"test"`, noChildren)
|
||||||
}
|
}
|
||||||
ref = expectVarExact(t, locals, -1, "iface4", "<interface {}>", hasChildren)
|
ref = expectVarExact(t, locals, -1, "iface4", "<interface {}([]go/constant.Value)>", hasChildren)
|
||||||
if ref > 0 {
|
if ref > 0 {
|
||||||
client.VariablesRequest(ref)
|
client.VariablesRequest(ref)
|
||||||
iface4 := client.ExpectVariablesResponse(t)
|
iface4 := client.ExpectVariablesResponse(t)
|
||||||
@ -926,10 +926,12 @@ func TestScopesAndVariablesRequests2(t *testing.T) {
|
|||||||
client.VariablesRequest(ref)
|
client.VariablesRequest(ref)
|
||||||
iface4data := client.ExpectVariablesResponse(t)
|
iface4data := client.ExpectVariablesResponse(t)
|
||||||
expectChildren(t, iface4data, "iface4.data", 1)
|
expectChildren(t, iface4data, "iface4.data", 1)
|
||||||
expectVarExact(t, iface4data, 0, "[0]", "<go/constant.Value>", hasChildren)
|
expectVarExact(t, iface4data, 0, "[0]", "<go/constant.Value(go/constant.int64Val)>", hasChildren)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
expectVarExact(t, locals, -1, "errnil", "nil <error>", noChildren)
|
||||||
|
expectVarExact(t, locals, -1, "err1", "<error(*main.astruct)>", hasChildren)
|
||||||
// reflect.Kind == Map
|
// reflect.Kind == Map
|
||||||
expectVarExact(t, locals, -1, "mnil", "nil <map[string]main.astruct>", noChildren)
|
expectVarExact(t, locals, -1, "mnil", "nil <map[string]main.astruct>", noChildren)
|
||||||
ref = expectVarExact(t, locals, -1, "m2", "<map[int]*main.astruct> (length: 1)", hasChildren)
|
ref = expectVarExact(t, locals, -1, "m2", "<map[int]*main.astruct> (length: 1)", hasChildren)
|
||||||
|
Loading…
Reference in New Issue
Block a user