mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-08-16 14:11:33 +00:00
more theme stuff
This commit is contained in:
+15
-17
@@ -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}`);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user