дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 09:41:34 +02:00
fix(csharp): colour Roslyn's record, delegate, extension method, field and constant tokens (#7756)
Roslyn sends records, delegates, extension methods, fields and constants with its own semantic token types (recordClass, recordStruct, delegate, extensionMethod, field, constant), which had no highlight class, so they showed as plain text. Each now maps to the standard type it extends. Closes #7749 Co-authored-by: ignacyszreter <[email protected]>
Цей коміт міститься в:
1 джерело
f5732dd706
коміт
c1b45b037d
2 files changed
+27
No files matched your search
@@ -61,6 +61,13 @@ const TYPE_CLASS: Record<string, string> = {
|
||||
record: "type",
|
||||
recordComponent: "property",
|
||||
attribute: "annotation",
|
||||
// Roslyn extensions
|
||||
recordClass: "type",
|
||||
recordStruct: "type",
|
||||
delegate: "type",
|
||||
extensionMethod: "function",
|
||||
field: "property",
|
||||
constant: "constant",
|
||||
enumMember: "constant",
|
||||
property: "property",
|
||||
parameter: "parameter",
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { Text } from "@codemirror/state";
|
||||
import { semanticRanges } from "./index";
|
||||
|
||||
const doc = Text.of(["name"]);
|
||||
const classesOf = (type: string) =>
|
||||
semanticRanges(doc, { tokenTypes: [type], tokenModifiers: [], data: [0, 0, 4, 0, 0] }, false, "csharp")[0]?.className;
|
||||
|
||||
describe("Roslyn semantic token types", () => {
|
||||
it.each([
|
||||
["recordClass", "cm-sem-type"],
|
||||
["recordStruct", "cm-sem-type"],
|
||||
["delegate", "cm-sem-type"],
|
||||
["extensionMethod", "cm-sem-function"],
|
||||
["field", "cm-sem-property"],
|
||||
["constant", "cm-sem-constant"],
|
||||
])("colours %s like the standard type it extends", (type, className) => {
|
||||
expect(classesOf(type)).toBe(className);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Заблокувати користувача