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

Function methodOf

src/resolution/frameworks/drupal.ts:665–682  ·  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

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