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

Function directive

src/ui-server/api/when.ts:256–272  ·  view source on GitHub ↗
(definition)

Source from the content-addressed store, hash-verified

254 return returnsForFile(file.abs, file.language, definition.startLine);
255 },
256 async directive(definition) {
257 // Not counted: a text read, cached per file, no tree.
258 const none = { file: null, own: false } as const;
259 if (!JS_FAMILY.has(definition.language)) return none;
260 const file = resolve(definition);
261 if (!file) return none;
262 const text = readText(file.abs);
263 if (text === null) return none;
264 const head = FILE_DIRECTIVE.exec(text);
265 const fileDirective = head ? (head[2] as 'server' | 'client') : null;
266 let own = false;
267 if (definition.startLine > 0) {
268 const lines = text.split('\n');
269 own = OWN_DIRECTIVE.test(lines.slice(definition.startLine - 1, definition.startLine + 3).join('\n'));
270 }
271 return { file: fileDirective, own };
272 },
273 async swiftExtension(definition) {
274 if (definition.language !== 'swift' || definition.kind !== 'class') return false;
275 const file = resolve(definition);

Callers

nothing calls this directly

Calls 5

hasMethod · 0.80
resolveFunction · 0.70
readTextFunction · 0.70
execMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected