diazhector98 created this revision.
diazhector98 added a reviewer: wallace.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
diazhector98 planned changes to this revision.
diazhector98 marked 5 inline comments as done.
diazhector98 added inline comments.
================
Comment at:
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/completions/TestVSCode_completions.py:122
+ self.verify_completions(
+ self.vscode.get_completions("foo1.v"),
+ [
----------------
also test this
foo.var1 + var2
foo.var1 + va
var2
var1
================
Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:956
+
+ std::vector<std::string> breakpoints = {".", "->"};
+ int max_breakpoint_position = -1;
----------------
commit_points
================
Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:958
+ int max_breakpoint_position = -1;
+ std::string breakpoint_string = "";
+ for (std::string breakpoint : breakpoints){
----------------
int breakpoint_index = -1
================
Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:959
+ std::string breakpoint_string = "";
+ for (std::string breakpoint : breakpoints){
+ int breakpoint_position = match.rfind(breakpoint);
----------------
space before {
================
Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:966
+ }
+ if (max_breakpoint_position != -1){
+ std::string cut_match = match.substr(max_breakpoint_position +
breakpoint_string.length(), match.length() - max_breakpoint_position);
----------------
space before {
TODO
Repository:
rG LLVM Github Monorepo
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/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
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,25 @@
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> breakpoints = {".", "->"};
+ int max_breakpoint_position = -1;
+ std::string breakpoint_string = "";
+ for (std::string breakpoint : breakpoints){
+ int breakpoint_position = match.rfind(breakpoint);
+ if (max_breakpoint_position < breakpoint_position){
+ breakpoint_string = breakpoint;
+ max_breakpoint_position = breakpoint_position;
+ }
+ }
+ if (max_breakpoint_position != -1){
+ std::string cut_match = match.substr(max_breakpoint_position + breakpoint_string.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/vscode.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -350,6 +350,8 @@
def get_completions(self, text):
response = self.request_completions(text)
+ print(response['body']['targets'])
+ print("==========")
return response['body']['targets']
def get_scope_variables(self, scope_name, frameIndex=0, threadId=None):
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
@@ -16,6 +16,10 @@
mydir = TestBase.compute_mydir(__file__)
def verify_completions(self, actual_list, expected_list, not_expected_list=[]):
+ print("Expected List: ")
+ print(expected_list)
+ print("Actual List: ")
+ print(actual_list)
for expected_item in expected_list:
self.assertTrue(expected_item in actual_list)
@@ -23,7 +27,7 @@
self.assertFalse(not_expected_item in actual_list)
@skipIfWindows
- @skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots
+ #@skipIfDarwin # Skip this test for now until we can figure out why tings aren't working on build bots
def test_completions(self):
"""
Tests the completion request at different breakpoints
@@ -113,3 +117,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
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits