private getStatementsForDeclaration()

in src/transforms/deprecation-warnings.ts [469:497]


  private getStatementsForDeclaration(
    node: ts.MethodDeclaration | ts.GetAccessorDeclaration | ts.SetAccessorDeclaration | ts.ConstructorDeclaration,
  ): ts.Statement[] {
    const klass = node.parent;
    const classSymbolId = symbolIdentifier(this.typeChecker, this.typeChecker.getTypeAtLocation(klass).symbol);
    if (classSymbolId && this.typeIndex.has(classSymbolId)) {
      const classType = this.typeIndex.get(classSymbolId)! as spec.ClassType;

      if (ts.isConstructorDeclaration(node)) {
        const initializer = classType?.initializer;
        if (initializer) {
          return this.getStatements(classType, initializer);
        }
      }

      const methods = classType?.methods ?? [];
      const method = methods.find((m) => m.name === node.name?.getText());
      if (method) {
        return this.getStatements(classType, method);
      }

      const properties = classType?.properties ?? [];
      const property = properties.find((p) => p.name === node.name?.getText());
      if (property) {
        return createWarningStatementForElement(property, classType);
      }
    }
    return [];
  }