MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / ResolutionContext

Interface ResolutionContext

src/resolution/types.ts:95–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93 * Context for resolution - provides access to the graph
94 */
95export interface ResolutionContext {
96 /** Get all nodes in a file */
97 getNodesInFile(filePath: string): Node[];
98 /** Whether any node in the file is exported (`getNodesInFile(f).some(n => n.isExported)`), as one indexed probe. */
99 fileHasExportedNode?(filePath: string): boolean;
100 /** `getNodesInFile(f).filter(n => n.isExported)`, without decoding the rest of the file. */
101 getExportedNodesInFile?(filePath: string): Node[];
102 /** `getNodesInFile(f).filter(n => n.name === name)`, without decoding the rest of the file. */
103 getNodesInFileNamed?(filePath: string, name: string): Node[];
104 /** Get all nodes by name */
105 getNodesByName(name: string): Node[];
106 /**
107 * Whether no node in the index has exactly this name, answered from the
108 * resolver's set of every node name rather than a query (#2829). False
109 * whenever that set isn't loaded (before `warmCaches`, after
110 * `clearCaches`), so a caller only ever acts on a certain absence. A view
111 * that hides nodes keeps its base's answer, which stays certain: hiding
112 * nodes adds no name. Optional: a context without it never answers.
113 */
114 isAbsentName?(name: string): boolean;
115 /** Get all nodes by qualified name */
116 getNodesByQualifiedName(qualifiedName: string): Node[];
117 /** Get all nodes of a kind */
118 getNodesByKind(kind: Node['kind']): Node[];
119 /**
120 * Stream nodes of a kind one at a time instead of materializing (and, unlike
121 * `getNodesByKind`, without populating the resolver's per-kind array cache).
122 * For unbounded kinds (`function`, `method`, `struct`) on a symbol-dense
123 * project the full array is gigabytes — the dynamic-edge synthesizers must
124 * use this so their memory stays O(1) in node count (#610, #1212). Optional
125 * so minimal test contexts compile; callers fall back to getNodesByKind.
126 */
127 iterateNodesByKind?(kind: Node['kind']): IterableIterator<Node>;
128 /** Check if a file exists */
129 fileExists(filePath: string): boolean;
130 /** Read file content */
131 readFile(filePath: string): string | null;
132 /** Record a project-relative file resolution read its answer from, for sync to watch (see `getModuleConfigSnapshot`). */
133 noteModuleConfigFile?(filePath: string): void;
134 /** `readFile(filePath)?.includes(needle) ?? false` for an ASCII `needle`, without decoding a file that lacks it. */
135 fileContains?(filePath: string, needle: string): boolean;
136 /**
137 * An indexed file's text for a walk over all of them, which keeps none: it
138 * stays out of the content cache, and each byte is a character, so anything
139 * outside ASCII reads wrongly. Null when the file can't be read.
140 */
141 scanFile?(filePath: string): string | null;
142 /**
143 * `readFile(filePath)` split into lines, LRU-cached per file. Receiver-type
144 * inference scans source lines for EVERY `receiver.method()` ref; splitting
145 * the whole file per ref made that O(refs-in-file × file-size) — ~20% of
146 * total index CPU on a Java-heavy repo and a driver of the #1122 watchdog
147 * kill on large ones. Optional so external/test contexts compile without it;
148 * callers fall back to splitting `readFile` themselves.
149 */
150 getFileLines?(filePath: string): string[] | null;
151 /**
152 * The method-definition nodes matching `typeName::methodName` in the language family —

Callers 180

getFileExportIndexFunction · 0.65
nodesInFileNamedFunction · 0.65
pythonModuleOfScriptFunction · 0.65
pythonModuleFileNodeFunction · 0.65
resolveJvmImportFunction · 0.65
phpOwnMethodsFunction · 0.65
declarationsInFunction · 0.65
createContextMethod · 0.65
getFileExportIndexFunction · 0.80
nodesInFileNamedFunction · 0.80
declarationsInFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected