This is an archive of the discontinued LLVM Phabricator instance.

[lldb/Commands] Add support to auto-completion for user commands
ClosedPublic

Authored by mib on Jun 2 2023, 10:35 AM.

Details

Summary

This patch should allow the user to set specific auto-completion type
for their custom commands.

To do so, we had to hoist the CompletionType enum so the user can
access it and add a new completion type flag to the CommandScriptAdd
Command Object.

So now, the user can specify which completion type will be used with
their custom command, when they register it.

This also makes the crashlog custom commands use disk-file completion
type, to browse through the user file system and load the report.

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>

Diff Detail

Event Timeline

mib created this revision.Jun 2 2023, 10:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 2 2023, 10:35 AM
mib requested review of this revision.Jun 2 2023, 10:35 AM

So the idea behind this is fine to me, allowing custom commands to specify a completion style seems like a very nifty feature to have.

We should definitely add a test though. An API test or a Shell test where we create a custom command and then try to do some kind of completion on it would be good.

lldb/include/lldb/Interpreter/CommandOptionArgumentTable.h
153–179

The nullptr argument for these is for the usage, yeah? We should probably add something... For example, eSourceFileCompletion could be something like "Completes to a source file" or something like this.

mib updated this revision to Diff 528069.Jun 2 2023, 8:05 PM
mib marked an inline comment as done.

Address @bulbazord comments:

  • Add test & usage descriptions
bulbazord accepted this revision.Jun 5 2023, 1:24 PM

Thanks for adding the test! Most of this change looks fairly mechanical so I think this is probably good to go.

This revision is now accepted and ready to land.Jun 5 2023, 1:24 PM
JDevlieghere added inline comments.Jun 5 2023, 6:17 PM
lldb/include/lldb/lldb-enumerations.h
1279

Should this be << 25?

mib marked an inline comment as done.Jun 6 2023, 10:25 AM
mib added inline comments.
lldb/include/lldb/lldb-enumerations.h
1279

I've just copied the enum as-is, but now that you mention it, I also think this should be << 25.

mib updated this revision to Diff 528928.Jun 6 2023, 10:25 AM
mib marked an inline comment as done.

Address @JDevlieghere comment

JDevlieghere accepted this revision.Jun 6 2023, 10:36 AM

LGTM. This is really cool.