41

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?

jarlh
  • 42,561
  • 8
  • 45
  • 63
Rens Verhage
  • 5,688
  • 4
  • 33
  • 51

5 Answers5

41

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.

Javaru
  • 30,412
  • 11
  • 93
  • 70
  • 2
    In te meantime, I downloaded the Intellij 13 EAP version. That obviously 'solved' my problem. Thanks for your answer, will certainly try your suggestions will I ever run into this problem again. – Rens Verhage Nov 06 '13 at 09:32
  • 2
    Intellij 13 also has problems if its index was corrupted due code changes (ieg. if you switch git branch). Invalidate Caches and Restart helps! – igor.beslic Mar 14 '14 at 13:30
  • 1
    @verhage On IDEA 13 I'm experiencing different types of bugs, all of them cause code corruption. I'm thinking now on switching back to 12. – Askar Kalykov May 04 '14 at 13:23
  • 5
    I'm using IDEA14, this solution does not work for me, still stuck/not responding once I press refactor(rename) or Al+F7(Find usage), until I delete the whole install and reinstall it. I'm on Windows 7. – July Jul 23 '15 at 02:59
  • 1
    I'm on IntelliJ 2018.2.4 and in-place Rename still fails for some variables. File > Invalidate caches... > Invalidate and Restart does not solve it. :^( – Paulo Merson Oct 16 '18 at 11:42
12

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.

JeanValjean
  • 17,172
  • 23
  • 113
  • 157
1

Following step worked for me:

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

BlackBeard
  • 10,246
  • 7
  • 52
  • 62
1

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.

bigsee
  • 927
  • 8
  • 14
0

waite for some time it can be due to running Indexing

Hassan Ali Shahzad
  • 2,439
  • 29
  • 32