The editor layer
The VSCode extension is thin wiring over this same core; the decisions and formatting it needs live in a logic.ts kept free of the editor API so they are unit-testable. The status-bar summary, for instance:
export function statusText(report: Report | null, level: GateLevel = 'strict'): string {
if (!report) return 'docref';
const s = report.summary;
const stale = s.staleSnippet + s.staleClaim;
const broken = s.broken + report.errors.length;
const suffix = level === 'strict' ? '' : ` · ${level}`;
if (broken > 0) {
const parts = [];
if (s.broken) parts.push(`${s.broken} broken`);
if (report.errors.length) parts.push(`${report.errors.length} error${report.errors.length === 1 ? '' : 's'}`);
if (stale) parts.push(`${stale} stale`);
// advisory never fails, so the count is shown without the alarming error glyph
const glyph = level === 'advisory' ? '$(info)' : '$(error)';
return `docref ${glyph} ${parts.join(', ')}${suffix}`;
}
if (stale > 0) return `docref $(warning) ${stale} stale${suffix}`;
if (report.unusedAnchors.length > 0) {
return `docref $(warning) ${report.unusedAnchors.length} unused${suffix}`;
}
return `docref $(check) ${s.upToDate}${suffix}`;
}
"Create anchor" picks a comment leader by language; an unknown language falls back to a quick-pick in the extension layer.
export function commentLeaderFor(languageId: string): Leader | null {
const line = LINE_LEADERS[languageId];
if (line) return { kind: 'line', open: line };
const block = BLOCK_LEADERS[languageId];
if (block) return { kind: 'block', open: block[0], close: block[1] };
return null;
}