MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / lookupModuleNode

Function lookupModuleNode

graph-ui/src/reader/file-source.ts:106–130  ·  view source on GitHub ↗

* Der Modul-Knoten dieser Datei, beim Graphen nachgefragt. * * Zuerst das Modul-Label, weil nur der Modul-Knoten eine Zeilenspanne mitbringt. * Wenn es keinen gibt, der File-Knoten: aus seinem Namen laesst sich der des * Moduls zurueckrechnen, aber eine Spanne kommt nicht mit, und dann weiss der

(
    client: RpcIntelligenceClient,
    project: string,
    path: string,
)

Source from the content-addressed store, hash-verified

104 * Reader spaeter nicht, wie lang die Datei wirklich ist.
105 */
106async function lookupModuleNode(
107 client: RpcIntelligenceClient,
108 project: string,
109 path: string,
110): Promise<{ qualifiedName: string; source: QnSource; endLine?: number } | undefined> {
111 const moduleRows = await client.queryRows(project, moduleForFile(path));
112 const moduleRow = moduleRows[0];
113 if (moduleRow !== undefined) {
114 const qualifiedName = moduleRow[COLUMNS.moduleForFile[0]] ?? '';
115 if (qualifiedName.length > 0) {
116 const endLine = toOptionalNumber(moduleRow[COLUMNS.moduleForFile[2]]);
117 return endLine === undefined
118 ? { qualifiedName, source: 'graph-module' }
119 : { qualifiedName, source: 'graph-module', endLine };
120 }
121 }
122
123 const fileRows = await client.queryRows(project, fileNodeForPath(path));
124 const fileQualifiedName = fileRows[0]?.[COLUMNS.fileNode[0]] ?? '';
125 if (fileQualifiedName.length === 0) {
126 return undefined;
127 }
128 const derived = moduleQnFromFileQn(fileQualifiedName);
129 return derived === undefined ? undefined : { qualifiedName: derived, source: 'graph-file' };
130}
131
132/** What the server writes in place of source when it cannot read the file. */
133export const SOURCE_UNAVAILABLE = '(source not available)';

Callers 1

loadFileDocumentFunction · 0.85

Calls 5

moduleForFileFunction · 0.90
fileNodeForPathFunction · 0.90
moduleQnFromFileQnFunction · 0.90
toOptionalNumberFunction · 0.70
queryRowsMethod · 0.65

Tested by

no test coverage detected