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

Function classOfType

src/ui-server/api/steps.ts:534–544  ·  view source on GitHub ↗
(type: string)

Source from the content-addressed store, hash-verified

532 const classByName = new Map<string, Node | null>();
533 /** The class / interface / struct a declared type names in the index, or null for a library's. */
534 const classOfType = async (type: string): Promise<Node | null> => {
535 const typeName = type.replace(/<.*$/, '').replace(/^[*&]+/, '').replace(/[?!]$/, '').split(/[.:]/).pop()?.trim() ?? '';
536 if (!typeName || /^(?:string|number|boolean|any|unknown|object|void|String|Integer|Long|Boolean|int|long|bool|var|dynamic|Object|List|Map|Set|Array|Promise|Optional|Task|IEnumerable|Iterable)$/.test(typeName)) return null;
537 let cls = classByName.get(typeName);
538 if (cls === undefined) {
539 const found = cg.getNodesByName(typeName).filter((n) => n.kind === 'class' || n.kind === 'interface' || n.kind === 'struct');
540 cls = found.find((n) => !isTestPath(n.filePath)) ?? found[0] ?? null;
541 classByName.set(typeName, cls);
542 }
543 return cls;
544 };
545 // Swift has no per-symbol imports: a type the project declares shadows the
546 // SDK name the effect table keys on — IceCubesApp's `Notifications`
547 // endpoint enum is not expo-notifications. An `extension Timer {}` declares

Callers 2

resolveByReceiverFunction · 0.85
buildStepsFunction · 0.85

Calls 4

isTestPathFunction · 0.90
getMethod · 0.65
getNodesByNameMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected