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

Function resolveRequestedFile

src/ui-server/api/source.ts:111–125  ·  view source on GitHub ↗
(
  cg: CodeGraph,
  projectRoot: string,
  requested: string
)

Source from the content-addressed store, hash-verified

109 * @throws {ApiError} `not-found` when it is fine but not in the index.
110 */
111export function resolveRequestedFile(
112 cg: CodeGraph,
113 projectRoot: string,
114 requested: string
115): { record: FileRecord; storedPath: string; absolute: string } {
116 const posix = toRequestPath(requested);
117 // Refusals happen here, ahead of everything. The read and the index lookup
118 // below use the same string, so a `%` in a file's name means the same file
119 // to both (#2009).
120 const absolute = resolveProjectFile(projectRoot, posix);
121
122 const found = findIndexedFile(cg, posix);
123 if (!found) throw notIndexedError(posix);
124 return { ...found, absolute };
125}
126
127export function notIndexedError(file: string): ApiError {
128 return notFound(

Callers 3

buildFileFunction · 0.90
buildFileCodeFunction · 0.90
buildSourceFunction · 0.85

Calls 4

resolveProjectFileFunction · 0.90
toRequestPathFunction · 0.85
findIndexedFileFunction · 0.85
notIndexedErrorFunction · 0.85

Tested by

no test coverage detected