未验证 提交 b72bce30 编写于 作者: S Suzy Mueller 提交者: GitHub

service/dap: support evaluate for hover context (#2496)

We can support evaluate for hover context in order to provide more
useful hover info for our users.

Updates go-delve/delve#2491
Updates golang/vscode-go#1510
上级 83fe7791
......@@ -102,6 +102,7 @@ func (c *Client) ExpectInitializeResponseAndCapabilities(t *testing.T) *dap.Init
SupportTerminateDebuggee: true,
SupportsExceptionInfoRequest: true,
SupportsFunctionBreakpoints: true,
SupportsEvaluateForHovers: true,
}
if !reflect.DeepEqual(initResp.Body, wantCapabilities) {
t.Errorf("capabilities in initializeResponse: got %+v, want %v", pretty(initResp.Body), pretty(wantCapabilities))
......
......@@ -677,6 +677,7 @@ func (s *Server) onInitializeRequest(request *dap.InitializeRequest) {
response.Body.SupportTerminateDebuggee = true
response.Body.SupportsFunctionBreakpoints = true
response.Body.SupportsExceptionInfoRequest = true
response.Body.SupportsEvaluateForHovers = true
// TODO(polina): support this to match vscode-go functionality
response.Body.SupportsSetVariable = false
// TODO(polina): support these requests in addition to vscode-go feature parity
......@@ -1755,7 +1756,7 @@ func (s *Server) convertVariableWithOpts(v *proc.Variable, qualifiedNameOrExpr s
// variables, so consider also adding the following:
// -- print {expression} - return the result as a string like from dlv cli
func (s *Server) onEvaluateRequest(request *dap.EvaluateRequest) {
showErrorToUser := request.Arguments.Context != "watch" && request.Arguments.Context != "repl"
showErrorToUser := request.Arguments.Context != "watch" && request.Arguments.Context != "repl" && request.Arguments.Context != "hover"
if s.debugger == nil {
s.sendErrorResponseWithOpts(request.Request, UnableToEvaluateExpression, "Unable to evaluate expression", "debugger is nil", showErrorToUser)
return
......
......@@ -2560,6 +2560,16 @@ func TestEvaluateRequest(t *testing.T) {
if erres.Body.Error.Format != "Unable to evaluate expression: could not find symbol value for a1" {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: could not find symbol value for a1\"", erres)
}
client.EvaluateRequest("a1", 1002, "repl")
erres = client.ExpectInvisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: could not find symbol value for a1" {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: could not find symbol value for a1\"", erres)
}
client.EvaluateRequest("a1", 1002, "hover")
erres = client.ExpectInvisibleErrorResponse(t)
if erres.Body.Error.Format != "Unable to evaluate expression: could not find symbol value for a1" {
t.Errorf("\ngot %#v\nwant Format=\"Unable to evaluate expression: could not find symbol value for a1\"", erres)
}
},
disconnect: false,
}})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册