* `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)
| 4896 | * getExportedNodesInFile) are left whole. |
| 4897 | */ |
| 4898 | private classExpressionFreeView(base: ResolutionContext): ResolutionContext { |
| 4899 | const { hiddenIds } = this.classExpressions()!; |
| 4900 | const hidden = (n: Node): boolean => hiddenIds.has(n.id); |
| 4901 | const keep = (nodes: Node[]): Node[] => (nodes.some(hidden) ? nodes.filter((n) => !hidden(n)) : nodes); |
| 4902 | const byKind = new Map<Node['kind'], Node[]>(); |
| 4903 | const getMethodMatches = base.getMethodMatches; |
| 4904 | const iterateNodesByKind = base.iterateNodesByKind; |
| 4905 | const { files } = this.classExpressions()!; |
| 4906 | return { |
| 4907 | ...base, |
| 4908 | getNodesByName: (name) => keep(base.getNodesByName(name)), |
| 4909 | getNodesByLowerName: (lowerName) => keep(base.getNodesByLowerName(lowerName)), |
| 4910 | getNodesByQualifiedName: (qualifiedName) => keep(base.getNodesByQualifiedName(qualifiedName)), |
| 4911 | getNodesInFile: (filePath) => (files.has(filePath) ? keep(base.getNodesInFile(filePath)) : base.getNodesInFile(filePath)), |
| 4912 | getNodesByKind: (kind) => { |
| 4913 | let nodes = byKind.get(kind); |
| 4914 | if (!nodes) byKind.set(kind, (nodes = keep(base.getNodesByKind(kind)))); |
| 4915 | return nodes; |
| 4916 | }, |
| 4917 | getMethodMatches: getMethodMatches |
| 4918 | ? (typeName, methodName, language) => keep(getMethodMatches(typeName, methodName, language)) |
| 4919 | : undefined, |
| 4920 | iterateNodesByKind: iterateNodesByKind |
| 4921 | ? function* (kind) { |
| 4922 | for (const n of iterateNodesByKind(kind)) if (!hidden(n)) yield n; |
| 4923 | } |
| 4924 | : undefined, |
| 4925 | }; |
| 4926 | } |
| 4927 | |
| 4928 | /** classExpressionFreeContextFor's views, by the context each hides from and what it hides, and each view's context; clearCaches drops both. */ |
| 4929 | private classExpressionFreeViews = new WeakMap<ResolutionContext, ResolutionContext>(); |
no test coverage detected