[lldb][NFC] Make cursor char position unsigned in CompletionRequest
authorRaphael Isemann <teemperor@gmail.com>
Mon, 23 Sep 2019 09:51:36 +0000 (09:51 +0000)
committerRaphael Isemann <teemperor@gmail.com>
Mon, 23 Sep 2019 09:51:36 +0000 (09:51 +0000)
This was only an 'int' because to fit into the old API which is
gone by now.

llvm-svn: 372568

lldb/include/lldb/Utility/CompletionRequest.h
lldb/unittests/Utility/CompletionRequestTest.cpp

index 849f0cf..af9f107 100644 (file)
@@ -129,8 +129,8 @@ public:
   void SetCursorIndex(size_t i) { m_cursor_index = i; }
   size_t GetCursorIndex() const { return m_cursor_index; }
 
-  void SetCursorCharPosition(int pos) { m_cursor_char_position = pos; }
-  int GetCursorCharPosition() const { return m_cursor_char_position; }
+  void SetCursorCharPosition(size_t pos) { m_cursor_char_position = pos; }
+  size_t GetCursorCharPosition() const { return m_cursor_char_position; }
 
   /// Adds a possible completion string. If the completion was already
   /// suggested before, it will not be added to the list of results. A copy of
@@ -210,7 +210,7 @@ private:
   /// 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.
-  int m_cursor_char_position;
+  size_t m_cursor_char_position;
 
   /// The result this request is supposed to fill out.
   /// We keep this object private to ensure that no backend can in any way
index bdd51eb..174a955 100644 (file)
@@ -15,7 +15,7 @@ TEST(CompletionRequest, Constructor) {
   std::string command = "a bad c";
   const unsigned cursor_pos = 3;
   const size_t arg_index = 1;
-  const int arg_cursor_pos = 1;
+  const size_t arg_cursor_pos = 1;
   StringList matches;
   CompletionResult result;
 
@@ -43,7 +43,7 @@ TEST(CompletionRequest, FakeLastArg) {
   EXPECT_STREQ(request.GetRawLine().str().c_str(), command.c_str());
   EXPECT_EQ(request.GetRawCursorPos(), cursor_pos);
   EXPECT_EQ(request.GetCursorIndex(), 3U);
-  EXPECT_EQ(request.GetCursorCharPosition(), 0);
+  EXPECT_EQ(request.GetCursorCharPosition(), 0U);
 
   EXPECT_EQ(request.GetPartialParsedLine().GetArgumentCount(), 4U);
   EXPECT_STREQ(request.GetPartialParsedLine().GetArgumentAtIndex(3), "");
@@ -90,7 +90,7 @@ TEST(CompletionRequest, ShiftArguments) {
   std::string command = "a bad c";
   const unsigned cursor_pos = 3;
   const size_t arg_index = 1;
-  const int arg_cursor_pos = 1;
+  const size_t arg_cursor_pos = 1;
   StringList matches;
   CompletionResult result;