diff --git a/lldb/include/lldb/Utility/CompletionRequest.h b/lldb/include/lldb/Utility/CompletionRequest.h index 0840e5c23952..ce8301b058ee 100644 --- a/lldb/include/lldb/Utility/CompletionRequest.h +++ b/lldb/include/lldb/Utility/CompletionRequest.h @@ -113,8 +113,6 @@ public: Args &GetParsedLine() { return m_parsed_line; } - const Args &GetPartialParsedLine() const { return m_partial_parsed_line; } - const Args::ArgEntry &GetParsedArg() { return GetParsedLine()[GetCursorIndex()]; } @@ -123,7 +121,6 @@ public: void ShiftArguments() { m_cursor_index--; m_parsed_line.Shift(); - m_partial_parsed_line.Shift(); } void SetCursorIndex(size_t i) { m_cursor_index = i; } @@ -206,8 +203,6 @@ private: unsigned m_raw_cursor_pos; /// The command line parsed as arguments. Args m_parsed_line; - /// The command line until the cursor position parsed as arguments. - Args m_partial_parsed_line; /// The index of the argument in which the completion cursor is. size_t m_cursor_index; /// The cursor position in the argument indexed by m_cursor_index. diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index cb61046e574e..10a806531680 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -1756,7 +1756,7 @@ void CommandInterpreter::HandleCompletionMatches(CompletionRequest &request) { // For any of the command completions a unique match will be a complete word. - if (request.GetPartialParsedLine().GetArgumentCount() == 0) { + if (request.GetParsedLine().GetArgumentCount() == 0) { // We got nothing on the command line, so return the list of commands bool include_aliases = true; StringList new_matches, descriptions; diff --git a/lldb/source/Utility/CompletionRequest.cpp b/lldb/source/Utility/CompletionRequest.cpp index aaaef78cd1de..e9c838f9d4ad 100644 --- a/lldb/source/Utility/CompletionRequest.cpp +++ b/lldb/source/Utility/CompletionRequest.cpp @@ -21,17 +21,16 @@ CompletionRequest::CompletionRequest(llvm::StringRef command_line, // 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 // last character. - m_parsed_line = Args(command_line); llvm::StringRef partial_command(command_line.substr(0, raw_cursor_pos)); - m_partial_parsed_line = Args(partial_command); + m_parsed_line = Args(partial_command); - if (m_partial_parsed_line.GetArgumentCount() == 0) { + if (GetParsedLine().GetArgumentCount() == 0) { m_cursor_index = 0; m_cursor_char_position = 0; } else { - m_cursor_index = m_partial_parsed_line.GetArgumentCount() - 1U; + m_cursor_index = GetParsedLine().GetArgumentCount() - 1U; m_cursor_char_position = - strlen(m_partial_parsed_line.GetArgumentAtIndex(m_cursor_index)); + strlen(GetParsedLine().GetArgumentAtIndex(m_cursor_index)); } // The cursor is after a space but the space is not part of the argument. @@ -40,7 +39,6 @@ CompletionRequest::CompletionRequest(llvm::StringRef command_line, if (partial_command.endswith(" ") && !GetCursorArgumentPrefix().endswith(" ")) { m_parsed_line.AppendArgument(llvm::StringRef()); - m_partial_parsed_line.AppendArgument(llvm::StringRef()); // Set the cursor to the start of the fake argument. m_cursor_index++; m_cursor_char_position = 0; diff --git a/lldb/unittests/Utility/CompletionRequestTest.cpp b/lldb/unittests/Utility/CompletionRequestTest.cpp index 174a9553c24f..6e501a988de3 100644 --- a/lldb/unittests/Utility/CompletionRequestTest.cpp +++ b/lldb/unittests/Utility/CompletionRequestTest.cpp @@ -27,8 +27,8 @@ TEST(CompletionRequest, Constructor) { EXPECT_EQ(request.GetCursorIndex(), arg_index); EXPECT_EQ(request.GetCursorCharPosition(), arg_cursor_pos); - EXPECT_EQ(request.GetPartialParsedLine().GetArgumentCount(), 2u); - EXPECT_STREQ(request.GetPartialParsedLine().GetArgumentAtIndex(1), "b"); + EXPECT_EQ(request.GetParsedLine().GetArgumentCount(), 2u); + EXPECT_STREQ(request.GetParsedLine().GetArgumentAtIndex(1), "b"); } TEST(CompletionRequest, FakeLastArg) { @@ -45,8 +45,8 @@ TEST(CompletionRequest, FakeLastArg) { EXPECT_EQ(request.GetCursorIndex(), 3U); EXPECT_EQ(request.GetCursorCharPosition(), 0U); - EXPECT_EQ(request.GetPartialParsedLine().GetArgumentCount(), 4U); - EXPECT_STREQ(request.GetPartialParsedLine().GetArgumentAtIndex(3), ""); + EXPECT_EQ(request.GetParsedLine().GetArgumentCount(), 4U); + EXPECT_STREQ(request.GetParsedLine().GetArgumentAtIndex(3), ""); } TEST(CompletionRequest, TryCompleteCurrentArgGood) { @@ -102,8 +102,8 @@ TEST(CompletionRequest, ShiftArguments) { EXPECT_EQ(request.GetCursorIndex(), arg_index); EXPECT_EQ(request.GetCursorCharPosition(), arg_cursor_pos); - EXPECT_EQ(request.GetPartialParsedLine().GetArgumentCount(), 2u); - EXPECT_STREQ(request.GetPartialParsedLine().GetArgumentAtIndex(1), "b"); + EXPECT_EQ(request.GetParsedLine().GetArgumentCount(), 2u); + EXPECT_STREQ(request.GetParsedLine().GetArgumentAtIndex(1), "b"); // Shift away the 'a' argument. request.ShiftArguments(); @@ -117,8 +117,8 @@ TEST(CompletionRequest, ShiftArguments) { // Partially parsed line and cursor should be updated. EXPECT_EQ(request.GetCursorIndex(), arg_index - 1U); - EXPECT_EQ(request.GetPartialParsedLine().GetArgumentCount(), 1u); - EXPECT_STREQ(request.GetPartialParsedLine().GetArgumentAtIndex(0), "b"); + EXPECT_EQ(request.GetParsedLine().GetArgumentCount(), 1u); + EXPECT_STREQ(request.GetParsedLine().GetArgumentAtIndex(0), "b"); } TEST(CompletionRequest, DuplicateFiltering) {