This revision was automatically updated to reflect the committed changes.
Closed by commit rGdc8f0035ca99: [lldb-vscode] Add presentation hints for 
scopes (authored by werat).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113400/new/

https://reviews.llvm.org/D113400

Files:
  lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
  lldb/tools/lldb-vscode/JSONUtils.cpp


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===================================================================
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -175,6 +175,13 @@
 //       "type": "string",
 //       "description": "Name of the scope such as 'Arguments', 'Locals'."
 //     },
+//     "presentationHint": {
+//       "type": "string",
+//       "description": "An optional hint for how to present this scope in the
+//                       UI. If this attribute is missing, the scope is shown
+//                       with a generic UI.",
+//       "_enum": [ "arguments", "locals", "registers" ],
+//     },
 //     "variablesReference": {
 //       "type": "integer",
 //       "description": "The variables of this scope can be retrieved by
@@ -229,6 +236,15 @@
                               int64_t namedVariables, bool expensive) {
   llvm::json::Object object;
   EmplaceSafeString(object, "name", name.str());
+
+  // TODO: Support "arguments" scope. At the moment lldb-vscode includes the
+  // arguments into the "locals" scope.
+  if (variablesReference == VARREF_LOCALS) {
+    object.try_emplace("presentationHint", "locals");
+  } else if (variablesReference == VARREF_REGS) {
+    object.try_emplace("presentationHint", "registers");
+  }
+
   object.try_emplace("variablesReference", variablesReference);
   object.try_emplace("expensive", expensive);
   object.try_emplace("namedVariables", namedVariables);
Index: lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
===================================================================
--- lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -394,3 +394,17 @@
         self.verify_variables(
             expandable_expression["children"], response["body"]["variables"]
         )
+
+        # Test that frame scopes have corresponding presentation hints.
+        frame_id = self.vscode.get_stackFrame()["id"]
+        scopes = self.vscode.request_scopes(frame_id)["body"]["scopes"]
+
+        scope_names = [scope["name"] for scope in scopes]
+        self.assertIn("Locals", scope_names)
+        self.assertIn("Registers", scope_names)
+
+        for scope in scopes:
+            if scope["name"] == "Locals":
+                self.assertEquals(scope.get("presentationHint"), "locals")
+            if scope["name"] == "Registers":
+                self.assertEquals(scope.get("presentationHint"), "registers")


Index: lldb/tools/lldb-vscode/JSONUtils.cpp
===================================================================
--- lldb/tools/lldb-vscode/JSONUtils.cpp
+++ lldb/tools/lldb-vscode/JSONUtils.cpp
@@ -175,6 +175,13 @@
 //       "type": "string",
 //       "description": "Name of the scope such as 'Arguments', 'Locals'."
 //     },
+//     "presentationHint": {
+//       "type": "string",
+//       "description": "An optional hint for how to present this scope in the
+//                       UI. If this attribute is missing, the scope is shown
+//                       with a generic UI.",
+//       "_enum": [ "arguments", "locals", "registers" ],
+//     },
 //     "variablesReference": {
 //       "type": "integer",
 //       "description": "The variables of this scope can be retrieved by
@@ -229,6 +236,15 @@
                               int64_t namedVariables, bool expensive) {
   llvm::json::Object object;
   EmplaceSafeString(object, "name", name.str());
+
+  // TODO: Support "arguments" scope. At the moment lldb-vscode includes the
+  // arguments into the "locals" scope.
+  if (variablesReference == VARREF_LOCALS) {
+    object.try_emplace("presentationHint", "locals");
+  } else if (variablesReference == VARREF_REGS) {
+    object.try_emplace("presentationHint", "registers");
+  }
+
   object.try_emplace("variablesReference", variablesReference);
   object.try_emplace("expensive", expensive);
   object.try_emplace("namedVariables", namedVariables);
Index: lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
===================================================================
--- lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
+++ lldb/test/API/tools/lldb-vscode/variables/TestVSCode_variables.py
@@ -394,3 +394,17 @@
         self.verify_variables(
             expandable_expression["children"], response["body"]["variables"]
         )
+
+        # Test that frame scopes have corresponding presentation hints.
+        frame_id = self.vscode.get_stackFrame()["id"]
+        scopes = self.vscode.request_scopes(frame_id)["body"]["scopes"]
+
+        scope_names = [scope["name"] for scope in scopes]
+        self.assertIn("Locals", scope_names)
+        self.assertIn("Registers", scope_names)
+
+        for scope in scopes:
+            if scope["name"] == "Locals":
+                self.assertEquals(scope.get("presentationHint"), "locals")
+            if scope["name"] == "Registers":
+                self.assertEquals(scope.get("presentationHint"), "registers")
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to