diff --git a/src/editor/core/cm/highlight.ts b/src/editor/core/cm/highlight.ts index e9be93e554..757c407aa4 100644 --- a/src/editor/core/cm/highlight.ts +++ b/src/editor/core/cm/highlight.ts @@ -53,7 +53,9 @@ export const openideaHighlightStyle = HighlightStyle.define([ token(t.escape, "escape"), token(t.regexp, "regexp"), token([t.number, t.integer, t.float], "number"), - token([t.typeName, t.className, t.namespace, t.definition(t.typeName)], "type"), + token([t.typeName, t.className, t.definition(t.typeName)], "type"), + // Package references get their own scheme attribute (IDEA's Package reference), with Class name as fallback. + token(t.namespace, "namespace", { color: "type" }), token(t.standard(t.variableName), "builtin"), token(t.standard(t.typeName), "builtin-type", { color: "builtin" }), token(t.standard(t.function(t.variableName)), "builtin-function", { color: "builtin" }), diff --git a/src/editor/core/cm/syntaxHighlight.test.ts b/src/editor/core/cm/syntaxHighlight.test.ts index 0ea2e3f475..b1f0033291 100644 --- a/src/editor/core/cm/syntaxHighlight.test.ts +++ b/src/editor/core/cm/syntaxHighlight.test.ts @@ -54,6 +54,13 @@ describe("syntaxHighlightField", () => { expect(marks(state)).toEqual([{ text: "def", cls: command }]); }); + it("maps t.namespace to Package reference, not Class name", () => { + const namespaceClass = openideaHighlightStyle.style([t.namespace]); + const typeClass = openideaHighlightStyle.style([t.typeName]); + expect(namespaceClass).toBeTruthy(); + expect(namespaceClass).not.toBe(typeClass); + }); + it("lets Kotlin declaration roles override the stream lexer's generic definition style", async () => { const support = await loadSupport(findLanguageDescription("Kotlin", "demo.kt")!); const view = new EditorView({