================
@@ -0,0 +1,120 @@
+//===-- GoToTargetsRequestHandler.cpp
+//--------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "DAP.h"
+
+#include "JSONUtils.h"
+
+#include <lldb/API/SBStream.h>
+
+namespace lldb_dap {
+
+//  "GotoTargetsRequest": {
+//    "allOf": [ { "$ref": "#/definitions/Request" }, {
+//      "type": "object",
+//      "description": "This request retrieves the possible goto targets for 
the
+//      specified source location.\nThese targets can be used in the `goto`
+//      request.\nClients should only call this request if the corresponding
+//      capability `supportsGotoTargetsRequest` is true.", "properties": {
+//        "command": {
+//          "type": "string",
+//          "enum": [ "gotoTargets" ]
+//        },
+//        "arguments": {
+//          "$ref": "#/definitions/GotoTargetsArguments"
+//        }
+//      },
+//      "required": [ "command", "arguments"  ]
+//    }]
+//  },
+//  "GotoTargetsArguments": {
+//    "type": "object",
+//    "description": "Arguments for `gotoTargets` request.",
+//    "properties": {
+//      "source": {
+//        "$ref": "#/definitions/Source",
+//        "description": "The source location for which the goto targets are
+//        determined."
+//      },
+//      "line": {
+//        "type": "integer",
+//        "description": "The line location for which the goto targets are
+//        determined."
+//      },
+//      "column": {
+//        "type": "integer",
+//        "description": "The position within `line` for which the goto targets
+//        are determined. It is measured in UTF-16 code units and the client
+//        capability `columnsStartAt1` determines whether it is 0- or 1-based."
+//      }
+//    },
+//    "required": [ "source", "line" ]
+//  },
+//  "GotoTargetsResponse": {
+//    "allOf": [ { "$ref": "#/definitions/Response" }, {
+//      "type": "object",
+//      "description": "Response to `gotoTargets` request.",
+//      "properties": {
+//        "body": {
+//          "type": "object",
+//          "properties": {
+//            "targets": {
+//              "type": "array",
+//              "items": {
+//                "$ref": "#/definitions/GotoTarget"
+//              },
+//              "description": "The possible goto targets of the specified
+//              location."
+//            }
+//          },
+//          "required": [ "targets" ]
+//        }
+//      },
+//      "required": [ "body" ]
+//    }]
+//  },
+void GoToTargetsRequestHandler::operator()(
+    const llvm::json::Object &request) const {
+  llvm::json::Object response;
+  FillResponse(request, response);
+  const auto *arguments = request.getObject("arguments");
+  const auto *source = arguments->getObject("source");
+  const std::string path = GetString(source, "path").str();
+
+  const auto goto_line = GetInteger<uint64_t>(arguments, "line").value_or(0u);
+  const auto goto_column =
+      GetInteger<uint64_t>(arguments, "column").value_or(0u);
+
+  lldb::SBLineEntry line_entry{};
+  const lldb::SBFileSpec file_spec(path.c_str(), true);
+  line_entry.SetFileSpec(file_spec);
+  line_entry.SetLine(goto_line);
+  line_entry.SetColumn(goto_column);
----------------
vogelsgesang wrote:

Instead of simply forwarding the line + column as provided by the user, I think 
we should check where we can actually go-to.

E.g., if clicking on an empty line where we cannot continue, we might want to 
provide the two options "previous line" and "next line" to allow the user to 
specify more precisely where to go to. What are other debug adapters doing here?

https://github.com/llvm/llvm-project/pull/130503
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to