PR Feedback

This commit is contained in:
Paul van Brenk
2016-08-26 14:32:01 -07:00
parent 6f4fb064ca
commit 124e05fd68
8 changed files with 31 additions and 36 deletions
+2 -5
View File
@@ -1,7 +1,6 @@
/* @internal */
/* @internal */
namespace ts {
export interface CodeFix {
name: string;
errorCodes: string[];
getCodeActions(context: CodeFixContext): CodeAction[];
}
@@ -14,7 +13,7 @@ namespace ts {
newLineCharacter: string;
}
export namespace codeFix {
export namespace codefix {
const codeFixes: Map<CodeFix[]> = {};
export function registerCodeFix(action: CodeFix) {
@@ -37,8 +36,6 @@ namespace ts {
const fixes = codeFixes[context.errorCode];
let allActions: CodeAction[] = [];
Debug.assert(fixes && fixes.length > 0, "No fixes found for error: '${errorCode}'.");
forEach(fixes, f => {
const actions = f.getCodeActions(context);
if (actions && actions.length > 0) {
-3
View File
@@ -1,6 +1,3 @@
///<reference path='..\services.ts' />
///<reference path='codeFixProvider.ts' />
///<reference path='superFixes.ts' />
///<reference path='unusedIdentifierFixes.ts' />
///<reference path='changeExtendsToImplementsFix.ts' />
///<reference path='interfaceFixes.ts' />
+3 -5
View File
@@ -1,13 +1,12 @@
/* @internal */
namespace ts.codeFix {
namespace ts.codefix {
function getOpenBraceEnd(constructor: ConstructorDeclaration, sourceFile: SourceFile) {
// First token is the open curly, this is where we want to put the 'super' call.
return constructor.body.getFirstToken(sourceFile).getEnd();
}
registerCodeFix({
name: "AddMissingSuperCallFix",
errorCodes: ["TS2377"],
errorCodes: [`TS${Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code}`],
getCodeActions: (context: CodeFixContext) => {
const sourceFile = context.sourceFile;
const token = getTokenAtPosition(sourceFile, context.span.start);
@@ -22,8 +21,7 @@ namespace ts.codeFix {
});
registerCodeFix({
name: "MakeSuperCallTheFirstStatementInTheConstructor",
errorCodes: ["TS17009"],
errorCodes: [`TS${Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code}`],
getCodeActions: (context: CodeFixContext) => {
const sourceFile = context.sourceFile;