Offer missing abstract codefix once

* per class that is missing potentially many abstract members.
This commit is contained in:
Arthur Ozga
2017-02-13 16:58:14 -08:00
parent 7cd0e1a0e6
commit 21355982fd
3 changed files with 29 additions and 2 deletions

View File

@@ -2153,12 +2153,29 @@ namespace FourSlash {
const diagnostics: ts.Diagnostic[] = this.getDiagnostics(fileName);
let actions: ts.CodeAction[] = undefined;
const checkedDiagnostics = ts.createMap<boolean>();
for (const diagnostic of diagnostics) {
if (errorCode && errorCode !== diagnostic.code) {
continue;
}
const summary = JSON.stringify({
start: diagnostic.start,
length: diagnostic.length,
code: diagnostic.code
});
if (checkedDiagnostics.has(summary)) {
// Don't want to ask for code fixes in an identical position for the same error code twice.
continue;
}
else {
checkedDiagnostics.set(summary, true);
}
const newActions = this.languageService.getCodeFixesAtPosition(fileName, diagnostic.start, diagnostic.length, [diagnostic.code]);
if (newActions && newActions.length) {
actions = actions ? actions.concat(newActions) : newActions;

View File

@@ -1688,7 +1688,13 @@ namespace ts {
let allFixes: CodeAction[] = [];
forEach(errorCodes, error => {
// De-duplicate error codes.
const errorCodeSet: number[] = [];
for (const code of errorCodes) {
errorCodeSet[code] = code;
}
forEach(errorCodeSet, error => {
cancellationToken.throwIfCancellationRequested();
const context = {

View File

@@ -2,11 +2,15 @@
//// abstract class A {
//// abstract x: number;
//// abstract foo(): number;
//// }
////
//// class C extends A {[|
//// |]}
verify.rangeAfterCodeFix(`
x: number;
x: number;
foo(): number {
throw new Error('Method not implemented.');
}
`);