Skip to main content
Matth1
Associate III
February 19, 2022
Solved

Does CubeIDE refactor methods in class between header and source ?

  • February 19, 2022
  • 8 replies
  • 3182 views

When developing a class, can CubeIDE update a method's name in the .cpp file when it's modified in the .h (the sme the other way around)? Or do we have to modify both files?

This topic has been closed for replies.
Best answer by TDK

Yes it will. Use Refactor -> Rename (Alt+Shift+R)

Any calls to it are also updated, assuming your index is valid.

8 replies

TDK
TDKBest answer
February 19, 2022

Yes it will. Use Refactor -> Rename (Alt+Shift+R)

Any calls to it are also updated, assuming your index is valid.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Matth1
Matth1Author
Associate III
February 19, 2022

OK, so I must be doing something wrong.

[a few minutes later] : Ooh I found the "implement method" tool. Ok.

So if I don't use this "implement method" tool, how can I make the indexer link the method's declaration and definition?

TDK
February 19, 2022

You don't need to do anything special. Type the header and class definitions correctly, make sure they're used (or at least compiled) in your project, make sure it builds correctly. You can rebuild the index but shouldn't need to.

"If you feel a post has answered your question, please click ""Accept as Solution""."
Matth1
Matth1Author
Associate III
February 19, 2022

So I need to build it (hammer icon) and that's when they get linked?

TDK
February 19, 2022

No, but if it builds, it means you don’t have typos and the IDE can interpret the code.

Edit: or hit F3 on the declaration and ensure it jumps to the definition.

"If you feel a post has answered your question, please click ""Accept as Solution""."
mattias norlander
ST Employee
February 22, 2022

Did you solve the issue?

Is the header file only setup as an include path but not as a resource (folder/file) visible in the project explorer?

If so, the CDT Indexer will not keep track of changes inside the include path directory.

Consequently many CDT features like refactoring will not work well.

Matth1
Matth1Author
Associate III
February 22, 2022

Yes, I think the issue was that I need to save a file for the indexer to acknowledge a method written within (it then appears in the autocomplete tool).

I don't think UM2609 mentions anything about that. Is there another UM for CubeIDE?