* `base` without the classes class expressions declare and their members. * The lookups an import reads a module's exports by (getNodesInFileNamed, * getExportedNodesInFile) are left whole.
(base: ResolutionContext)
| 4586 | * getExportedNodesInFile) are left whole. |
| 4587 | */ |
| 4588 | private classExpressionFreeView(base: ResolutionContext): ResolutionContext { |
| 4589 | const { hiddenIds } = this.classExpressions()!; |
| 4590 | const hidden = (n: Node): boolean => hiddenIds.has(n.id); |
| 4591 | const keep = (nodes: Node[]): Node[] => (nodes.some(hidden) ? nodes.filter((n) => !hidden(n)) : nodes); |
| 4592 | const byKind = new Map<Node['kind'], Node[]>(); |
| 4593 | const getMethodMatches = base.getMethodMatches; |
| 4594 | const iterateNodesByKind = base.iterateNodesByKind; |
| 4595 | const { files } = this.classExpressions()!; |
| 4596 | return { |
| 4597 | ...base, |
| 4598 | getNodesByName: (name) => keep(base.getNodesByName(name)), |
| 4599 | getNodesByLowerName: (lowerName) => keep(base.getNodesByLowerName(lowerName)), |
| 4600 | getNodesByQualifiedName: (qualifiedName) => keep(base.getNodesByQualifiedName(qualifiedName)), |
| 4601 | getNodesInFile: (filePath) => (files.has(filePath) ? keep(base.getNodesInFile(filePath)) : base.getNodesInFile(filePath)), |
| 4602 | getNodesByKind: (kind) => { |
| 4603 | let nodes = byKind.get(kind); |
| 4604 | if (!nodes) byKind.set(kind, (nodes = keep(base.getNodesByKind(kind)))); |
| 4605 | return nodes; |
| 4606 | }, |
| 4607 | getMethodMatches: getMethodMatches |
| 4608 | ? (typeName, methodName, language) => keep(getMethodMatches(typeName, methodName, language)) |
| 4609 | : undefined, |
| 4610 | iterateNodesByKind: iterateNodesByKind |
| 4611 | ? function* (kind) { |
| 4612 | for (const n of iterateNodesByKind(kind)) if (!hidden(n)) yield n; |
| 4613 | } |
| 4614 | : undefined, |
| 4615 | }; |
| 4616 | } |
| 4617 | |
| 4618 | /** classExpressionFreeContextFor's views, by the context each hides from and what it hides, and each view's context; clearCaches drops both. */ |
| 4619 | private classExpressionFreeViews = new WeakMap<ResolutionContext, ResolutionContext>(); |
no test coverage detected