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

Function methodOf

src/resolution/frameworks/drupal.ts:666–683  ·  view source on GitHub ↗

A method by name on a class, its own or an inherited one.

(cls: Node, name: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

664
665/** A method by name on a class, its own or an inherited one. */
666function methodOf(cls: Node, name: string, context: ResolutionContext): Node | undefined {
667 const seen = new Set<string>();
668 let level: Node[] = [cls];
669 for (let depth = 0; depth < 6 && level.length > 0; depth++) {
670 const next: Node[] = [];
671 for (const type of level) {
672 if (seen.has(type.id)) continue;
673 seen.add(type.id);
674 const own = context.getNodesInFile(type.filePath).find(
675 (n) => n.kind === 'method' && n.name === name && n.qualifiedName.startsWith(`${type.qualifiedName}::`)
676 );
677 if (own) return own;
678 next.push(...(context.getSupertypeNodes?.(type.id) ?? []));
679 }
680 level = next;
681 }
682 return undefined;
683}
684
685/** The service the `\Drupal::service('x')->method()` on this reference's line asks for. */
686function serviceOnLine(ref: UnresolvedRef, method: string, context: ResolutionContext): string | null {

Callers 1

resolveFunction · 0.70

Calls 5

hasMethod · 0.80
pushMethod · 0.80
getSupertypeNodesMethod · 0.80
getNodesInFileMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected