kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/typescript/testdata/refcall.ts (about)

     1  /**
     2   * @fileoverview Test to ensure that indexer produces ref/call edges and all data needed for callgraph.
     3   * See https://kythe.io/docs/schema/callgraph.html.
     4   */
     5  
     6  // clang-format off
     7  //- FileInitFunc=vname("fileInit:synthetic", _, _, "testdata/refcall", "typescript").node/kind function
     8  //- FileInitDef defines FileInitFunc
     9  //- FileInitDef.node/kind anchor
    10  //- FileInitDef.loc/start 0
    11  //- FileInitDef.loc/end 0
    12  // clang-format on
    13  
    14  //- @Square defines/binding Square
    15  //- Square.node/kind function
    16  class Square {
    17    //- @getWidth defines/binding GetWidth
    18    getWidth(): number {
    19      return 42;
    20    }
    21  
    22    //- @getArea defines/binding GetArea
    23    getArea() {
    24      //- GetWidthCall=@"this.getWidth()" ref/call GetWidth
    25      //- GetWidthCall childof GetArea
    26      this.getWidth() ** 2;
    27    }
    28  }
    29  
    30  //- @"new Square()" ref/call Square
    31  const square = new Square();
    32  
    33  //- GetAreaCallOne=@"square.getArea()" ref/call GetArea
    34  //- GetAreaCallOne childof FileInitFunc
    35  square.getArea();
    36  
    37  //- @doNothing defines/binding DoNothing
    38  function doNothing() {
    39    //- GetAreaCallTwo=@"square.getArea()" ref/call GetArea
    40    //- GetAreaCallTwo childof DoNothing
    41    square.getArea();
    42  }
    43  
    44  //- DoNothingCall=@"doNothing()" ref/call DoNothing
    45  //- DoNothingCall childof FileInitFunc
    46  doNothing();
    47  
    48  //- GetAreaCallInAnonArrow=@"square.getArea()" ref/call GetArea
    49  //- GetAreaCallInAnonArrow childof AnonArrow
    50  //- AnonArrowCall ref/call AnonArrow
    51  //- AnonArrowCall childof FileInitFunc
    52  (() => square.getArea())();
    53  
    54  //- AnonFunctionCall ref/call AnonFunction
    55  //- AnonFunctionCall childof FileInitFunc
    56  (function() {
    57    //- GetAreaCallInAnonFunction=@"square.getArea()" ref/call GetArea
    58    //- GetAreaCallInAnonFunction childof AnonFunction
    59    square.getArea();
    60  })();