aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lang.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-11-29 19:33:23 +0000
committerPedro Alves <palves@redhat.com>2017-11-29 19:33:23 +0000
commita207cff2da9f154e4f581b19dcde215593bfccf9 (patch)
treea05eafa2c9349fb663f150aff45680aae9aa7cf0 /gdb/ada-lang.c
parent4024cf2b8d864279ff87af1a2ade77ab6d710d50 (diff)
downloadgdb-a207cff2da9f154e4f581b19dcde215593bfccf9.zip
gdb-a207cff2da9f154e4f581b19dcde215593bfccf9.tar.gz
gdb-a207cff2da9f154e4f581b19dcde215593bfccf9.tar.bz2
Handle custom completion match prefix / LCD
A following patch will add support for wild matching for C++ symbols, making completing on "b push_ba" on a C++ program complete to std::vector<...>::push_back, std::string::push_back etc., like: (gdb) b push_ba[TAB] std::vector<...>::push_back(....) std::string<...>::push_back(....) Currently, we compute the "lowest common denominator" between all completion candidates (what the input line is adjusted to) as the common prefix of all matches. That's problematic with wild matching as above, as then we'd end up with TAB changing the input line to "b std::", losing the original input, like: (gdb) b push_ba[TAB] std::vector<...>::push_back(....) std::string<...>::push_back(....) (gdb) b std:: while obviously we'd want it to adjust itself to "b push_back(" instead: (gdb) b push_ba[TAB] std::vector<...>::push_back(....) std::string<...>::push_back(....) (gdb) b push_back( This patch adds the core code necessary to support this, though nothing really makes use of it yet in this patch. gdb/ChangeLog: 2017-11-29 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_lookup_name_info::matches): Change type of parameter from completion_match to completion_match_result. Adjust. (do_wild_match, do_full_match, ada_symbol_name_matches): Likewise. * completer.c (completion_tracker::maybe_add_completion): Add match_for_lcd parameter and use it. (completion_tracker::add_completion): Likewise. * completer.h (class completion_match_for_lcd): New class. (completion_match_result::match_for_lcd): New field. (completion_match_result::set_match): New method. (completion_tracker): Add comments. (completion_tracker::add_completion): Add match_for_lcd parameter. (completion_tracker::reset_completion_match_result): Reset match_for_lcd too. (completion_tracker::maybe_add_completion): Add match_for_lcd parameter. (completion_tracker::m_lowest_common_denominator_unique): Extend comments. * cp-support.c (cp_symbol_name_matches_1) (cp_fq_symbol_name_matches): Change type of parameter from completion_match to completion_match_result. Adjust. * language.c (default_symbol_name_matcher): Change type of parameter from completion_match to completion_match_result. Adjust. * language.h (completion_match_for_lcd): Forward declare. (default_symbol_name_matcher): Change type of parameter from completion_match to completion_match_result. * symtab.c (compare_symbol_name): Adjust. (completion_list_add_name): Pass the match_for_lcd to the tracker. * symtab.h (ada_lookup_name_info::matches): Change type of parameter from completion_match to completion_match_result. (symbol_name_matcher_ftype): Likewise, and update comments.
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r--gdb/ada-lang.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3265c21..38d1ce6 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -6357,7 +6357,7 @@ bool
ada_lookup_name_info::matches
(const char *sym_name,
symbol_name_match_type match_type,
- completion_match *comp_match) const
+ completion_match_result *comp_match_res) const
{
bool match = false;
const char *text = m_encoded_name.c_str ();
@@ -6415,15 +6415,12 @@ ada_lookup_name_info::matches
if (!match)
return false;
- if (comp_match != NULL)
+ if (comp_match_res != NULL)
{
- std::string &match_str = comp_match->storage ();
+ std::string &match_str = comp_match_res->match.storage ();
if (!m_encoded_p)
- {
- match_str = ada_decode (sym_name);
- comp_match->set_match (match_str.c_str ());
- }
+ match_str = ada_decode (sym_name);
else
{
if (m_verbatim_p)
@@ -6431,8 +6428,9 @@ ada_lookup_name_info::matches
else
match_str = sym_name;
- comp_match->set_match (match_str.c_str ());
}
+
+ comp_match_res->set_match (match_str.c_str ());
}
return true;
@@ -13925,7 +13923,7 @@ static const struct exp_descriptor ada_exp_descriptor = {
static bool
do_wild_match (const char *symbol_search_name,
const lookup_name_info &lookup_name,
- completion_match *match)
+ completion_match_result *comp_match_res)
{
return wild_match (symbol_search_name, ada_lookup_name (lookup_name));
}
@@ -13935,7 +13933,7 @@ do_wild_match (const char *symbol_search_name,
static bool
do_full_match (const char *symbol_search_name,
const lookup_name_info &lookup_name,
- completion_match *match)
+ completion_match_result *comp_match_res)
{
return full_match (symbol_search_name, ada_lookup_name (lookup_name));
}
@@ -14005,11 +14003,11 @@ ada_lookup_name_info::ada_lookup_name_info (const lookup_name_info &lookup_name)
static bool
ada_symbol_name_matches (const char *symbol_search_name,
const lookup_name_info &lookup_name,
- completion_match *match)
+ completion_match_result *comp_match_res)
{
return lookup_name.ada ().matches (symbol_search_name,
lookup_name.match_type (),
- match);
+ comp_match_res);
}
/* Implement the "la_get_symbol_name_matcher" language_defn method for