parent
a8b7c344d3
commit
4f9ebc3205
|
@ -355,6 +355,7 @@ const preferredFixes = new Map<string, { readonly value: number, readonly thereC
|
||||||
[fixNames.extendsInterfaceBecomesImplements, { value: 1 }],
|
[fixNames.extendsInterfaceBecomesImplements, { value: 1 }],
|
||||||
[fixNames.awaitInSyncFunction, { value: 1 }],
|
[fixNames.awaitInSyncFunction, { value: 1 }],
|
||||||
[fixNames.classIncorrectlyImplementsInterface, { value: 3 }],
|
[fixNames.classIncorrectlyImplementsInterface, { value: 3 }],
|
||||||
|
[fixNames.classDoesntImplementInheritedAbstractMember, { value: 3 }],
|
||||||
[fixNames.unreachableCode, { value: 1 }],
|
[fixNames.unreachableCode, { value: 1 }],
|
||||||
[fixNames.unusedIdentifier, { value: 1 }],
|
[fixNames.unusedIdentifier, { value: 1 }],
|
||||||
[fixNames.forgottenThisPropertyAccess, { value: 1 }],
|
[fixNames.forgottenThisPropertyAccess, { value: 1 }],
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
|
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
import { join } from 'path';
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import { disposeAll } from '../utils/dispose';
|
import { disposeAll } from '../utils/dispose';
|
||||||
import { createTestEditor, joinLines, wait } from './testUtils';
|
import { createTestEditor, joinLines, wait } from './testUtils';
|
||||||
|
@ -123,6 +122,25 @@ suite('TypeScript Quick Fix', () => {
|
||||||
assert.strictEqual(fixes![1].title, `Remove unused declaration for: 'Foo'`);
|
assert.strictEqual(fixes![1].title, `Remove unused declaration for: 'Foo'`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Should prioritize implement abstract class over remove unused #101486', async () => {
|
||||||
|
const testDocumentUri = workspaceFile('foo.ts');
|
||||||
|
const editor = await createTestEditor(testDocumentUri,
|
||||||
|
`export abstract class Foo { abstract foo(): number; }`,
|
||||||
|
`class ConcreteFoo extends Foo { }`,
|
||||||
|
);
|
||||||
|
|
||||||
|
await wait(3000);
|
||||||
|
|
||||||
|
const fixes = await vscode.commands.executeCommand<vscode.CodeAction[]>('vscode.executeCodeActionProvider',
|
||||||
|
testDocumentUri,
|
||||||
|
editor.document.lineAt(1).range
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(fixes?.length, 2);
|
||||||
|
assert.strictEqual(fixes![0].title, `Implement inherited abstract class`);
|
||||||
|
assert.strictEqual(fixes![1].title, `Remove unused declaration for: 'ConcreteFoo'`);
|
||||||
|
});
|
||||||
|
|
||||||
test('Add all missing imports should come after other add import fixes #98613', async () => {
|
test('Add all missing imports should come after other add import fixes #98613', async () => {
|
||||||
await createTestEditor(workspaceFile('foo.ts'),
|
await createTestEditor(workspaceFile('foo.ts'),
|
||||||
`export const foo = 1;`);
|
`export const foo = 1;`);
|
||||||
|
@ -152,6 +170,6 @@ suite('TypeScript Quick Fix', () => {
|
||||||
|
|
||||||
|
|
||||||
function workspaceFile(fileName: string) {
|
function workspaceFile(fileName: string) {
|
||||||
return vscode.Uri.file(join(vscode.workspace.rootPath!, fileName));
|
return vscode.Uri.joinPath(vscode.workspace.workspaceFolders![0].uri, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ export const constructorForDerivedNeedSuperCall = 'constructorForDerivedNeedSupe
|
||||||
export const extendsInterfaceBecomesImplements = 'extendsInterfaceBecomesImplements';
|
export const extendsInterfaceBecomesImplements = 'extendsInterfaceBecomesImplements';
|
||||||
export const awaitInSyncFunction = 'fixAwaitInSyncFunction';
|
export const awaitInSyncFunction = 'fixAwaitInSyncFunction';
|
||||||
export const classIncorrectlyImplementsInterface = 'fixClassIncorrectlyImplementsInterface';
|
export const classIncorrectlyImplementsInterface = 'fixClassIncorrectlyImplementsInterface';
|
||||||
|
export const classDoesntImplementInheritedAbstractMember = 'fixClassDoesntImplementInheritedAbstractMember';
|
||||||
export const unreachableCode = 'fixUnreachableCode';
|
export const unreachableCode = 'fixUnreachableCode';
|
||||||
export const unusedIdentifier = 'unusedIdentifier';
|
export const unusedIdentifier = 'unusedIdentifier';
|
||||||
export const forgottenThisPropertyAccess = 'forgottenThisPropertyAccess';
|
export const forgottenThisPropertyAccess = 'forgottenThisPropertyAccess';
|
||||||
|
|
Loading…
Reference in a new issue