This revision was automatically updated to reflect the committed changes. Closed by commit rG45e3f6660cf4: Auto-completion bug fix for dot operator (authored by Hector Diaz <hd...@fb.com>, committed by Walter Erquinigo <walterme...@fb.com>).
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,17 @@ 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); + + llvm::StringRef match_ref = match; + for(llvm::StringRef commit_point: {".", "->"}) { + if (match_ref.contains(commit_point)){ + match_ref = match_ref.rsplit(commit_point).second; + } + } + EmplaceSafeString(item, "text", match_ref); + 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,76 @@ } ], ) + + 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" + } + ] + ) + + self.verify_completions( + self.vscode.get_completions("foo1.var1 + foo1.v"), + [ + { + "text": "var1", + "label": "foo1.var1 -- int" + } + ] + ) + + self.verify_completions( + self.vscode.get_completions("foo1.var1 + v"), + [ + { + "text": "var1", + "label": "var1 -- int &" + } + ] + ) + + #should correctly handle spaces between objects and member operators + self.verify_completions( + self.vscode.get_completions("foo1 .v"), + [ + { + "text": "var1", + "label": ".var1 -- int" + } + ], + [ + { + "text": "var2", + "label": ".var2 -- int" + } + ] + ) + + self.verify_completions( + self.vscode.get_completions("foo1 . v"), + [ + { + "text": "var1", + "label": "var1 -- int" + } + ], + [ + { + "text": "var2", + "label": "var2 -- int" + } + ] + )
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits