0

I am working with Playwright on a test automation project. I already have several Pages classes and would now like to move a method from one class to another. This already has various references.

Is there an IDE that can help me with the move, i.e. adapt the references at the same time?

So far I have cut the method and pasted it into the new class. But then I had to adjust all references by hand. I can't believe that there is no support for this.

I have Visual Studio Code and IntelliJ IDEA Ultimate.

1
  • None of the options that show up when you right-click on the method and select Refactor... address this? For a standard TypeScript project, the Move to file option works fine for me. Don't know about Playwright though... Commented Nov 11, 2024 at 6:35

1 Answer 1

0

This is typically possible using VS Code's Move To File refactoring, which is documented here: https://code.visualstudio.com/updates/v1_82#_move-to-file-refactoring

The Move to file refactoring for JavaScript and TypeScript lets you move a class, function, or constant into an existing file. This will also automatically update all references to the symbol and update imports as needed:

When you select Move to file, VS Code shows you a list of all files in the current TypeScript or JavaScript project. You can start typings to quickly filter to the file you want.

Alternatively, you can use Select existing file... to select a file using the normal file picker or Enter new file path... to specify a new file that should be created.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.