-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcontext.ts
More file actions
85 lines (77 loc) · 2.97 KB
/
context.ts
File metadata and controls
85 lines (77 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* PipelineContext — shared mutable state threaded through all build stages.
*
* Each stage reads what it needs and writes what it produces.
* This replaces the closure-captured locals in the old monolithic buildGraph().
*/
import type {
BetterSqlite3Database,
BuildGraphOpts,
CodegraphConfig,
EngineOpts,
ExtractorOutput,
FileToParse,
MetadataUpdate,
NativeDatabase,
NodeRow,
ParseChange,
PathAliases,
} from '../../../types.js';
export class PipelineContext {
// ── Inputs (set during setup) ──────────────────────────────────────
rootDir!: string;
db!: BetterSqlite3Database;
dbPath!: string;
config!: CodegraphConfig;
opts!: BuildGraphOpts;
engineOpts!: EngineOpts;
engineName!: 'native' | 'wasm';
engineVersion!: string | null;
aliases!: PathAliases;
incremental!: boolean;
forceFullRebuild: boolean = false;
schemaVersion!: number;
nativeDb?: NativeDatabase;
/** Whether native engine is available (deferred — DB opened only when needed). */
nativeAvailable: boolean = false;
// ── File collection (set by collectFiles stage) ────────────────────
allFiles!: string[];
discoveredDirs!: Set<string>;
// ── Change detection (set by detectChanges stage) ──────────────────
isFullBuild!: boolean;
parseChanges!: ParseChange[];
metadataUpdates!: MetadataUpdate[];
removed!: string[];
earlyExit: boolean = false;
// ── Parsing (set by parseFiles stage) ──────────────────────────────
allSymbols!: Map<string, ExtractorOutput>;
fileSymbols!: Map<string, ExtractorOutput>;
filesToParse!: FileToParse[];
// ── Import resolution (set by resolveImports stage) ────────────────
batchResolved!: Map<string, string> | null;
reexportMap!: Map<string, unknown[]>;
barrelOnlyFiles!: Set<string>;
// ── Node lookup (set by insertNodes / buildEdges stages) ───────────
nodesByName!: Map<string, NodeRow[]>;
nodesByNameAndFile!: Map<string, NodeRow[]>;
// ── Misc state ─────────────────────────────────────────────────────
hasEmbeddings: boolean = false;
lineCountMap!: Map<string, number>;
// ── Phase timing ───────────────────────────────────────────────────
timing: {
setupMs?: number;
parseMs?: number;
insertMs?: number;
resolveMs?: number;
edgesMs?: number;
structureMs?: number;
rolesMs?: number;
astMs?: number;
complexityMs?: number;
cfgMs?: number;
dataflowMs?: number;
finalizeMs?: number;
[key: string]: number | undefined;
} = {};
buildStart!: number;
}