diazhector98 updated this revision to Diff 240694.
diazhector98 added a comment.



1. Updating D73506 <https://reviews.llvm.org/D73506>: Bug fix #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment. #
4. If you intended to create a new revision, use:
5. $ arc diff --create

Brackets syntax


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73506/new/

https://reviews.llvm.org/D73506

Files:
  
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===================================================================
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -951,9 +951,27 @@
   for (size_t i = 0; i < count; i++) {
     std::string match = matches.GetStringAtIndex(i);
     std::string description = descriptions.GetStringAtIndex(i);
-
+    
     llvm::json::Object item;
-    EmplaceSafeString(item, "text", match);
+
+    std::vector<std::string> commit_points = {".", "->"};
+    int max_breakpoint_position = -1;
+    int commit_points_index = -1;
+    for (uint32_t breakpoint_index = 0; breakpoint_index < 
commit_points.size(); breakpoint_index++) {
+      int breakpoint_position = match.rfind(commit_points[breakpoint_index]);
+      if (max_breakpoint_position < breakpoint_position){
+        commit_points_index = breakpoint_index;
+        max_breakpoint_position = breakpoint_position;
+      }
+    }
+
+    if (max_breakpoint_position != -1) {
+      std::string cut_match = match.substr(max_breakpoint_position + 
commit_points[commit_points_index].length(), match.length() - 
max_breakpoint_position);
+      EmplaceSafeString(item, "text", cut_match);
+    } else {
+      EmplaceSafeString(item, "text", match);
+    }
+
     if (description.empty())
       EmplaceSafeString(item, "label", match);
     else
Index: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
@@ -1,6 +1,17 @@
 #include <string>
 #include <vector>
 
+struct bar {
+  int var1;
+};
+
+struct foo {
+  int var1;
+  bar* my_bar_pointer;
+  bar my_bar_object;
+  foo* next_foo;
+};
+
 int fun(std::vector<std::string> var) {
   return var.size(); // breakpoint 1
 }
@@ -12,5 +23,8 @@
   std::string str2 = "b";
   std::vector<std::string> vec;
   fun(vec);
+  bar bar1 = {2};
+  bar* bar2 = &bar1; 
+  foo foo1 = {3,&bar1, bar1, NULL};
   return 0; // breakpoint 2
 }
Index: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
===================================================================
--- 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
+++ 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
@@ -113,3 +113,23 @@
                 }
             ],
         )
+
+        self.verify_completions(
+            self.vscode.get_completions("foo1.v"),
+            [
+                {
+                    "text": "var1",
+                    "label": "foo1.var1 -- int"
+                }
+            ]
+        )
+
+        self.verify_completions(
+            self.vscode.get_completions("foo1.my_bar_object.v"),
+            [
+                {
+                    "text": "var1",
+                    "label": "foo1.my_bar_object.var1 -- int"
+                }
+            ]
+        )


Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===================================================================
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -951,9 +951,27 @@
   for (size_t i = 0; i < count; i++) {
     std::string match = matches.GetStringAtIndex(i);
     std::string description = descriptions.GetStringAtIndex(i);
-
+    
     llvm::json::Object item;
-    EmplaceSafeString(item, "text", match);
+
+    std::vector<std::string> commit_points = {".", "->"};
+    int max_breakpoint_position = -1;
+    int commit_points_index = -1;
+    for (uint32_t breakpoint_index = 0; breakpoint_index < commit_points.size(); breakpoint_index++) {
+      int breakpoint_position = match.rfind(commit_points[breakpoint_index]);
+      if (max_breakpoint_position < breakpoint_position){
+        commit_points_index = breakpoint_index;
+        max_breakpoint_position = breakpoint_position;
+      }
+    }
+
+    if (max_breakpoint_position != -1) {
+      std::string cut_match = match.substr(max_breakpoint_position + commit_points[commit_points_index].length(), match.length() - max_breakpoint_position);
+      EmplaceSafeString(item, "text", cut_match);
+    } else {
+      EmplaceSafeString(item, "text", match);
+    }
+
     if (description.empty())
       EmplaceSafeString(item, "label", match);
     else
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/main.cpp
@@ -1,6 +1,17 @@
 #include <string>
 #include <vector>
 
+struct bar {
+  int var1;
+};
+
+struct foo {
+  int var1;
+  bar* my_bar_pointer;
+  bar my_bar_object;
+  foo* next_foo;
+};
+
 int fun(std::vector<std::string> var) {
   return var.size(); // breakpoint 1
 }
@@ -12,5 +23,8 @@
   std::string str2 = "b";
   std::vector<std::string> vec;
   fun(vec);
+  bar bar1 = {2};
+  bar* bar2 = &bar1; 
+  foo foo1 = {3,&bar1, bar1, NULL};
   return 0; // breakpoint 2
 }
Index: lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py
@@ -113,3 +113,23 @@
                 }
             ],
         )
+
+        self.verify_completions(
+            self.vscode.get_completions("foo1.v"),
+            [
+                {
+                    "text": "var1",
+                    "label": "foo1.var1 -- int"
+                }
+            ]
+        )
+
+        self.verify_completions(
+            self.vscode.get_completions("foo1.my_bar_object.v"),
+            [
+                {
+                    "text": "var1",
+                    "label": "foo1.my_bar_object.var1 -- int"
+                }
+            ]
+        )
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] ... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... walter erquinigo via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Pavel Labath via Phabricator via lldb-commits
    • [Lldb-comm... Raphael Isemann via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Héctor Luis Díaz Aceves via Phabricator via lldb-commits
    • [Lldb-comm... Phabricator via Phabricator via lldb-commits

Reply via email to