This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] MI: Add new command -complete
- From: Tom Tromey <tom at tromey dot com>
- To: Jan Vrany <jan dot vrany at fit dot cvut dot cz>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 17 Jan 2019 13:29:49 -0700
- Subject: Re: [PATCH] MI: Add new command -complete
- References: <20190103222930.4365-1-jan.vrany@fit.cvut.cz>
>>>>> "Jan" == Jan Vrany <jan.vrany@fit.cvut.cz> writes:
Jan> This commit adds a new '-complete' MI command which is implemented using
Jan> CLI's 'complete'.
I suspect it would be better to just write a new MI function and then
mildly refactor complete_command so that the two commands can share most
of their implementation.
First, this would make it so we could add options to the MI command as
needed. (Perhaps the current argument to the command ought to have a
flag to avoid future parsing problems? I am not sure.)
Second, it would mean that we could make changes to the CLI command
without worrying about breaking MI compatibility.
What do you think of this?
I looked and I see that some other MI commands are implemented directly
by CLI commands. I am not sure but I suspect this might be a deprecated
approach.
Jan> + bool is_mi_like = uiout->is_mi_like_p ();
This could be removed by having a more explicit API.
Jan> + ui_out_emit_list completions_emitter (uiout, "completions");
Jan> + if (result.number_matches != 0)
Jan> + {
Jan> + if (result.number_matches == 1)
Jan> + {
Jan> + if (is_mi_like)
Jan> + uiout->field_fmt(NULL, "%s%s", arg_prefix.c_str (),
Jan> + result.match_list[0]);
Jan> + else
Jan> + printf_unfiltered ("%s%s\n", arg_prefix.c_str (),
Jan> + result.match_list[0]);
Space before "(" in the field_fmt call. Unifying the cases would be
preferable. Or another argument for separation.
thanks,
Tom