Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refactor rename broken in Intellij IDEA

Somehow, I managed to break my refactoring capabilities in Intellij IDEA 12. I have somehow disabled it for my project. Renaming a member through Shift+F6 doesn't work. The inline edit box is not drawn, nothing happens.

I know of the refactoring settings in Settings -> Editor, Enable in-place mode and Preselect old name are both checked.

It has to be some kind of project setting. I checked by creating a test project, adding some member and renaming it, which works perfectly.

What setting am I looking for? Or could my project be broken?

like image 940
Rens Verhage Avatar asked Nov 05 '13 14:11

Rens Verhage


People also ask

How do I rename a file in IntelliJ?

The only way to rename files seems to be Shift+F6 which attempts to find all usages which takes too long (~30s - 1min).

How do I Refactor variable type in IntelliJ?

In the editor, highlight or place the caret at a type you want to refactor. Press Ctrl+Shift+F6 or on the main menu, select Refactor | Type Migration. In the dialog that opens, specify the new type and scope where to look for the usages. Preview and apply the changes.


Video Answer


4 Answers

There is no way to turn refactoring off in the settings. My guess is that the project's cache/indexes are corrupted. I had a case once where refactoring, especially renames, stopped working. A re-index solved it for me. Go to File >Invalidate Caches, invalidate your caches, restart IDEA, and let IDEA re-index the project (progress is shown in the bottom status bar right of center). Then try the refactoring.

If that does not solve it, take a look in the logs (Help > Show Log) and see if there is any indication in there as to the cause of the issue.

like image 82
Javaru Avatar answered Oct 20 '22 06:10

Javaru


Fo all the MacOS users, do not forget to access Settings -> Keyboard and turn on the flag for the option Use all F1, F2, etc. keys as standard function keys. E.g.:

enter image description here

Otherwise IntelliJ will not get the focus to use the F4 key.

like image 23
JeanValjean Avatar answered Oct 20 '22 05:10

JeanValjean


Following step worked for me:

From your IDE, go to: Preferences -> Project Structure -> Add Content Root, then select the folder you want to use.

like image 1
BlackBeard Avatar answered Oct 20 '22 06:10

BlackBeard


None of the above steps worked for me in IDEA 2021.2.4 (Ultimate Edition). I got the following error message when trying to rename a file and its usages:

Cannot perform refactoring. Selected file is not located inside the project.

Instead, I had to create a new module.

File > Project Structure > Modules > Add (+) > Import module > Select <root_folder_of_your_project>

This reindexed the whole project, which took a couple of minutes, and restored the Refactor > Rename functionality.

like image 1
bigsee Avatar answered Oct 20 '22 05:10

bigsee