mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
fix(50416): correctly names disabled export refactors (#50663)
* added test case to try to retrieve duplicate refactor as in #50416. 'verify.refactorAvailable' correctly retrieves nonduplicate refactors... * optional arguments in refactorAvailable return `true` even if there is no single refactor that satisfies both * it still passes :C * Delete fixExtractToInnerFunctionDuplicaton.ts * deleted extra test code * fix 'verify.refactorAvailable' so that tests correctly check for multiple arguments * fixes #50416 * refactor
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
|
||||
namespace FourSlash {
|
||||
import ArrayOrSingle = FourSlashInterface.ArrayOrSingle;
|
||||
|
||||
@@ -3481,8 +3480,18 @@ namespace FourSlash {
|
||||
|
||||
public verifyRefactorAvailable(negative: boolean, triggerReason: ts.RefactorTriggerReason, name: string, actionName?: string, actionDescription?: string) {
|
||||
let refactors = this.getApplicableRefactorsAtSelection(triggerReason);
|
||||
refactors = refactors.filter(r =>
|
||||
r.name === name && (actionName === undefined || r.actions.some(a => a.name === actionName)) && (actionDescription === undefined || r.actions.some(a => a.description === actionDescription)));
|
||||
refactors = refactors.filter(r => r.name === name);
|
||||
|
||||
if (actionName !== undefined) {
|
||||
refactors.forEach(r => r.actions = r.actions.filter(a => a.name === actionName));
|
||||
}
|
||||
|
||||
if (actionDescription !== undefined) {
|
||||
refactors.forEach(r => r.actions = r.actions.filter(a => a.description === actionDescription));
|
||||
}
|
||||
|
||||
refactors = refactors.filter(r => r.actions.length > 0);
|
||||
|
||||
const isAvailable = refactors.length > 0;
|
||||
|
||||
if (negative) {
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace ts.refactor.extractSymbol {
|
||||
|
||||
let i = 0;
|
||||
for (const { functionExtraction, constantExtraction } of extractions) {
|
||||
const description = functionExtraction.description;
|
||||
if (refactorKindBeginsWith(extractFunctionAction.kind, requestedRefactor)) {
|
||||
const description = functionExtraction.description;
|
||||
if (functionExtraction.errors.length === 0) {
|
||||
// Don't issue refactorings with duplicated names.
|
||||
// Scopes come back in "innermost first" order, so extractions will
|
||||
@@ -95,11 +95,11 @@ namespace ts.refactor.extractSymbol {
|
||||
}
|
||||
|
||||
if (refactorKindBeginsWith(extractConstantAction.kind, requestedRefactor)) {
|
||||
const description = constantExtraction.description;
|
||||
if (constantExtraction.errors.length === 0) {
|
||||
// Don't issue refactorings with duplicated names.
|
||||
// Scopes come back in "innermost first" order, so extractions will
|
||||
// preferentially go into nearer scopes
|
||||
const description = constantExtraction.description;
|
||||
if (!usedConstantNames.has(description)) {
|
||||
usedConstantNames.set(description, true);
|
||||
constantActions.push({
|
||||
|
||||
Reference in New Issue
Block a user