Angular Modernizer
    Preparing search index...

    Builds caller/callee graphs for methods, functions, constructors, accessors and arrow-function properties across a ts-morph Project. Traverses upward (callers) and downward (callees) with configurable depth.

    Supported targets (and graph nodes):

    • class methods and top-level functions
    • constructors ('constructor' or 'ClassName.constructor'); a class without an explicit constructor is represented by its field initializers
    • get/set accessors
    • properties and top-level variables initialized with an arrow function or function expression

    Callees include:

    • call expressions (resolved via the type checker, name-based fallback only when the symbol cannot be resolved)
    • new X() (edge to X's constructor, including X's field initializers)
    • super(...) (edge to the base class constructor)
    • property reads/writes that resolve to a getter/setter
    • for constructors: instance field initializers (they run during construction)

    Callers are the enclosing callable of each reference: method, function, constructor, accessor, arrow-function property, or (for references in a field initializer) the owning class constructor. Callers of a constructor are the new X() sites and the constructors of subclasses.

    Template callers: for members of an Angular component, the component's own template (inline or templateUrl) is scanned for calls of the member ((click)="save()", {{ label() }}, [x]="compute()"; getters as reads, setters as writes). Each hit becomes a leaf node with kind 'template', the template file and line and the source line as snippet. Templates of subclasses (all levels) count as well, with className of the subclass and inheritedFrom of the declaring class; a subclass overriding a concrete member takes itself and its descendants out (their templates call the override). Implementations of an abstract member do not.

    Traversal limits:

    • maxNodes (default 200) caps the number of nodes across both trees; when hit, traversal stops and the result carries truncated: true.
    • Unless includeLifecycleHooks is set, the upward traversal does not fan out over polymorphic siblings: declaration sites of other implementations are not callers, and callers of an Angular lifecycle hook or implements-interface member are limited to the owning class and its subclasses. Without this, findReferences on ngOnInit resolves through OnInit to every ngOnInit in the program.

    Used in bug investigation to understand how an error propagates through the codebase. Combine with UsageFinder to trace the full call path from the entry point to the failing code, e.g. "what runs transitively while an interceptor is constructed" (ctor -> helper getter -> static config read).

    const builder = new CallGraphBuilder(project);
    const graph = builder.buildCallGraph('getUser', '/src/app/user.service.ts', {
    direction: 'both',
    depth: 2,
    });
    // graph.callers -> who calls getUser
    // graph.callees -> what getUser calls

    const ctorGraph = builder.buildCallGraph(
    'AuthInterceptor.constructor',
    '/src/app/auth.interceptor.ts',
    { direction: 'down', depth: 3 },
    );
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Builds a call graph rooted at the named callable.

      Parameters

      • method: string

        Name of the callable to analyse. Accepts a method, function, accessor or arrow-function property name, 'constructor', or a class-qualified name such as 'AuthInterceptor.constructor' or 'AuthInterceptor.headers'.

      • file: string

        Absolute path of the source file containing the callable.

      • options: CallGraphOptions = {}

        Traversal direction, depth and limits. Defaults to both / depth 2 / maxNodes 200 / lifecycle hooks excluded.

      Returns CallGraphResult

      A CallGraphResult with the target and its caller/callee trees.