[Lldb-commits] [lldb] [lldb] Add tree-sitter based Rust syntax highlighting (PR #181282)
David Spickett via lldb-commits
lldb-commits at lists.llvm.org
Tue Feb 17 05:21:58 PST 2026
================
@@ -436,4 +442,124 @@ TEST_F(HighlighterTest, SwiftClosures) {
EXPECT_EQ(" <k>let</k> closure = { (x: <k>Int</k>) in return x * 2 }",
highlightSwift(" let closure = { (x: Int) in return x * 2 }", s));
}
+
+static std::string
+highlightRust(llvm::StringRef code, HighlightStyle style,
+ std::optional<size_t> cursor = std::optional<size_t>()) {
+ HighlighterManager mgr;
+ const Highlighter &h =
+ mgr.getHighlighterFor(lldb::eLanguageTypeRust, "main.rs");
+ return h.Highlight(style, code, cursor);
+}
+
+TEST_F(HighlighterTest, RustComments) {
+ HighlightStyle s;
+ s.comment.Set("<cc>", "</cc>");
+
+ EXPECT_EQ(" <cc>// I'm feeling lucky today</cc>",
+ highlightRust(" // I'm feeling lucky today", s));
+ EXPECT_EQ(" <cc>/* This is a\nmultiline comment */</cc>",
+ highlightRust(" /* This is a\nmultiline comment */", s));
+ EXPECT_EQ(" <cc>/* nested /* comment */ works */</cc>",
+ highlightRust(" /* nested /* comment */ works */", s));
+ EXPECT_EQ(" <cc>/// Documentation comment</cc>",
+ highlightRust(" /// Documentation comment", s));
+ EXPECT_EQ(" <cc>//! Inner doc comment</cc>",
+ highlightRust(" //! Inner doc comment", s));
+}
----------------
DavidSpickett wrote:
I'm not very familiar with these plugins. What is the goal of these tests exactly?
I can't tell if they're on the scale of smoke tests or trying to cover a majority of things we'd expect it to do. If it's the latter, what's the coverage in the original project and can we either trust that or import the tests here too?
https://github.com/llvm/llvm-project/pull/181282
More information about the lldb-commits
mailing list