From 49b65c749fc291dfb22b997820ce0c369ad40c43 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Fri, 9 Sep 2016 14:30:28 -0700 Subject: [PATCH] PR feedback --- src/services/codefixes/superFixes.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index d06ba9df955..622ded06d31 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -10,7 +10,10 @@ namespace ts.codefix { getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); - Debug.assert(token.kind === SyntaxKind.ConstructorKeyword, "Failed to find the constructor."); + + if (token.kind !== SyntaxKind.ConstructorKeyword) { + return undefined; + } const newPosition = getOpenBraceEnd(token.parent, sourceFile); return [{ @@ -26,14 +29,18 @@ namespace ts.codefix { const sourceFile = context.sourceFile; const token = getTokenAtPosition(sourceFile, context.span.start); - const constructor = getContainingFunction(token); - Debug.assert(constructor.kind === SyntaxKind.Constructor, "Failed to find the constructor."); + if (token.kind !== SyntaxKind.ConstructorKeyword) { + return undefined; + } + const constructor = getContainingFunction(token); const superCall = findSuperCall((constructor).body); - Debug.assert(!!superCall, "Failed to find super call."); + if (!superCall) { + return undefined; + } const newPosition = getOpenBraceEnd(constructor, sourceFile); - const changes = [{ + const changes = [{ fileName: sourceFile.fileName, textChanges: [{ newText: superCall.getText(sourceFile), span: { start: newPosition, length: 0 }