MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / classExpressionFreeView

Method classExpressionFreeView

src/resolution/index.ts:4817–4845  ·  view source on GitHub ↗

* `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)

Source from the content-addressed store, hash-verified

4815 * getExportedNodesInFile) are left whole.
4816 */
4817 private classExpressionFreeView(base: ResolutionContext): ResolutionContext {
4818 const { hiddenIds } = this.classExpressions()!;
4819 const hidden = (n: Node): boolean => hiddenIds.has(n.id);
4820 const keep = (nodes: Node[]): Node[] => (nodes.some(hidden) ? nodes.filter((n) => !hidden(n)) : nodes);
4821 const byKind = new Map<Node['kind'], Node[]>();
4822 const getMethodMatches = base.getMethodMatches;
4823 const iterateNodesByKind = base.iterateNodesByKind;
4824 const { files } = this.classExpressions()!;
4825 return {
4826 ...base,
4827 getNodesByName: (name) => keep(base.getNodesByName(name)),
4828 getNodesByLowerName: (lowerName) => keep(base.getNodesByLowerName(lowerName)),
4829 getNodesByQualifiedName: (qualifiedName) => keep(base.getNodesByQualifiedName(qualifiedName)),
4830 getNodesInFile: (filePath) => (files.has(filePath) ? keep(base.getNodesInFile(filePath)) : base.getNodesInFile(filePath)),
4831 getNodesByKind: (kind) => {
4832 let nodes = byKind.get(kind);
4833 if (!nodes) byKind.set(kind, (nodes = keep(base.getNodesByKind(kind))));
4834 return nodes;
4835 },
4836 getMethodMatches: getMethodMatches
4837 ? (typeName, methodName, language) => keep(getMethodMatches(typeName, methodName, language))
4838 : undefined,
4839 iterateNodesByKind: iterateNodesByKind
4840 ? function* (kind) {
4841 for (const n of iterateNodesByKind(kind)) if (!hidden(n)) yield n;
4842 }
4843 : undefined,
4844 };
4845 }
4846
4847 /** classExpressionFreeContextFor's views, by the context each hides from and what it hides, and each view's context; clearCaches drops both. */
4848 private classExpressionFreeViews = new WeakMap<ResolutionContext, ResolutionContext>();

Callers 1

Calls 11

classExpressionsMethod · 0.95
hasMethod · 0.80
hiddenFunction · 0.70
getNodesByNameMethod · 0.65
getNodesByLowerNameMethod · 0.65
getNodesInFileMethod · 0.65
getMethod · 0.65
getNodesByKindMethod · 0.65
keepFunction · 0.50
setMethod · 0.45

Tested by

no test coverage detected