refactor(views): share Python pyc code-object selection (#16849)

This commit is contained in:
Vincent Koc authored and GitHub committed 2026-12-05 05:55:04 +08:00
1 parent d2342c949d
commit 5c8e144ddf
1 file changed
+9 -18
+9 -18
View File
@@ -1,9 +1,6 @@
import { viewParentIdentity } from "./viewParentIdentity.js";
import { z } from "zod";
import {
pythonPycSchema,
type PythonPycCodeObject,
} from "../python/pythonPyc.js";
import { pythonPycSchema } from "../python/pythonPyc.js";
import { ok } from "../result.js";
import type { AnalysisViewParent } from "./analysisViewParent.js";
import {
@@ -20,6 +17,7 @@ import {
} from "./analysisViewCoverage.js";
import {
filterSet,
matchingViewFields,
pickSourceOrderedFields,
selectViewRows,
} from "./selectViewRows.js";
@@ -93,23 +91,16 @@ export const projectPythonPycView = (
summary,
coverage: completeWithinViewCoverage(code_objects.length),
});
const names = filterSet(view.names);
const indices = filterSet(view.indices);
const fields = new Set<string>(view.fields ?? code.keyof().options);
const projectRow = (row: PythonPycCodeObject, source_index: number) => ({
...pickSourceOrderedFields(row, fields),
source_index,
});
const matches =
names === undefined
? undefined
: (row: PythonPycCodeObject) => names.has(row.name);
const fields = filterSet<string>(view.fields);
const selected = selectViewRows(
code_objects,
view,
matches,
projectRow,
indices,
matchingViewFields([["name", view.names]]),
(row, source_index) => ({
...(fields === undefined ? row : pickSourceOrderedFields(row, fields)),
source_index,
}),
filterSet(view.indices),
);
return ok({
...shared,