Lines 19–25 at 143 (were 19–25 at 142)
1919// A use means a definition only through an import of it, or in the file 2020// that defines it (project.ts, #definitionCore). 22−import type { LineId, View } from "../../src/engine/index.ts";
22+import type { LineId, ReadView } from "../../src/engine/index.ts"; 2323import { codeOfLines, holdsNoCode, isCommonName } from "./names.ts"; 2525export interface Definition { Lines 90–102 at 143 (were 90–102 at 142)
9090const TOP_ASSIGN = new RegExp(`^(${NAME})\\s*(?::[^=]*)?=(?![=>])`); 9191const MAX_HEADER = 30; 93−const cache = new WeakMap<View, Map<string, readonly Definition[]>>();
93+const cache = new WeakMap<ReadView, Map<string, readonly Definition[]>>(); 9696 * Every definition in the view's code files (or only in `files`), by name. 9797 * Each file's definitions are cached per view. 99−export function definitionsIn(view: View, files?: Iterable<string>): Map<string, Definition[]> {
99+export function definitionsIn(view: ReadView, files?: Iterable<string>): Map<string, Definition[]> { 100100 let perFile = cache.get(view); 102102 perFile = new Map(); Lines 118–124 at 143 (were 118–124 at 142)
121−function definitionsInFile(view: View, file: string, keepCommon = false): Definition[] {
121+function definitionsInFile(view: ReadView, file: string, keepCommon = false): Definition[] { 122122 if (holdsNoCode(file) || !view.hasFile(file)) return []; 123123 const out: Definition[] = []; 124124 const visible = view.lines(file); Lines 149–155 at 143 (were 149–155 at 142)
149149 * included (two `parse` functions in a file are a mistake whatever the name). 150150 * Each spans its whole block, body and all, for showing to the agent. 152−export function definedTwice(view: View, file: string): Map<string, Definition[]> {
152+export function definedTwice(view: ReadView, file: string): Map<string, Definition[]> { 153153 const out = new Map<string, Definition[]>(); 154154 const all = definitionsInFile(view, file, true); 155155 const count = new Map<string, number>(); Lines 306–312 at 143 (were 306–312 at 142)
309−const importCache = new WeakMap<View, Map<string, ReadonlyMap<string, string>>>();
309+const importCache = new WeakMap<ReadView, Map<string, ReadonlyMap<string, string>>>(); 312312 * Names a file imports by name, and the project file each comes from, when Lines 316–322 at 143 (were 316–322 at 142)
316316 * x.y import a, b`. Lets a use of a name be matched to the definition it 317317 * means instead of every definition with that name. 319−export function importsOf(view: View, file: string): ReadonlyMap<string, string> {
319+export function importsOf(view: ReadView, file: string): ReadonlyMap<string, string> { 320320 let perFile = importCache.get(view); 322322 perFile = new Map(); Lines 367–373 at 143 (were 367–373 at 142)
367367 return parts.join("/"); 370−function resolveModule(view: View, from: string, spec: string): string | undefined {
370+function resolveModule(view: ReadView, from: string, spec: string): string | undefined { 371371 if (!spec.startsWith(".")) return undefined; 372372 const base = joinPath(dirOf(from), spec); 373373 const stem = base.replace(/\.(?:js|mjs|cjs|jsx)$/, ""); Lines 385–391 at 143 (were 385–391 at 142)
388−function resolvePython(view: View, from: string, spec: string): string | undefined {
388+function resolvePython(view: ReadView, from: string, spec: string): string | undefined { 389389 const dots = /^\.*/.exec(spec)![0].length; 390390 const rest = spec.slice(dots).replace(/\./g, "/"); 391391 let dir = dots > 0 ? dirOf(from) : "";