| 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); |