Refactor/Rename not working in CLion

Answered

Refactor->Rename is not working at all in CLion.  I right-click on a name, select refactor->rename, edit the name.  When I press "Refactor", nothing happens.  The toolbar says "No occurrences found".  I get the same result attempting to refactor instance variable names and typedefs in C++.

I am using CLion 2016.3.2 Build #CL-163.10154.43, built on December 21, 2016
JRE: 1.8.0_112-release-408-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

running on OSX 10.11.6

 

No entries are made in the log file when I attempt to refactor.

Neither restarting CLion nor invalidating caches has any effect.

What should I try next?

 

 

3
11 comments

The same story. Also when I refactor by selecting variable, alt + shift + r, it indeed shows preview of refactor, but after I confirm with enter, it roles back to the original variable name without any error information.

In my opinion this feature should work no matter CMakeLists includes what it should or not. Many people (including me) do not use CLion to build source at all, because for now it handles only CMake as build system - I do not use it. My scenario is that I want to use CLion only as editor and refactor feature could work within dependencies it sees at the moment. 

For now my workaround is to just find/replace, but it is a bit torture :(

At lest there should be info like: "Cannot refactor due to problem with project"

3

I am having the same problem.  Please let us know as soon as you have a solution.  Thanks.

1

Resolved in support.

0

Does "resolved in support" mean that I should file a bug report, or that a bug report has already been filed?

0

Sorry, I mixed up your question with the other question which was resolved in our support channel. Could you please check that the project file is not greyed out? If it is it means that it's not included in the project and you need to add it in your CMakeLists (https://www.jetbrains.com/help/clion/2016.3/quick-cmake-tutorial.html). If it is not the case, please send us an example so we could reproduce the issue on our side (clion-support at jetbrains.com).

0

The file wasn't included in the project.  Including the file fixed the problem.  Thanks for the help.

0

Hi all!

CLion uses a concept of a project and relies on CMake as a build system for it for now. All the includes paths, variables and more is taken from CMake files and are used by CLion to understand your project better and to resolve your code correctly.

Please take a look at this issue in our tracker https://youtrack.jetbrains.com/issue/CPP-653 and at discussions in the related/duplicated ones to get more details. Feel free to comment.

0

I'm having the same issue as Mw336071. When I hit shift-F6 to refactor a variable, it momentarily appears to work, as I can see all appearances of the variable change as I type, but after I hit enter, it reverts back to what its name was before I hit shift-F6.

 

I am using CLion 2021.2.3

Build #CL-212.5457.51 built on October 14, 2021

 

I was running this on a Linux virtual machine. I tried closing CLion and restarting it, but that didn't help.

0

I am having a very similar issue on Windows:

The source file in question is included in CMakeLists.txt as part of the project (it is only a two file project), attempting to rename a class does not do anything. Either via Shift + F6 or by bringing up a popup menu with a right-click, and then Refactor->Rename.

Compiling and running the project both work fine.

For what it's worth, I am using CLion 2021.3.3 Build #CL-213.6777.58, built on Jan 31, 2022.

Renaming all class name occurrences manually is a pain. Can you please help and look into this? Thank you.

0

overwriter please send your project to clion-support at jetbrains.com.

0

Kcwells please send your project to clion-support at jetbrains.com.

0

Please sign in to leave a comment.