From 75e1b80ad59d54af5029cdc61ec14a756a0b0063 Mon Sep 17 00:00:00 2001 From: Paul van Brenk Date: Thu, 6 Oct 2016 13:21:58 -0700 Subject: [PATCH] Use just the errorcode, without the TS prefix --- src/harness/fourslash.ts | 2 +- src/harness/harnessLanguageService.ts | 2 +- src/server/client.ts | 2 +- src/server/protocol.d.ts | 2 +- src/services/codefixes/codeFixProvider.ts | 6 +++--- src/services/codefixes/superFixes.ts | 8 ++++---- src/services/services.ts | 2 +- src/services/shims.ts | 2 +- src/services/types.ts | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 5fc2674404..cadda289da 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -2055,7 +2055,7 @@ namespace FourSlash { const diagnostic = !errorCode ? diagnostics[0] : ts.find(diagnostics, d => d.code == errorCode); - return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [`TS${diagnostic.code}`]); + return this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]); } public verifyCodeFixAtPosition(expectedText: string, errorCode?: number) { diff --git a/src/harness/harnessLanguageService.ts b/src/harness/harnessLanguageService.ts index 514049511f..6af168796f 100644 --- a/src/harness/harnessLanguageService.ts +++ b/src/harness/harnessLanguageService.ts @@ -486,7 +486,7 @@ namespace Harness.LanguageService { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean { return unwrapJSONCallResult(this.shim.isValidBraceCompletionAtPosition(fileName, position, openingBrace)); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeAction[] { + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] { return unwrapJSONCallResult(this.shim.getCodeFixesAtPosition(fileName, start, end, JSON.stringify(errorCodes))); } getEmitOutput(fileName: string): ts.EmitOutput { diff --git a/src/server/client.ts b/src/server/client.ts index f9fdf62423..089a0eed12 100644 --- a/src/server/client.ts +++ b/src/server/client.ts @@ -630,7 +630,7 @@ namespace ts.server { throw new Error("Not Implemented Yet."); } - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): ts.CodeAction[] { + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): ts.CodeAction[] { throw new Error("Not Implemented Yet."); } diff --git a/src/server/protocol.d.ts b/src/server/protocol.d.ts index e8919f843e..02e488650c 100644 --- a/src/server/protocol.d.ts +++ b/src/server/protocol.d.ts @@ -247,7 +247,7 @@ declare namespace ts.server.protocol { /** * Errorcodes we want to get the fixes for. */ - errorCodes?: string[] + errorCodes?: number[] } /** diff --git a/src/services/codefixes/codeFixProvider.ts b/src/services/codefixes/codeFixProvider.ts index 55aa8d38f7..bc5ee1fb97 100644 --- a/src/services/codefixes/codeFixProvider.ts +++ b/src/services/codefixes/codeFixProvider.ts @@ -1,12 +1,12 @@ -/* @internal */ +/* @internal */ namespace ts { export interface CodeFix { - errorCodes: string[]; + errorCodes: number[]; getCodeActions(context: CodeFixContext): CodeAction[]; } export interface CodeFixContext { - errorCode: string; + errorCode: number; sourceFile: SourceFile; span: TextSpan; program: Program; diff --git a/src/services/codefixes/superFixes.ts b/src/services/codefixes/superFixes.ts index 2f0a78580c..35462f0d49 100644 --- a/src/services/codefixes/superFixes.ts +++ b/src/services/codefixes/superFixes.ts @@ -1,4 +1,4 @@ -/* @internal */ +/* @internal */ 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. @@ -6,7 +6,7 @@ namespace ts.codefix { } registerCodeFix({ - errorCodes: [`TS${Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call.code}`], + errorCodes: [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); @@ -24,7 +24,7 @@ namespace ts.codefix { }); registerCodeFix({ - errorCodes: [`TS${Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code}`], + errorCodes: [Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class.code], getCodeActions: (context: CodeFixContext) => { const sourceFile = context.sourceFile; @@ -43,7 +43,7 @@ namespace ts.codefix { // i.e. super(this.a), since in that case we won't suggest a fix if (superCall.expression && superCall.expression.kind == SyntaxKind.CallExpression) { const arguments = (superCall.expression).arguments; - for (let i = 0; i < arguments.length; i++){ + for (let i = 0; i < arguments.length; i++) { if ((arguments[i]).expression === token) { return undefined; } diff --git a/src/services/services.ts b/src/services/services.ts index 050096b45d..7f81649bac 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -1639,7 +1639,7 @@ namespace ts { return []; } - function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[] { + function getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[] { synchronizeHostData(); const sourceFile = getValidSourceFile(fileName); const span = { start, length: end - start }; diff --git a/src/services/shims.ts b/src/services/shims.ts index 63f766eff5..19dadba89b 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -961,7 +961,7 @@ namespace ts { return this.forwardJSONCall( `getCodeFixesAtPosition( '${fileName}', ${start}, ${end}, ${errorCodes}')`, () => { - const localErrors: string[] = JSON.parse(errorCodes); + const localErrors: number[] = JSON.parse(errorCodes); return this.languageService.getCodeFixesAtPosition(fileName, start, end, localErrors); } ); diff --git a/src/services/types.ts b/src/services/types.ts index f8b57ab0d3..59abe2f799 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -239,7 +239,7 @@ namespace ts { isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: string[]): CodeAction[]; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput;