Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/services/refactorProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
Refactor,
RefactorContext,
RefactorEditInfo,
FileTextChanges,
} from "./_namespaces/ts.js";
import { refactorKindBeginsWith } from "./_namespaces/ts.refactor.js";
import { getEditsForFileRename } from '../services/refactors/autoRenamePlugin.js';

Check failure on line 12 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / lint

This import relatively references another project; did you mean to import from a local _namespace module?

// A map with the refactor code as key, the refactor itself as value
// e.g. nonSuggestableRefactors[refactorCode] -> the refactor you want
Expand Down Expand Up @@ -35,3 +37,34 @@
const refactor = refactors.get(refactorName);
return refactor && refactor.getEditsForAction(context, actionName, interactiveRefactorArguments);
}

/** @internal */
export function autoRenameRefactor(
fileName: string,
newFileName: string,
program: ts.Program

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on macos-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on ubuntu-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / smoke

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / coverage

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on ubuntu-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on macos-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on macos-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on ubuntu-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on ubuntu-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node lts/* on ubuntu-latest with --no-bundle

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on ubuntu-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on macos-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / self-check

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / browser-integration

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on windows-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on windows-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on windows-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on windows-latest

Cannot find namespace 'ts'.

Check failure on line 45 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on windows-latest

Cannot find namespace 'ts'.
): RefactorEditInfo | undefined {
const edits: FileTextChanges[] = getEditsForFileRename(fileName, newFileName, program);
if (edits.length === 0) return;
return { edits };
}

registerRefactor("autoRename", {
kinds: ["refactor.autoRename"],
getAvailableActions(context: RefactorContext): ApplicableRefactorInfo[] {
const { fileName, newFileName } = context;

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on macos-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on macos-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / smoke

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / smoke

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / coverage

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / coverage

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on macos-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on macos-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on macos-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on macos-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node lts/* on ubuntu-latest with --no-bundle

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node lts/* on ubuntu-latest with --no-bundle

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on macos-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on macos-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / self-check

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / self-check

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / browser-integration

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / browser-integration

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 55 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.
if (!fileName || !newFileName) return [];

return [{
name: "autoRenameFunction",
description: "Rename function to match the file name",
actions: [{
name: "autoRenameFunctionAction",
description: "Automatically rename the function to match the file name",
}],
}];
},
getEditsForAction(context: RefactorContext): RefactorEditInfo | undefined {
return autoRenameRefactor(context.fileName, context.newFileName!, context.program);

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on macos-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on macos-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / typecheck

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / smoke

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / smoke

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / coverage

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / coverage

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on macos-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on macos-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on macos-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on macos-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node lts/* on ubuntu-latest with --no-bundle

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node lts/* on ubuntu-latest with --no-bundle

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on ubuntu-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on ubuntu-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on macos-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on macos-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / lint

This assertion is unnecessary since the receiver accepts the original type of the expression

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / self-check

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / self-check

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / browser-integration

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / browser-integration

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 22 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 18 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 14 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 20 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on windows-latest

Property 'fileName' does not exist on type 'RefactorContext'.

Check failure on line 68 in src/services/refactorProvider.ts

View workflow job for this annotation

GitHub Actions / Test Node 16 on windows-latest

Property 'newFileName' does not exist on type 'RefactorContext'.
},
});
41 changes: 41 additions & 0 deletions src/services/refactors/autoRenamePlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as ts from "../_namespaces/ts";

Check failure on line 1 in src/services/refactors/autoRenamePlugin.ts

View workflow job for this annotation

GitHub Actions / lint

This relative module reference is missing a '.js' extension

export function getEditsForFileRename(
oldFilePath: string,
newFilePath: string,
sourceFile: ts.SourceFile
): ts.FileTextChanges[] {
const edits: ts.FileTextChanges[] = [];

// Extract function name from old and new file paths
const oldFileName = ts.getBaseFileName(oldFilePath).replace(/\.[jt]sx?$/, "");
const newFileName = ts.getBaseFileName(newFilePath).replace(/\.[jt]sx?$/, "");

if (!oldFileName || !newFileName) return edits;

// Traverse the source file to find a matching function
function visit(node: ts.Node) {
if (
ts.isFunctionDeclaration(node) &&
node.name?.text === oldFileName
) {
edits.push({
fileName: sourceFile.fileName,
textChanges: [
{
newText: newFileName,
span: {
start: node.name.getStart(),
length: node.name.getWidth(),
},
},
],
});
}

ts.forEachChild(node, visit);
}

visit(sourceFile);
return edits;
}
83 changes: 83 additions & 0 deletions tests/cases/fourslash/autoRenamePlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/// <reference path="fourslash.ts" />

// Test Case: Rename Function and Update Imports

// Step 1: Create an initial file "myFunction.ts" with named, default exports and arrow function
// @filename: myFunction.ts
//// export function myFunction() {}
//// export const myFunc = () => {};
//// export default function defaultFunction() {}

// Step 2: Perform file renaming from "myFunction.ts" to "myNewFunction.ts"
goTo.file("myFunction.ts");
renameFile("myFunction.ts", "myNewFunction.ts");

// Verify that the content of the current file reflects the correct function name change
verify.currentFileContentIs(`export function myNewFunction() {}
export const myFunc = () => {};
export default function defaultFunction() {}`);

// Step 3: Verify the imported path in other files

// @filename: anotherFile.ts
//// import { myFunction } from './myFunction';
//// import myDefaultFunction from './myFunction';

goTo.file("anotherFile.ts");

// After renaming, the import paths and bindings should be updated correctly
verify.currentFileContentIs(`import { myFunction } from './myNewFunction';
import myDefaultFunction from './myNewFunction';`);

verify.importBindingChange("myFunction", "myNewFunction"); // Check that the named function is renamed correctly
verify.importBindingChange("myDefaultFunction", "defaultFunction"); // Default function name should not change

// Step 4: Edge Case - Renaming a class

// Initial file: myClass.ts
//// export class MyClass {}
//// export default class MyClassDefault {}

goTo.file("myClass.ts");
renameFile("myClass.ts", "myNewClass.ts");

// Verify that the class name and file name are updated correctly
verify.currentFileContentIs(`export class MyNewClass {}
export default class MyClassDefault {}`);

// Step 5: Verify imports in another file for the class

// @filename: anotherFileWithClass.ts
//// import { MyClass } from './myClass';
//// import MyClassDefault from './myClass';

goTo.file("anotherFileWithClass.ts");

// Verify that the import paths and bindings are updated correctly after renaming
verify.currentFileContentIs(`import { MyClass } from './myNewClass';
import MyClassDefault from './myNewClass';`);

verify.importBindingChange("MyClass", "MyNewClass"); // Check that the class name is renamed correctly
verify.importBindingChange("MyClassDefault", "MyClassDefault"); // Default class name should remain the same

// Step 6: Edge Case - Renaming an arrow function

// Initial file: myArrowFunction.ts
//// export const myArrowFunc = () => {};

goTo.file("myArrowFunction.ts");
renameFile("myArrowFunction.ts", "myNewArrowFunction.ts");

// Verify the renamed arrow function is updated correctly
verify.currentFileContentIs(`export const myNewArrowFunc = () => {};`);

// Step 7: Verify imports for the renamed arrow function

// @filename: anotherFileWithArrow.ts
//// import { myArrowFunc } from './myArrowFunction';

goTo.file("anotherFileWithArrow.ts");

// Verify the import path and binding name after renaming the arrow function
verify.currentFileContentIs(`import { myArrowFunc } from './myNewArrowFunction';`);
verify.importBindingChange("myArrowFunc", "myNewArrowFunc"); // Verify the arrow function name change
Loading