feat(editor): style Java static, constant and final fields separately (#7930)

Java fields get their own colour scheme attributes under Java > Class Fields: instance field, instance final field, static field and constant (static final field), each falling back through the field kind it refines to Language Defaults > Identifiers > Static field / Instance field. Interface fields count as constants. The resolver and settings preview follow the whole inherit chain; .icls import maps the matching attributes.

Fixes #7643
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-12-04 11:17:26 +08:00
1 джерело d62c978032
коміт d55f116add
16 files changed
+247 -29

No files matched your search

+37
Переглянути файл
@@ -0,0 +1,37 @@
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";
// jdtls's tokens for four fields, one per line: instance, instance final, static, static final.
setInvokeRoute(() => null);
commands.lspSemanticTokens = async () => ({
status: "ok",
data: {
tokenTypes: ["property"],
tokenModifiers: ["static", "readonly"],
data: [0, 0, 5, 0, 0, 1, 0, 4, 0, 2, 2, 0, 6, 0, 1, 3, 0, 3, 0, 3],
},
});
const style = document.createElement("style");
style.textContent = schemeCss("dark", {
dark: {
staticField: { foreground: "#9876aa" },
"java.staticFinalField": { bold: true },
"java.instanceFinalField": { foreground: "#cc7832" },
},
});
document.head.append(style);
new EditorView({
parent: document.body,
doc: "count\ncode\nactive\nMAX",
extensions: [
EditorView.editorAttributes.of({ "data-language": "Java" }),
lspTheme,
lspDoc.of({ doc: 1, path: "A.java", language: "java", uiMode: "Java", readOnly: false }),
semanticExtension(),
],
});