[CompletionRequest] Remove unimplemented members.

Completion requests have two fields that are essentially unimplemented:
`m_match_start_point` and `m_max_return_elements`. This would've been
okay, if it wasn't for the fact that this caused a bunch of useless
parameters to be passed around. Occasionally there would be a comment or
assert saying that they are not supported. This patch removes them.

llvm-svn: 367385
This commit is contained in:
Jonas Devlieghere 2019-07-31 03:48:29 +00:00
parent 175f093090
commit b22860da61
13 changed files with 21 additions and 68 deletions

View File

@ -200,7 +200,6 @@ public:
virtual int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
const char *cursor, const char *last_char,
int skip_first_n_matches, int max_matches,
StringList &matches, StringList &descriptions);
virtual const char *IOHandlerGetFixIndentationCharacters() { return nullptr; }
@ -417,7 +416,6 @@ private:
static int AutoCompleteCallback(const char *current_line, const char *cursor,
const char *last_char,
int skip_first_n_matches, int max_matches,
StringList &matches, StringList &descriptions,
void *baton);
#endif
@ -452,7 +450,6 @@ public:
int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
const char *cursor, const char *last_char,
int skip_first_n_matches, int max_matches,
StringList &matches, StringList &descriptions) override;
void IOHandlerInputComplete(IOHandler &io_handler,

View File

@ -105,7 +105,6 @@ public:
int IOHandlerComplete(IOHandler &io_handler, const char *current_line,
const char *cursor, const char *last_char,
int skip_first_n_matches, int max_matches,
StringList &matches, StringList &descriptions) override;
protected:

View File

@ -99,7 +99,6 @@ typedef int (*FixIndentationCallbackType)(Editline *editline,
typedef int (*CompleteCallbackType)(const char *current_line,
const char *cursor, const char *last_char,
int skip_first_n_matches, int max_matches,
StringList &matches,
StringList &descriptions, void *baton);

View File

@ -325,8 +325,7 @@ public:
//
// FIXME: Only max_return_elements == -1 is supported at present.
int HandleCompletion(const char *current_line, const char *cursor,
const char *last_char, int match_start_point,
int max_return_elements, StringList &matches,
const char *last_char, StringList &matches,
StringList &descriptions);
// This version just returns matches, and doesn't compute the substring. It

View File

@ -68,18 +68,10 @@ public:
/// the cursor is at the start of the line. The completion starts from
/// this cursor position.
///
/// \param [in] match_start_point
/// \param [in] max_return_elements
/// If there is a match that is expensive to compute, these are here to
/// allow you to compute the completions in batches. Start the
/// completion from match_start_point, and return match_return_elements
/// elements.
///
/// \param [out] result
/// The CompletionResult that will be filled with the results after this
/// request has been handled.
CompletionRequest(llvm::StringRef command_line, unsigned raw_cursor_pos,
int match_start_point, int max_return_elements,
CompletionResult &result);
llvm::StringRef GetRawLine() const { return m_command; }
@ -98,10 +90,6 @@ public:
void SetCursorCharPosition(int pos) { m_cursor_char_position = pos; }
int GetCursorCharPosition() const { return m_cursor_char_position; }
int GetMatchStartPoint() const { return m_match_start_point; }
int GetMaxReturnElements() const { return m_max_return_elements; }
bool GetWordComplete() { return m_word_complete; }
void SetWordComplete(bool v) { m_word_complete = v; }
@ -170,13 +158,6 @@ private:
int m_cursor_index;
/// The cursor position in the argument indexed by m_cursor_index.
int m_cursor_char_position;
/// If there is a match that is expensive
/// to compute, these are here to allow you to compute the completions in
/// batches. Start the completion from \amatch_start_point, and return
/// \amatch_return_elements elements.
// FIXME: These two values are not implemented.
int m_match_start_point;
int m_max_return_elements;
/// \btrue if this is a complete option value (a space will be inserted
/// after the completion.) \bfalse otherwise.
bool m_word_complete = false;

View File

@ -372,8 +372,7 @@ int SBCommandInterpreter::HandleCompletionWithDescriptions(
if (IsValid()) {
lldb_private::StringList lldb_matches, lldb_descriptions;
num_completions = m_opaque_ptr->HandleCompletion(
current_line, cursor, last_char, match_start_point, max_return_elements,
lldb_matches, lldb_descriptions);
current_line, cursor, last_char, lldb_matches, lldb_descriptions);
SBStringList temp_matches_list(&lldb_matches);
matches.AppendList(temp_matches_list);

View File

@ -2350,7 +2350,6 @@ size_t FormatEntity::AutoComplete(CompletionRequest &request) {
llvm::StringRef str = request.GetCursorArgumentPrefix().str();
request.SetWordComplete(false);
str = str.drop_front(request.GetMatchStartPoint());
const size_t dollar_pos = str.rfind('$');
if (dollar_pos == llvm::StringRef::npos)

View File

@ -172,8 +172,7 @@ IOHandlerConfirm::~IOHandlerConfirm() = default;
int IOHandlerConfirm::IOHandlerComplete(
IOHandler &io_handler, const char *current_line, const char *cursor,
const char *last_char, int skip_first_n_matches, int max_matches,
StringList &matches, StringList &descriptions) {
const char *last_char, StringList &matches, StringList &descriptions) {
if (current_line == cursor) {
if (m_default_response) {
matches.AppendString("y");
@ -221,20 +220,17 @@ void IOHandlerConfirm::IOHandlerInputComplete(IOHandler &io_handler,
int IOHandlerDelegate::IOHandlerComplete(
IOHandler &io_handler, const char *current_line, const char *cursor,
const char *last_char, int skip_first_n_matches, int max_matches,
StringList &matches, StringList &descriptions) {
const char *last_char, StringList &matches, StringList &descriptions) {
switch (m_completion) {
case Completion::None:
break;
case Completion::LLDBCommand:
return io_handler.GetDebugger().GetCommandInterpreter().HandleCompletion(
current_line, cursor, last_char, skip_first_n_matches, max_matches,
matches, descriptions);
current_line, cursor, last_char, matches, descriptions);
case Completion::Expression: {
CompletionResult result;
CompletionRequest request(current_line, cursor - current_line,
skip_first_n_matches, max_matches, result);
CompletionRequest request(current_line, cursor - current_line, result);
CommandCompletions::InvokeCommonCompletionCallbacks(
io_handler.GetDebugger().GetCommandInterpreter(),
CommandCompletions::eVariablePathCompletion, request, nullptr);
@ -449,13 +445,12 @@ int IOHandlerEditline::FixIndentationCallback(Editline *editline,
int IOHandlerEditline::AutoCompleteCallback(
const char *current_line, const char *cursor, const char *last_char,
int skip_first_n_matches, int max_matches, StringList &matches,
StringList &descriptions, void *baton) {
StringList &matches, StringList &descriptions, void *baton) {
IOHandlerEditline *editline_reader = (IOHandlerEditline *)baton;
if (editline_reader)
return editline_reader->m_delegate.IOHandlerComplete(
*editline_reader, current_line, cursor, last_char, skip_first_n_matches,
max_matches, matches, descriptions);
*editline_reader, current_line, cursor, last_char, matches,
descriptions);
return 0;
}
#endif

View File

@ -435,7 +435,6 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) {
int REPL::IOHandlerComplete(IOHandler &io_handler, const char *current_line,
const char *cursor, const char *last_char,
int skip_first_n_matches, int max_matches,
StringList &matches, StringList &descriptions) {
matches.Clear();
@ -448,8 +447,7 @@ int REPL::IOHandlerComplete(IOHandler &io_handler, const char *current_line,
// auto complete LLDB commands
const char *lldb_current_line = line.substr(1).data();
return debugger.GetCommandInterpreter().HandleCompletion(
lldb_current_line, cursor, last_char, skip_first_n_matches, max_matches,
matches, descriptions);
lldb_current_line, cursor, last_char, matches, descriptions);
}
// Strip spaces from the line and see if we had only spaces

View File

@ -896,8 +896,6 @@ unsigned char Editline::TabCommand(int ch) {
const int num_completions = m_completion_callback(
line_info->buffer, line_info->cursor, line_info->lastchar,
0, // Don't skip any matches (start at match zero)
-1, // Get all the matches
completions, descriptions, m_completion_callback_baton);
if (num_completions == 0)

View File

@ -1813,15 +1813,15 @@ int CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) {
return num_command_matches;
}
int CommandInterpreter::HandleCompletion(
const char *current_line, const char *cursor, const char *last_char,
int match_start_point, int max_return_elements, StringList &matches,
StringList &descriptions) {
int CommandInterpreter::HandleCompletion(const char *current_line,
const char *cursor,
const char *last_char,
StringList &matches,
StringList &descriptions) {
llvm::StringRef command_line(current_line, last_char - current_line);
CompletionResult result;
CompletionRequest request(command_line, cursor - current_line,
match_start_point, max_return_elements, result);
CompletionRequest request(command_line, cursor - current_line, result);
// Don't complete comments, and if the line we are completing is just the
// history repeat character, substitute the appropriate history line.
const char *first_arg = request.GetParsedLine().GetArgumentAtIndex(0);
@ -1838,9 +1838,6 @@ int CommandInterpreter::HandleCompletion(
}
}
// Only max_return_elements == -1 is supported at present:
lldbassert(max_return_elements == -1);
int num_command_matches = HandleCompletionMatches(request);
result.GetMatches(matches);
result.GetDescriptions(descriptions);

View File

@ -13,12 +13,9 @@ using namespace lldb_private;
CompletionRequest::CompletionRequest(llvm::StringRef command_line,
unsigned raw_cursor_pos,
int match_start_point,
int max_return_elements,
CompletionResult &result)
: m_command(command_line), m_raw_cursor_pos(raw_cursor_pos),
m_match_start_point(match_start_point),
m_max_return_elements(max_return_elements), m_result(result) {
m_result(result) {
// We parse the argument up to the cursor, so the last argument in
// parsed_line is the one containing the cursor, and the cursor is after the

View File

@ -16,21 +16,16 @@ TEST(CompletionRequest, Constructor) {
const unsigned cursor_pos = 3;
const int arg_index = 1;
const int arg_cursor_pos = 1;
const int match_start = 2345;
const int match_max_return = 12345;
StringList matches;
CompletionResult result;
CompletionRequest request(command, cursor_pos, match_start, match_max_return,
result);
CompletionRequest request(command, cursor_pos, result);
result.GetMatches(matches);
EXPECT_STREQ(request.GetRawLine().str().c_str(), command.c_str());
EXPECT_EQ(request.GetRawCursorPos(), cursor_pos);
EXPECT_EQ(request.GetCursorIndex(), arg_index);
EXPECT_EQ(request.GetCursorCharPosition(), arg_cursor_pos);
EXPECT_EQ(request.GetMatchStartPoint(), match_start);
EXPECT_EQ(request.GetMaxReturnElements(), match_max_return);
EXPECT_EQ(request.GetWordComplete(), false);
EXPECT_EQ(request.GetPartialParsedLine().GetArgumentCount(), 2u);
@ -43,7 +38,7 @@ TEST(CompletionRequest, DuplicateFiltering) {
StringList matches;
CompletionResult result;
CompletionRequest request(command, cursor_pos, 0, 0, result);
CompletionRequest request(command, cursor_pos, result);
result.GetMatches(matches);
EXPECT_EQ(0U, request.GetNumberOfMatches());
@ -106,7 +101,7 @@ TEST(CompletionRequest, DuplicateFilteringWithComments) {
StringList matches, descriptions;
CompletionResult result;
CompletionRequest request(command, cursor_pos, 0, 0, result);
CompletionRequest request(command, cursor_pos, result);
result.GetMatches(matches);
result.GetDescriptions(descriptions);
@ -182,7 +177,7 @@ TEST(CompletionRequest, TestCompletionOwnership) {
StringList matches;
CompletionResult result;
CompletionRequest request(command, cursor_pos, 0, 0, result);
CompletionRequest request(command, cursor_pos, result);
std::string Temporary = "bar";
request.AddCompletion(Temporary);