A language's declarations, each read as a pass comes to it: most never are.
| 417 | |
| 418 | /** A language's declarations, each read as a pass comes to it: most never are. */ |
| 419 | class MethodsRead implements FlowMethods { |
| 420 | private readonly read = new Map<string, FlowMethod | undefined>(); |
| 421 | private readonly names = new Map<string, boolean>(); |
| 422 | private readonly scopes = new Map<string, FlowMethod[]>(); |
| 423 | |
| 424 | constructor(private readonly queries: ParameterFlowQueries, private readonly language: Language) {} |
| 425 | |
| 426 | /** Methods already read. */ |
| 427 | know(methods: FlowMethod[]): void { |
| 428 | for (const method of methods) this.read.set(method.id, method); |
| 429 | } |
| 430 | |
| 431 | get(id: string): FlowMethod | undefined { |
| 432 | if (this.read.has(id)) return this.read.get(id); |
| 433 | const node = this.queries.getNodeOutline(id); |
| 434 | const method = node && node.language === this.language && isMethodKind(node.kind) ? node : undefined; |
| 435 | this.read.set(id, method); |
| 436 | return method; |
| 437 | } |
| 438 | |
| 439 | isName(name: string): boolean { |
| 440 | let is = this.names.get(name); |
| 441 | if (is === undefined) this.names.set(name, (is = this.queries.hasMethodNamed(name, this.language))); |
| 442 | return is; |
| 443 | } |
| 444 | |
| 445 | scopesIn(file: string): FlowMethod[] { |
| 446 | let scopes = this.scopes.get(file); |
| 447 | if (!scopes) this.scopes.set(file, (scopes = this.queries.getScopesInFile(file))); |
| 448 | return scopes; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | /** One flow as a record keeps it. */ |
| 453 | interface RecordedFlow { |
nothing calls this directly
no outgoing calls
no test coverage detected