Author Topic: File manager and refactoring  (Read 5988 times)

Offline Phumus-9

  • Multiple posting newcomer
  • *
  • Posts: 12
File manager and refactoring
« on: February 16, 2019, 11:06:11 pm »
Hi guys, it's me again.
This time I'm struggling with file organization. What can I do if I want to move a file to a new folder?
I've searched online, and I read that the only way to move a file is to create a new folder on the Windows file manager (or in the "Files" tab of the "Management" menu on C::B), move there the file(s) I want, remove that file from my project, add the same file but with the new path.
Now, I find this process just a bit time consuming for such a simple task, in one of the most famous IDEs of 2019. I really hope there is a faster way (for example I tried to right-click on the project name in "Management" menu, but I can only add virtual folders, and this is not what I want).

Moreover I have problems concerning refactoring. If I want to change the name of a variable I select that variable, right click on it, "Code refactoring", "Rename symbols" and I write the new name in the dialog box. All ok, but then if I have another variable with the same name, then it changes that variable too (for example in a setter method of a class this happens frequently). This makes the refactoring pretty useless... Is there another way to refactor my code?

Thanks in advance!

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5915
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: File manager and refactoring
« Reply #1 on: February 17, 2019, 03:25:00 pm »
Moreover I have problems concerning refactoring. If I want to change the name of a variable I select that variable, right click on it, "Code refactoring", "Rename symbols" and I write the new name in the dialog box. All ok, but then if I have another variable with the same name, then it changes that variable too (for example in a setter method of a class this happens frequently). This makes the refactoring pretty useless... Is there another way to refactor my code?

This feature is supplied by CodeCompletion plugin, and this plugin has bugs. It would be better to file a bug report on our Ticket system so that this bug won't lost.

BTW: fix such bug is not easy I guess.  :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Phumus-9

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: File manager and refactoring
« Reply #2 on: February 17, 2019, 06:13:50 pm »
Moreover I have problems concerning refactoring. If I want to change the name of a variable I select that variable, right click on it, "Code refactoring", "Rename symbols" and I write the new name in the dialog box. All ok, but then if I have another variable with the same name, then it changes that variable too (for example in a setter method of a class this happens frequently). This makes the refactoring pretty useless... Is there another way to refactor my code?

This feature is supplied by CodeCompletion plugin, and this plugin has bugs. It would be better to file a bug report on our Ticket system so that this bug won't lost.

BTW: fix such bug is not easy I guess.  :)

Thanks for the answer, I thoutght it was the normal behaviour, since eve when I select a variable, the highlighting too highlights all the occurrences.
Btw I suggest you to report this bug somewhere in the IDE, because at the beginning I didn't understand why it was acting like that.

What about my first question about file manegement?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: File manager and refactoring
« Reply #3 on: February 18, 2019, 09:24:19 am »
The thing with file management is this: you have a highly specialized program for file management on your pc, why should codeblocks try to re implement it?
If you have to move a lot files then the easiest way is to use the file manager of your os to move the files, open codeblocks and your project, call the plugin "Plugins->Find broken files in project" Remove the broken files and then add the new files via Project->Add files recursively. Codeblocks will select only the new files. You can also filter it more in the following dialogues...

« Last Edit: February 18, 2019, 09:30:15 am by BlueHazzard »

Offline Phumus-9

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: File manager and refactoring
« Reply #4 on: February 18, 2019, 01:12:55 pm »
The thing with file management is this: you have a highly specialized program for file management on your pc, why should codeblocks try to re implement it?
If you have to move a lot files then the easiest way is to use the file manager of your os to move the files, open codeblocks and your project, call the plugin "Plugins->Find broken files in project" Remove the broken files and then add the new files via Project->Add files recursively. Codeblocks will select only the new files. You can also filter it more in the following dialogues...
Ok, I tried what you suggested and it is a bit faster.
I agree that my PC's file manager is highly specialized, and I'm ok with creating the main structure of my project with it. But it happens quite frequently that I have to do minor changes to the structure, and there is where an integrated file manager would be very useful.
Just a method to insert a new folder would be needed, so that I can drag and drop the files I want to move in that folder, without having to remove and re-add them. Of course I imagine that it isn't that easy to implement (if not you would have already implemented it), maybe in the future I can try to implement it by myself, but right now I'm not experienced enough (I'm just a student), and probably this is also why I do a lot of minor changes to the structure of my project...

Thanks for the answer!
« Last Edit: February 18, 2019, 01:14:56 pm by Phumus-9 »

Offline cacb

  • Lives here!
  • ****
  • Posts: 536
Re: File manager and refactoring
« Reply #5 on: February 18, 2019, 03:16:26 pm »
Just a method to insert a new folder would be needed, so that I can drag and drop the files I want to move in that folder, without having to remove and re-add them.

I saw you didn't want to use virtual folders, but why not? I find they are very flexible and allow files to be organised without physically moving the files around. For this reason I use virtual folders in C::B projects much more than actual disk folders.

Offline Phumus-9

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: File manager and refactoring
« Reply #6 on: February 18, 2019, 03:30:03 pm »
Just a method to insert a new folder would be needed, so that I can drag and drop the files I want to move in that folder, without having to remove and re-add them.

I saw you didn't want to use virtual folders, but why not? I find they are very flexible and allow files to be organised without physically moving the files around. For this reason I use virtual folders in C::B projects much more than actual disk folders.

Hi cacb, I don't use them because I'd like to have coherence between the actual structure of the project and what I see in the IDE. Btw at the moment I'm using virtual folders because my project is small, but I think that if it was a big one using them could lead to problems in the organization of the files.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: File manager and refactoring
« Reply #7 on: February 23, 2019, 05:43:41 pm »
I agree that my PC's file manager is highly specialized, and I'm ok with creating the main structure of my project with it. But it happens quite frequently that I have to do minor changes to the structure, and there is where an integrated file manager would be very useful.

There is one under the files tab. Also, for an open project you can right click on the project icon in the project tab and select "open in file browser" to see the directory where the project resides in the files tab:



Which looks like this.



You can move files around etc. but you will still need to update the project manually afterwards.

Offline Phumus-9

  • Multiple posting newcomer
  • *
  • Posts: 12
Re: File manager and refactoring
« Reply #8 on: February 23, 2019, 05:51:29 pm »
I agree that my PC's file manager is highly specialized, and I'm ok with creating the main structure of my project with it. But it happens quite frequently that I have to do minor changes to the structure, and there is where an integrated file manager would be very useful.

There is one under the files tab. Also, for an open project you can right click on the project icon in the project tab and select "open in file browser" to see the directory where the project resides in the files tab:



Which looks like this.



You can move files around etc. but you will still need to update the project manually afterwards.
Thank you for the tip!
By the way I'm getting used to do it manually and actually it is not a big deal, except for changing the #include "..." directives.

Inviato dal mio SM-G950F utilizzando Tapatalk