Use just the errorcode, without the TS prefix

This commit is contained in:
Paul van Brenk 2016-10-06 13:21:58 -07:00
parent 163e758e10
commit 75e1b80ad5
9 changed files with 14 additions and 14 deletions

View file

@ -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) {

View file

@ -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 {

View file

@ -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.");
}

View file

@ -247,7 +247,7 @@ declare namespace ts.server.protocol {
/**
* Errorcodes we want to get the fixes for.
*/
errorCodes?: string[]
errorCodes?: number[]
}
/**

View file

@ -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;

View file

@ -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 = (<CallExpression>superCall.expression).arguments;
for (let i = 0; i < arguments.length; i++){
for (let i = 0; i < arguments.length; i++) {
if ((<PropertyAccessExpression>arguments[i]).expression === token) {
return undefined;
}

View file

@ -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 };

View file

@ -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);
}
);

View file

@ -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;