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

Function directive

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

Source from the content-addressed store, hash-verified

227 return memberTypesForFile(file.abs, file.language, definition.startLine);
228 },
229 async directive(definition) {
230 // Not counted: a text read, cached per file, no tree.
231 const none = { file: null, own: false } as const;
232 if (!JS_FAMILY.has(definition.language)) return none;
233 const file = resolve(definition);
234 if (!file) return none;
235 let text = texts.get(file.abs);
236 if (text === undefined) {
237 try {
238 text = fs.statSync(file.abs).size <= MAX_DIRECTIVE_FILE ? fs.readFileSync(file.abs, 'utf8') : null;
239 } catch {
240 text = null;
241 }
242 texts.set(file.abs, text);
243 }
244 if (text === null) return none;
245 const head = FILE_DIRECTIVE.exec(text);
246 const fileDirective = head ? (head[2] as 'server' | 'client') : null;
247 let own = false;
248 if (definition.startLine > 0) {
249 const lines = text.split('\n');
250 own = OWN_DIRECTIVE.test(lines.slice(definition.startLine - 1, definition.startLine + 3).join('\n'));
251 }
252 return { file: fileDirective, own };
253 },
254 };
255}
256

Callers

nothing calls this directly

Calls 6

hasMethod · 0.80
resolveFunction · 0.70
getMethod · 0.65
execMethod · 0.65
setMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected