refactor(oc-path): drop unused repack helper

This commit is contained in:
Vincent Koc
2026-06-20 01:32:12 +08:00
parent 8aa58c5fb0
commit d41a3d28a0
2 changed files with 2 additions and 27 deletions

View File

@@ -65,7 +65,7 @@ export {
// `evaluatePredicate`, `getPathLayout`, `parseOrdinalSeg`,
// `parsePredicateSeg`, `parseUnionSeg`, `quoteSeg`, `unquoteSeg`,
// `repackPath`, `resolvePositionalSeg`, `splitRespectingBrackets`
// `resolvePositionalSeg`, `splitRespectingBrackets`
// were exported from earlier prototypes. They're substrate-internal
// helpers — used by `find.ts`, the per-kind resolvers, and the parser
// itself, but not part of the upstream-portable public surface.

View File

@@ -546,7 +546,7 @@ export interface PathSegmentLayout {
export function getPathLayout(path: OcPath): PathSegmentLayout {
// Quote-aware split — `.split('.')` would shred a quoted segment
// containing a literal `.` (e.g. `"a.b"`) and break repackPath.
// containing a literal `.` (e.g. `"a.b"`).
const sectionSubs = path.section === undefined ? [] : splitRespectingBrackets(path.section, ".");
const itemSubs = path.item === undefined ? [] : splitRespectingBrackets(path.item, ".");
const fieldSubs = path.field === undefined ? [] : splitRespectingBrackets(path.field, ".");
@@ -558,31 +558,6 @@ export function getPathLayout(path: OcPath): PathSegmentLayout {
};
}
/**
* Re-pack a concrete sub-segment list into an `OcPath` preserving the
* pattern's slot boundaries. Throws on length mismatch.
*/
export function repackPath(pattern: OcPath, subs: readonly string[]): OcPath {
const layout = getPathLayout(pattern);
if (subs.length !== layout.subs.length) {
fail(
`repack length mismatch: pattern has ${layout.subs.length} sub-segments, got ${subs.length}`,
formatOcPath(pattern),
"OC_PATH_REPACK_LENGTH",
);
}
const sectionSubs = subs.slice(0, layout.sectionLen);
const itemSubs = subs.slice(layout.sectionLen, layout.sectionLen + layout.itemLen);
const fieldSubs = subs.slice(layout.sectionLen + layout.itemLen);
return {
file: pattern.file,
...(sectionSubs.length > 0 ? { section: sectionSubs.join(".") } : {}),
...(itemSubs.length > 0 ? { item: itemSubs.join(".") } : {}),
...(fieldSubs.length > 0 ? { field: fieldSubs.join(".") } : {}),
...(pattern.session !== undefined ? { session: pattern.session } : {}),
};
}
function extractSession(queryPart: string, input: string): string | undefined {
if (queryPart.length === 0) {
return undefined;