private _checkOverrideCallsSuper()

in src/tslint/overrideCallsSuperRule.ts [44:77]


    private _checkOverrideCallsSuper(node: ts.MethodDeclaration, methodName: string): void {
        // Must have a call to super (for the same method name) in the top-level list of statements.
        let hasSuperCall = false;
        if (node.body) {
            hasSuperCall = node.body.statements.some(statement => {
                if (statement.kind !== ts.SyntaxKind.ExpressionStatement) {
                    return false;
                }
                const expressionStatement = statement as ts.ExpressionStatement;
                if (expressionStatement.expression.kind !== ts.SyntaxKind.CallExpression) {
                    return false;
                }
                const callExpression = expressionStatement.expression as ts.CallExpression;
                if (callExpression.expression.kind !== ts.SyntaxKind.PropertyAccessExpression) {
                    return false;
                }
                const propertyAccessExpression = callExpression.expression as ts.PropertyAccessExpression;
                if (propertyAccessExpression.expression.kind !== ts.SyntaxKind.SuperKeyword) {
                    return false;
                }
                return this._hasSuperCallForSameMethodName(callExpression, methodName);
            });
        }

        if (!hasSuperCall) {
            // If it had a super call for the same method but not at the top level, then give a more specific warning.
            const failureTemplate = this._hasSuperCallForSameMethodName(node, methodName)
                ? MISSING_TOP_LEVEL_SUPER_CALL
                : MISSING_SUPER_CALL;
            const failureString = failureTemplate.replace(/%/g, methodName);
            // Create a failure at the current position.
            this.addFailure(this.createFailure(node.getStart(), node.getWidth(), failureString));
        }
    }