Файли
openidea/e2e/jsMethodStyle.fixture.ts
T
l0ng-ai 2523e17cbd feat(editor): colour JavaScript and TypeScript methods apart from functions (#5683)
tsserver's method/member tokens were mapped to the plain function class. Methods now also get an instance- or static-method class, with Identifiers › Instance method and Static method on the JavaScript and TypeScript colour scheme page; unset, they keep the function declaration/call styles so existing themes look the same. JetBrains scheme import maps INSTANCE_MEMBER_FUNCTION and STATIC_MEMBER_FUNCTION to them.

Fixes #5623
2026-11-25 05:13:27 +08:00

45 рядки
1.7 KiB
TypeScript

import { EditorView } from "@codemirror/view";
import { commands } from "../src/platform/ipc";
import { setInvokeRoute } from "../src/platform/tauriCore";
import { schemeCss } from "../src/platform/colorScheme";
import { lspDoc } from "../src/editor/lsp/lsp";
import { semanticExtension } from "../src/editor/lsp/semantic";
import { lspTheme } from "../src/editor/lsp/theme";
// Lines: an instance method declaration, its call, a static method call, a local function call.
setInvokeRoute(() => null);
commands.lspSemanticTokens = async () => ({
status: "ok",
data: {
tokenTypes: ["method", "member", "function"],
tokenModifiers: ["declaration", "static", "local"],
data: [0, 0, 5, 0, 0b001, 1, 0, 5, 1, 0, 2, 0, 6, 1, 0b010, 3, 0, 4, 2, 0b100],
},
});
const methods = new URLSearchParams(location.search).has("methods");
const style = document.createElement("style");
style.textContent = schemeCss("dark", {
dark: {
functionDeclaration: { foreground: "#6688aa" },
functionCall: { foreground: "#99bbdd" },
...(methods
? {
"javascript.instanceMethod": { foreground: "#e06c75" },
"javascript.staticMethod": { foreground: "#cf8e6d", italic: false },
}
: {}),
},
});
document.head.append(style);
new EditorView({
parent: document.body,
doc: "count\ncount\ncreate\nhelp",
extensions: [
// The app's editors name their language; the JavaScript and TypeScript page's colours apply there.
EditorView.editorAttributes.of({ "data-language": "TypeScript" }),
lspTheme,
lspDoc.of({ doc: 1, path: "demo.ts", language: "typescript", uiMode: "TypeScript", readOnly: false }),
semanticExtension(),
],
});