Alip
Alip

Reputation: 1

Why eclipse refactoring rename a variable even in different folders?

I am working with Eclipse and I have a weird problem.

I have one code (let's call it A) and another copy of that code (let's call it B). A and B are one code but in different folders.

I want to keep A as original code and change some variable's name in code B.

When I change any variable's name using Refactor option in code B, it will automatically be changed in code A too!!!!

I do not want to see this change in code A, I want to compare both code in same time so I should open both of them with my Eclipse.

Look forward to your kind response,

Upvotes: 0

Views: 202

Answers (3)

Alip
Alip

Reputation: 1

Finally I found a solution for above mentioned problem ! Imagine I have to same folder with same code which are dependent together (folder A and B):

Now when I open these folders in Eclipse to work on the codes, lets call them Project A and Project B, as I mentioned I had problem with renaming the valuables in my code. Because with renaming one variables (Refactor option) in Code A, that variable will be renamed in code B automatically which I do not want it !

The simple solution is: I should just right click on Project B -> choose "close project" !

Now I can work on Project A without any influence on Code B, and when ever I need to move to Project B I need to simply write click on Project B -> choose "open project"!

It is good, because I already have two projects in my Eclipse desktop and whenever I need the using "close project" and "open project" I will active them :)

Anyway many thanks for all your helps...

Upvotes: 0

Ankit Bhatnagar
Ankit Bhatnagar

Reputation: 755

If code A is dependent on that variable in code B, refactoring B should change code A as well. This is the expected scenario. So, you should first remove the dependency and then do this refactoring.

Upvotes: 1

Boann
Boann

Reputation: 50042

After typing the new variable name, press Esc instead of Enter. This will limit changes to the one file.

Upvotes: 0

Related Questions