fix(vscode): repair WRN language diagnostics and activation

This commit is contained in:
2026-07-19 14:02:17 +05:30
parent df4c1d3e7d
commit 646d16f83d
16 changed files with 425 additions and 171 deletions
+38
View File
@@ -37,10 +37,48 @@ for (const rel of [
const grammar = JSON.parse(readFileSync(join(root, "syntaxes/wrn.tmLanguage.json"), "utf8"));
grammar.scopeName === "source.wrn" ? ok("grammar scopeName") : bad("grammar scopeName");
const localIncludes = [];
const visitGrammarNode = (value) => {
if (Array.isArray(value)) {
value.forEach(visitGrammarNode);
return;
}
if (!value || typeof value !== "object") return;
if (typeof value.include === "string" && value.include.startsWith("#")) {
localIncludes.push(value.include.slice(1));
}
Object.values(value).forEach(visitGrammarNode);
};
visitGrammarNode(grammar.patterns);
visitGrammarNode(grammar.repository);
const missingIncludes = [...new Set(localIncludes)].filter((name) => !grammar.repository?.[name]);
missingIncludes.length === 0
? ok("all local grammar includes resolve")
: bad("all local grammar includes resolve", missingIncludes.join(", "));
grammar.repository?.["conditional-class-single"]
? ok("single-quoted class directives are registered")
: bad("single-quoted class directives are registered");
// 3. Marketplace metadata and the gallery icon meet vsce requirements.
try {
const manifest = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
manifest.publisher === "wrnexus" ? ok("publisher id") : bad("publisher id");
const language = manifest.contributes?.languages?.find((entry) => entry.id === "wrn");
language?.extensions?.includes(".wrn")
? ok(".wrn extension maps to the wrn language")
: bad(".wrn extension maps to the wrn language");
manifest.contributes?.configurationDefaults?.["files.associations"]?.["*.wrn"] === "wrn"
? ok("default file association uses the wrn language id")
: bad("default file association uses the wrn language id");
manifest.activationEvents?.includes("onLanguage:wrn")
? ok("extension activates for the wrn language")
: bad("extension activates for the wrn language");
manifest.activationEvents?.includes("onStartupFinished")
? ok("extension can repair legacy associations at startup")
: bad("extension can repair legacy associations at startup");
language?.firstLine
? ok("first-line language detection is configured")
: bad("first-line language detection is configured");
manifest.icon?.endsWith(".png") ? ok("Marketplace icon is PNG") : bad("Marketplace icon is PNG");
const icon = readFileSync(join(root, manifest.icon));
const isPng = icon.subarray(1, 4).toString("ascii") === "PNG";