changedCode
Where a scratch file's changed code is: definitions new or changed, leaving out ones re-hashed only because they refer to one that changed and back (a cycle's members are hashed together; a member's IR is as it was, but for the positions it refers to the others by, which a change to one can reorder).
import type { Codebase } from "#codebase/tcmts/cli/codebase"; import { withoutCyclePositions } from "#codebase/tcmts/cli/main"; import type { Row } from "#codebase/tcmts/cli/main"; import type { ProjectDef } from "#codebase/tcmts/core/analyze"; export function changedCode(cb: Codebase, rows: Row[]): { start: number; end: number }[] { return rows .filter( (r) => r.status !== "identical" && r.status !== "doc" && !cb.store .hashesAt(r.path, r.def.kind) .some( (h) => withoutCyclePositions(cb.store.getDef(h)?.ir ?? "") === withoutCyclePositions(r.def.ir), ), ) .flatMap((r) => (r.def as ProjectDef).range ?? []); }
uses
- tcmts.cli.codebase.Codebase
- tcmts.cli.main.Row
- tcmts.cli.main.withoutCyclePositions
- tcmts.core.analyze.ProjectDef