mirror of
https://github.com/go-delve/delve.git
synced 2025-11-02 21:40:22 +08:00
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
This commit is contained in:
@ -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,
|
||||
}})
|
||||
|
||||
Reference in New Issue
Block a user