diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:36:23 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:46:02 -0500 |
commit | c583a2520616c2736cffc389c89a48b159366e6c (patch) | |
tree | b4925f26506fcee96c16119431c01760f05db95d /gdb/completer.h | |
parent | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff) | |
download | binutils-users/simark/clang-format.zip binutils-users/simark/clang-format.tar.gz binutils-users/simark/clang-format.tar.bz2 |
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdb/completer.h')
-rw-r--r-- | gdb/completer.h | 136 |
1 files changed, 70 insertions, 66 deletions
diff --git a/gdb/completer.h b/gdb/completer.h index 8b4ad8e..de41381 100644 --- a/gdb/completer.h +++ b/gdb/completer.h @@ -14,7 +14,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#if !defined (COMPLETER_H) +#if !defined(COMPLETER_H) #define COMPLETER_H 1 #include "gdbsupport/gdb-hashtab.h" @@ -80,21 +80,19 @@ typedef std::vector<gdb::unique_xmalloc_ptr<char>> completion_list; class completion_match { public: + /* Get the completion match result. See m_match/m_storage's descriptions. */ - const char *match () - { return m_match; } + const char *match () { return m_match; } /* Set the completion match result. See m_match/m_storage's descriptions. */ - void set_match (const char *match) - { m_match = match; } + void set_match (const char *match) { m_match = match; } /* Get temporary storage for generating a match result, dynamically. The built string is only good until the next clear() call. I.e., good until the next symbol comparison. */ - std::string &storage () - { return m_storage; } + std::string &storage () { return m_storage; } /* Prepare for another completion matching sequence. */ void clear () @@ -104,6 +102,7 @@ public: } private: + /* The completion match result. This can either be a pointer into M_STORAGE string, or it can be a pointer into the some other string that outlives the completion matching sequence (usually, a @@ -135,17 +134,18 @@ private: class completion_match_for_lcd { public: + /* Get the resulting LCD, after a successful match. */ - const char *match () - { return m_match; } + const char *match () { return m_match; } /* Set the match for LCD. See m_match's description. */ - void set_match (const char *match) - { m_match = match; } + void set_match (const char *match) { m_match = match; } /* Mark the range between [BEGIN, END) as ignored. */ void mark_ignored_range (const char *begin, const char *end) - { m_ignored_ranges.emplace_back (begin, end); } + { + m_ignored_ranges.emplace_back (begin, end); + } /* Get the resulting LCD, after a successful match. If there are ignored ranges, then this builds a new string with the ignored @@ -180,6 +180,7 @@ public: } private: + /* The completion match result for LCD. This is usually either a pointer into to a substring within a symbol's name, or to the storage of the pairing completion_match object. */ @@ -252,10 +253,12 @@ struct completion_result void sort_match_list (); private: + /* Destroy the match list array and its contents. */ void reset_match_list (); public: + /* (There's no point in making these fields private, since the whole point of this wrapper is to build data in the layout expected by readline. Making them private would require adding getters for @@ -311,6 +314,7 @@ public: class completion_tracker { public: + completion_tracker (); ~completion_tracker (); @@ -334,8 +338,7 @@ public: /* Set the quote char to be appended after a unique completion is added to the input line. Set to '\0' to clear. See m_quote_char's description. */ - void set_quote_char (int quote_char) - { m_quote_char = quote_char; } + void set_quote_char (int quote_char) { m_quote_char = quote_char; } /* The quote char to be appended after a unique completion is added to the input line. Returns '\0' if no quote char has been set. @@ -347,32 +350,32 @@ public: handle_brkchars phase. Such completers must also compute their completions then. */ void set_use_custom_word_point (bool enable) - { m_use_custom_word_point = enable; } + { + m_use_custom_word_point = enable; + } /* Whether the current completer computes a custom word point. */ - bool use_custom_word_point () const - { return m_use_custom_word_point; } + bool use_custom_word_point () const { return m_use_custom_word_point; } /* The custom word point. */ - int custom_word_point () const - { return m_custom_word_point; } + int custom_word_point () const { return m_custom_word_point; } /* Set the custom word point to POINT. */ - void set_custom_word_point (int point) - { m_custom_word_point = point; } + void set_custom_word_point (int point) { m_custom_word_point = point; } /* Advance the custom word point by LEN. */ void advance_custom_word_point_by (int len); /* Whether to tell readline to skip appending a whitespace after the completion. See m_suppress_append_ws. */ - bool suppress_append_ws () const - { return m_suppress_append_ws; } + bool suppress_append_ws () const { return m_suppress_append_ws; } /* Set whether to tell readline to skip appending a whitespace after the completion. See m_suppress_append_ws. */ void set_suppress_append_ws (bool suppress) - { m_suppress_append_ws = suppress; } + { + m_suppress_append_ws = suppress; + } /* Return true if we only have one completion, and it matches exactly the completion word. I.e., completing results in what we @@ -394,7 +397,9 @@ public: /* True if we have any completion match recorded. */ bool have_completions () const - { return htab_elements (m_entries_hash.get ()) > 0; } + { + return htab_elements (m_entries_hash.get ()) > 0; + } /* Discard the current completion match list and the current LCD. */ @@ -403,8 +408,8 @@ public: /* Build a completion_result containing the list of completion matches to hand over to readline. The parameters are as in rl_attempted_completion_function. */ - completion_result build_completion_result (const char *text, - int start, int end); + completion_result build_completion_result (const char *text, int start, + int end); private: @@ -502,32 +507,30 @@ private: TEXT/WORD. For a description of TEXT/WORD see completer_ftype. */ extern gdb::unique_xmalloc_ptr<char> - make_completion_match_str (const char *match_name, - const char *text, const char *word); +make_completion_match_str (const char *match_name, const char *text, + const char *word); /* Like above, but takes ownership of MATCH_NAME (i.e., can reuse/return it). */ extern gdb::unique_xmalloc_ptr<char> - make_completion_match_str (gdb::unique_xmalloc_ptr<char> &&match_name, - const char *text, const char *word); +make_completion_match_str (gdb::unique_xmalloc_ptr<char> &&match_name, + const char *text, const char *word); extern void gdb_display_match_list (char **matches, int len, int max, const struct match_list_displayer *); extern const char *get_max_completions_reached_message (void); -extern void complete_line (completion_tracker &tracker, - const char *text, - const char *line_buffer, - int point); +extern void complete_line (completion_tracker &tracker, const char *text, + const char *line_buffer, int point); /* Complete LINE and return completion results. For completion purposes, cursor position is assumed to be at the end of LINE. WORD is set to the end of word to complete. QUOTE_CHAR is set to the opening quote character if we found an unclosed quoted substring, '\0' otherwise. */ -extern completion_result - complete (const char *line, char const **word, int *quote_char); +extern completion_result complete (const char *line, char const **word, + int *quote_char); /* Find the bounds of the word in TEXT for completion purposes, and return a pointer to the end of the word. Calls the completion @@ -535,62 +538,63 @@ extern completion_result the right work break characters for the command in TEXT. QUOTE_CHAR, if non-null, is set to the opening quote character if we found an unclosed quoted substring, '\0' otherwise. */ -extern const char *completion_find_completion_word (completion_tracker &tracker, - const char *text, - int *quote_char); - +extern const char * +completion_find_completion_word (completion_tracker &tracker, const char *text, + int *quote_char); /* Assuming TEXT is an expression in the current language, find the completion word point for TEXT, emulating the algorithm readline uses to find the word point, using the current language's word break characters. */ -const char *advance_to_expression_complete_word_point - (completion_tracker &tracker, const char *text); +const char * +advance_to_expression_complete_word_point (completion_tracker &tracker, + const char *text); /* Assuming TEXT is an filename, find the completion word point for TEXT, emulating the algorithm readline uses to find the word point. */ -extern const char *advance_to_filename_complete_word_point - (completion_tracker &tracker, const char *text); +extern const char * +advance_to_filename_complete_word_point (completion_tracker &tracker, + const char *text); extern char **gdb_rl_attempted_completion_function (const char *text, int start, int end); extern void noop_completer (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *); + completion_tracker &tracker, const char *, + const char *); extern void filename_completer (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *); + completion_tracker &tracker, const char *, + const char *); extern void expression_completer (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *); + completion_tracker &tracker, const char *, + const char *); extern void location_completer (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *); + completion_tracker &tracker, const char *, + const char *); extern void symbol_completer (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *); + completion_tracker &tracker, const char *, + const char *); extern void command_completer (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *); + completion_tracker &tracker, const char *, + const char *); extern void signal_completer (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *); + completion_tracker &tracker, const char *, + const char *); extern void reg_or_group_completer (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *); + completion_tracker &tracker, const char *, + const char *); extern void reggroup_completer (struct cmd_list_element *, - completion_tracker &tracker, - const char *, const char *); + completion_tracker &tracker, const char *, + const char *); extern const char *get_gdb_completer_quote_characters (void); @@ -609,7 +613,7 @@ extern void set_rl_completer_word_break_characters (const char *break_chars); calculation is done (e.g., for Python functions). */ extern completer_handle_brkchars_ftype * - completer_handle_brkchars_func_for_completer (completer_ftype *fn); +completer_handle_brkchars_func_for_completer (completer_ftype *fn); /* Exported to linespec.c */ @@ -620,8 +624,8 @@ extern completion_list complete_source_filenames (const char *text); /* Complete on expressions. Often this means completing on symbol names, but some language parsers also have support for completing field names. */ -extern void complete_expression (completion_tracker &tracker, - const char *text, const char *word); +extern void complete_expression (completion_tracker &tracker, const char *text, + const char *word); /* Called by custom word point completers that want to recurse into the completion machinery to complete a command. Used to complete |