more theme stuff

This commit is contained in:
ed
2026-08-14 21:48:52 -04:00
parent 9ca865d5db
commit 7ec778a68e
11 changed files with 236 additions and 63 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ test("document-local declarations override an empty workspace index", () => {
const result = classifyDocument(source, "C:/x/code/duffle/math.atom.c", createIndex());
assert.equal(byText(result, "ac_new_component")[0].type, "tapeComponentName");
assert.equal(byText(result, "mac_new_component")[0].type, "tapeComponentInstruction");
assert.equal(byText(result, "mac_new_component")[0].type, "tapeCpuInstruction");
});
test("classifier returns ordered non-overlapping spans and partial malformed output", () => {
+15 -17
View File
@@ -10,7 +10,9 @@ const { TOKEN_MODIFIERS, TOKEN_TYPES } = require("../classifier");
const ROOT = path.resolve(__dirname, "..");
function readJson(filePath) {
return JSON.parse(fs.readFileSync(filePath, "utf8"));
const raw = fs.readFileSync(filePath, "utf8");
const stripped = raw.replace(/\/\/.*$/gm, "").replace(/,\s*([}\]])/g, "$1");
return JSON.parse(stripped);
}
function collectScopeNames(value, output = new Set()) {
@@ -48,15 +50,23 @@ test("package includes runtime files only and acknowledges local-only metadata",
assert.equal(packageJson.scripts.package.includes("--skip-license"), true);
});
test("every semantic token has a TextMate fallback scope and grammar scope", () => {
test("every semantic token has a scope mapping; DSL-specific tokens also have grammar scopes", () => {
const packageJson = readJson(path.join(ROOT, "package.json"));
const grammar = readJson(path.join(ROOT, "syntaxes", "tape_atom.tmLanguage.json"));
const mappings = packageJson.contributes.semanticTokenScopes[0].scopes;
const grammarScopes = collectScopeNames(grammar);
const grammarRequired = new Set([
"tapeAtomKeyword", "tapeAtomName", "tapeComponentKeyword", "tapeComponentName",
"tapeAnnotation", "tapeBindType", "tapePhase", "tapeLabel",
"tapeDelaySlot", "tapeDuffleType", "tapeAttribute",
]);
for (const tokenType of TOKEN_TYPES) {
assert.equal(Array.isArray(mappings[tokenType]), true, `missing scope mapping: ${tokenType}`);
assert.equal(mappings[tokenType].some((scope) => grammarScopes.has(scope)), true, `grammar does not emit: ${tokenType}`);
if (grammarRequired.has(tokenType)) {
assert.equal(mappings[tokenType].some((scope) => grammarScopes.has(scope)), true, `grammar does not emit: ${tokenType}`);
}
}
});
@@ -72,22 +82,10 @@ test("TextMate offset labels stay scoped to atom_offset calls", () => {
assert.equal(offsetRule.captures[3].name, "entity.name.label.duffle.atom");
});
test("workspace enables semantic highlighting and colors every custom token", () => {
test("workspace enables semantic highlighting", () => {
const settings = readJson(path.resolve(ROOT, "..", "settings.json"));
const semantic = settings["editor.semanticTokenColorCustomizations"];
assert.equal(settings["editor.semanticHighlighting.enabled"], true);
const semantic = settings["editor.semanticTokenColorCustomizations"];
assert.equal(semantic.enabled, true);
for (const tokenType of TOKEN_TYPES) {
assert.equal(Object.hasOwn(semantic.rules, tokenType), true, `missing color: ${tokenType}`);
}
for (const rule of [
"tapeGprRegister.tapeRead",
"tapeGprRegister.tapeWrite",
"tapeCop2Register.tapeRead",
"tapeCop2Register.tapeWrite",
"*.tapeAuto",
]) {
assert.equal(Object.hasOwn(semantic.rules, rule), true, `missing modifier color: ${rule}`);
}
});