[Lldb-commits] [lldb] Add the ability to define custom completers to the parsed_cmd template. (PR #109062)

Med Ismail Bennani via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 19 16:50:48 PDT 2024


================
@@ -43,7 +43,65 @@ def __call__(self, debugger, args_list, exe_ctx, result):
 will return True if the user set this option, and False if it was left at its default
 value.
 
-There are example commands in the lldb testsuite at:
+Custom Completions:
+
+You can also implement custom completers for your custom command, either for the
+arguments to your command or to the option values in your command.  If you use enum
+values or if your option/argument uses is one of the types we have completers for,
+you should not need to do this.  But if you have your own completeable types, or if
+you want completion of one option to be conditioned by other options on the command
+line, you can use this interface to take over the completion.  
+
+You can choose to add a completion for the option values defined for your command,
+or for the arguments, separately.  For the option values, define:
+
+def handle_option_argument_completion(self, long_option, cursor_pos):
+
+The line to be completed will be parsed up to the option containint the cursor position, 
+and the values will be set in the OptionValue parser object.  long_option will be
+the option name containing the cursor, and cursor_pos will be the position of the cursor
+in that option's value.  You can call the OVParser.dest_for_option(long_option) to get the
+value for that option.  The other options that came before the cursor in the command
+line will also be set in the OV Parser when the completion handler is called.
----------------
medismailben wrote:

```suggestion
in that option's value.  You can call the `OVParser.dest_for_option(long_option)` to get the
value for that option.  The other options that came before the cursor in the command
line will also be set in the `OVParser` when the completion handler is called.
```

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


More information about the lldb-commits mailing list