* A Scala def's value parameters, every curried list: `def f[A](fa: F[A])(f: * A => B)(implicit G: Applicative[G])` → fa, f, G.
(node: Node, context: ResolutionContext)
| 221 | * A => B)(implicit G: Applicative[G])` → fa, f, G. |
| 222 | */ |
| 223 | function declaredValueParameters(node: Node, context: ResolutionContext): ReadonlySet<string> { |
| 224 | let memo = valueMemos.get(context); |
| 225 | if (!memo) { |
| 226 | memo = new Map(); |
| 227 | valueMemos.set(context, memo); |
| 228 | } |
| 229 | const hit = memo.get(node.id); |
| 230 | if (hit) return hit; |
| 231 | const names = new Set<string>(); |
| 232 | const lines = context.getFileLines?.(node.filePath) ?? context.readFile(node.filePath)?.split(/\r?\n/) ?? null; |
| 233 | if (lines) { |
| 234 | const head = lines.slice(node.startLine - 1, Math.min(node.endLine, node.startLine - 1 + HEAD_LINES)).join('\n'); |
| 235 | const at = nameIndex(head, node.name); |
| 236 | if (at >= 0) { |
| 237 | let i = at + node.name.length; |
| 238 | const skipSpace = (): void => { |
| 239 | while (i < head.length && /\s/.test(head[i]!)) i++; |
| 240 | }; |
| 241 | skipSpace(); |
| 242 | if (head[i] === '[') { |
| 243 | const close = matchingBracket(head, i); |
| 244 | i = close < 0 ? head.length : close + 1; |
| 245 | } |
| 246 | for (skipSpace(); head[i] === '('; skipSpace()) { |
| 247 | const close = matchingBracket(head, i); |
| 248 | if (close < 0) break; |
| 249 | for (const item of splitTopLevel(head.slice(i + 1, close), false)) { |
| 250 | const bare = item.replace(/^\s*(?:@[\w.]+(?:\([^()]*\))?\s*)+/, ''); |
| 251 | const param = /^\s*(?:(?:implicit|using|val|var|override|private|protected|final|inline|erased)\s+)*([A-Za-z_]\w*)\s*:/.exec(bare)?.[1]; |
| 252 | if (param) names.add(param); |
| 253 | } |
| 254 | i = close + 1; |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | memo.set(node.id, names); |
| 259 | return names; |
| 260 | } |
| 261 | |
| 262 | /** |
| 263 | * The declared name's position in its head: the whole word, past attributes |
no test coverage detected