[Lldb-commits] [lldb] [lldb-dap] Migrating DAP 'initialize' to new typed RequestHandler. (PR #133007)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Mar 26 16:16:25 PDT 2025


================
@@ -23,6 +24,75 @@ bool fromJSON(const json::Value &Params, DisconnectArguments &DA,
          O.mapOptional("suspendDebuggee", DA.suspendDebuggee);
 }
 
+bool fromJSON(const llvm::json::Value &Params,
+              InitializeRequestArguments::PathFormat &PF, llvm::json::Path P) {
+  auto rawPathFormat = Params.getAsString();
+  if (!rawPathFormat) {
+    P.report("expected a string");
+    return false;
+  }
+
+  std::optional<InitializeRequestArguments::PathFormat> pathFormat =
+      StringSwitch<std::optional<InitializeRequestArguments::PathFormat>>(
+          *rawPathFormat)
+          .Case("path", InitializeRequestArguments::PathFormat::path)
+          .Case("uri", InitializeRequestArguments::PathFormat::uri)
+          .Default(std::nullopt);
+  if (!pathFormat) {
+    P.report("unexpected value, expected 'path' or 'uri'");
+    return false;
+  }
+
+  PF = *pathFormat;
+  return true;
+}
+
+bool fromJSON(const llvm::json::Value &Params, InitializeRequestArguments &IRA,
+              llvm::json::Path P) {
+  json::ObjectMapper OM(Params, P);
+  if (!OM)
+    return false;
+
+  const json::Object *O = Params.getAsObject();
+  if (std::optional<bool> v = O->getBoolean("supportsVariableType"); v && *v)
+    IRA.supportedFeatures.insert(ClientFeature::supportsVariableType);
----------------
JDevlieghere wrote:

This seems like an opportunity for a for-loop that iterates over a `std::pair<lllvm::StringLiteral, ClientFeature>`. 

https://github.com/llvm/llvm-project/pull/133007


More information about the lldb-commits mailing list