refactor: unify declare block scanning between CLI and client
Introduce `scanDeclareBlocks` in `declare-parser.ts` to provide a single source of truth for parsing `role=declare` blocks. This replaces redundant scanning logic in both the CLI and the journal completions. Also remove unused `dice.ts` and `spark-scanner.ts` files.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
import { posix } from "path";
|
||||
import { createHash } from "crypto";
|
||||
import { parseDeclareCsv, type VarDeclaration, type TagModifier } from "./declare-parser.js";
|
||||
import { scanDeclareBlocks, type VarDeclaration, type TagModifier } from "./declare-parser.js";
|
||||
import {
|
||||
FENCED_BLOCK_RE,
|
||||
parseBlockAttrs,
|
||||
@@ -86,13 +86,9 @@ export function processBlocks(
|
||||
// ---- Dispatch by role ----
|
||||
|
||||
if (attrs.role === "declare") {
|
||||
try {
|
||||
const result = parseDeclareCsv(body, fileRelativePath);
|
||||
blocks.declarations.push(...result.variables);
|
||||
blocks.tagModifiers.push(...result.tagModifiers);
|
||||
} catch (e) {
|
||||
console.warn(`[block-processor] ${fileRelativePath}: ${e}`);
|
||||
}
|
||||
const result = scanDeclareBlocks(_match, fileRelativePath);
|
||||
blocks.declarations.push(...result.variables);
|
||||
blocks.tagModifiers.push(...result.tagModifiers);
|
||||
}
|
||||
|
||||
if (attrs.role === "file") {
|
||||
|
||||
Reference in New Issue
Block a user