[Lldb-commits] [lldb] [lldb-dap] Correct auto-completion based on ReplMode and escape char (PR #110784)

via lldb-commits lldb-commits at lists.llvm.org
Tue Oct 1 19:45:59 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r 915df1ae41652e2f595ce741dcd8f01878ef4e30...41694e6e64b3f16cc5b8e4b64c89d27f4e076573 lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- test/API/tools/lldb-dap/completions/TestDAP_completions.py	2024-10-02 02:41:21.000000 +0000
+++ test/API/tools/lldb-dap/completions/TestDAP_completions.py	2024-10-02 02:45:30.605434 +0000
@@ -17,17 +17,20 @@
     "text": "settings",
     "label": "settings -- Commands for managing LLDB settings.",
 }
 memory_completion = {
     "text": "memory",
-    "label": "memory -- Commands for operating on memory in the current target process."
+    "label": "memory -- Commands for operating on memory in the current target process.",
 }
 command_var_completion = {
     "text": "var",
     "label": "var -- Show variables for the current stack frame. Defaults to all arguments and local variables in scope. Names of argument, local, file static and file global variables can be specified.",
 }
-variable_var_completion = { "text": "var", "label": "var -- vector<baz> &", }
+variable_var_completion = {
+    "text": "var",
+    "label": "var -- vector<baz> &",
+}
 variable_var1_completion = {"text": "var1", "label": "var1 -- int &"}
 variable_var2_completion = {"text": "var2", "label": "var2 -- int &"}
 
 class TestDAP_completions(lldbdap_testcase.DAPTestCaseBase):
     def verify_completions(self, actual_list, expected_list, not_expected_list=[]):
@@ -46,59 +49,58 @@
         breakpoint1_line = line_number(source, "// breakpoint 1")
         breakpoint2_line = line_number(source, "// breakpoint 2")
 
         self.set_source_breakpoints(source, [breakpoint1_line, breakpoint2_line])
 
-
     def test_command_completions(self):
         """
         Tests completion requests for lldb commands, within "repl-mode=command"
         """
         self.setup_debugee()
         self.continue_to_next_stop()
 
-        res = self.dap_server.request_evaluate("`lldb-dap repl-mode command", context="repl")
+        res = self.dap_server.request_evaluate(
+            "`lldb-dap repl-mode command", context="repl"
+        )
         self.assertTrue(res["success"])
 
         # Provides completion for top-level commands
         self.verify_completions(
             self.dap_server.get_completions("se"),
-            [session_completion, settings_completion]
+            [session_completion, settings_completion],
         )
 
         # Provides completions for sub-commands
         self.verify_completions(
             self.dap_server.get_completions("memory "),
             [
                 {
                     "text": "read",
-                    "label": "read -- Read from the memory of the current target process."
+                    "label": "read -- Read from the memory of the current target process.",
                 },
                 {
                     "text": "region",
                     "label": "region -- Get information on the memory region containing an address in the current target process.",
                 },
-            ]
+            ],
         )
 
         # Provides completions for parameter values of commands
         self.verify_completions(
             self.dap_server.get_completions("`log enable  "),
             [{"text": "gdb-remote", "label": "gdb-remote"}],
         )
 
         # Also works if the escape prefix is used
         self.verify_completions(
-            self.dap_server.get_completions("`mem"),
-            [memory_completion]
+            self.dap_server.get_completions("`mem"), [memory_completion]
         )
 
         self.verify_completions(
             self.dap_server.get_completions("`"),
-            [session_completion, settings_completion, memory_completion]
-        )
-
+            [session_completion, settings_completion, memory_completion],
+        )
 
         # Completes an incomplete quoted token
         self.verify_completions(
             self.dap_server.get_completions('setting "se'),
             [
@@ -126,19 +128,20 @@
             self.dap_server.get_completions("var"),
             [command_var_completion],
             [variable_var_completion],
         )
 
-
     def test_variable_completions(self):
         """
         Tests completion requests in "repl-mode=command"
         """
         self.setup_debugee()
         self.continue_to_next_stop()
 
-        res = self.dap_server.request_evaluate("`lldb-dap repl-mode variable", context="repl")
+        res = self.dap_server.request_evaluate(
+            "`lldb-dap repl-mode variable", context="repl"
+        )
         self.assertTrue(res["success"])
 
         # Provides completions for varibles, but not command
         self.verify_completions(
             self.dap_server.get_completions("var"),
@@ -220,41 +223,44 @@
             [{"text": "var2", "label": "var2 -- int"}],
         )
 
         # Even in variable mode, we can still use the escape prefix
         self.verify_completions(
-            self.dap_server.get_completions("`mem"),
-            [memory_completion]
+            self.dap_server.get_completions("`mem"), [memory_completion]
         )
 
     def test_auto_completions(self):
         """
         Tests completion requests in "repl-mode=auto"
         """
         self.setup_debugee()
 
-        res = self.dap_server.request_evaluate("`lldb-dap repl-mode auto", context="repl")
+        res = self.dap_server.request_evaluate(
+            "`lldb-dap repl-mode auto", context="repl"
+        )
         self.assertTrue(res["success"])
 
         self.continue_to_next_stop()
         self.continue_to_next_stop()
 
         # We are stopped inside `main`. Variables `var1` and `var2` are in scope.
         # Make sure, we offer all completions
         self.verify_completions(
             self.dap_server.get_completions("va"),
-            [ 
-              command_var_completion,
-              variable_var1_completion,
-              variable_var2_completion,
+            [
+                command_var_completion,
+                variable_var1_completion,
+                variable_var2_completion,
             ],
         )
 
         # If we are using the escape prefix, only commands are suggested, but no variables
         self.verify_completions(
             self.dap_server.get_completions("`va"),
-            [ command_var_completion, ],
-            [
-              variable_var1_completion,
-              variable_var2_completion,
-            ],
-        )
+            [
+                command_var_completion,
+            ],
+            [
+                variable_var1_completion,
+                variable_var2_completion,
+            ],
+        )

``````````

</details>


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


More information about the lldb-commits mailing list