Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 15866d11b4 fix(rust): colour self as a keyword
rust-analyzer's `selfKeyword` token and @lezer/rust's `self` tag were painted with Python's self-parameter colour. Both now take the keyword colour, as RustRover colours the self parameter by default.
2026-11-16 05:10:55 +08:00
4 змінених файлів з 11 додано та 3 видалено

No files matched your search

+2 -1
Переглянути файл
@@ -270,7 +270,7 @@ describe("language modes", () => {
}
});
it("colours `this` and `super` as keywords in Java, JavaScript, TypeScript and C++", async () => {
it("colours `this`, `super` and Rust's `self` as keywords", async () => {
const highlighter = tagHighlighter([
{ tag: t.keyword, class: "keyword" },
{ tag: t.self, class: "self" },
@@ -281,6 +281,7 @@ describe("language modes", () => {
["JavaScript", "/p/a.js", "class A extends B { m() { super.m(); this.a = 1; } }", ["super", "this"]],
["TypeScript", "/p/a.ts", "class A extends B { m() { super.m(); this.a = 1; } }", ["super", "this"]],
["C++", "/p/a.cpp", "void A::m() { this->a = 1; }", ["this"]],
["Rust", "/p/a.rs", "impl A { fn m(&self) { self.a = 1; } }", ["self", "self"]],
] as const) {
const support = await loadSupport(findLanguageDescription(mode, path)!);
const found: Array<[string, string]> = [];
+2 -1
Переглянути файл
@@ -308,8 +308,9 @@ const EXTRA_TAGS: Record<string, Parameters<typeof styleTags>[0]> = {
JSX: JS_TAGS,
TSX: JS_TAGS,
Java: JAVA_TAGS,
// CLion colours `this` as a keyword.
// CLion colours `this` as a keyword, RustRover `self`.
"C++": { this: t.keyword },
Rust: { self: t.keyword },
PHP: {
"; ,": t.separator,
"ClassDeclaration/Name BaseClause/Name InterfaceClause/Name": t.className,
+5
Переглянути файл
@@ -64,6 +64,11 @@ describe("semanticRanges", () => {
]);
});
it("colours rust-analyzer's `self` as a keyword", () => {
const input = { tokenTypes: ["selfKeyword"], tokenModifiers: [], data: [0, 0, 3, 0, 0] };
expect(semanticRanges(doc, input)[0]?.className).toBe("cm-sem-keyword");
});
it("colours a constructor (jdtls: class + `constructor`) as a function", () => {
const input = { tokenTypes: ["class"], tokenModifiers: ["constructor", "declaration"], data: [0, 0, 3, 0, 0b11] };
expect(semanticRanges(doc, input)[0]?.className).toBe("cm-sem-function cm-sem-declaration");
+2 -1
Переглянути файл
@@ -61,7 +61,8 @@ const TYPE_CLASS: Record<string, string> = {
lifetime: "annotation",
selfParameter: "self",
clsParameter: "self",
selfKeyword: "self",
// rust-analyzer's `self`: RustRover colours the self parameter as a keyword.
selfKeyword: "keyword",
};
const MODIFIER_CLASS: Record<string, string> = {