Safe Delete Refactor not working correctly.
When I attempt to safely delete a field in a class, 1144 seems to do a straight string search rather than an attribute search and comes up with occurrences that have nothing to do with the attribute needing to be deleted. Then, I go through the list and exclude the ones I am not interested in (and which should be in the list anyway) and I cannot find the 'Do Refactor' button. So, I hit the 'Rerun Safe Delete' button and guess what happens? It repeats the whole process over again!! This used to work (I cant remember how long ago) and it needs to work before IDEA is released.
请先登录再写评论。
Did you enable "Search in comments and strings"?
Yeh - are you seeing the same problem?
No, I don't use Safe Delete, I was just making sure you hadn't checked those options. I just tested it with a simple class that had the same name as a string in another class, and it worked fine for me.
Here is a screenshot of the problem.
Attachment(s):
SafeDeleteProblem.jpg
Saqib,
what you see here are usages of 'calculateButton' grouped by methods. That is, 'calculateButton' is used in methods 'jbInit' etc. If you uncollapse the nodes, you'll see the actual usages.
Friendly,
Dmitry
Keith,
BTW, why don't you use Safe Delete? Any special reason?
Is your motto: "my classes and methods are forever"? :))
Friendly,
Dmitry
No, my classes are not forever :) If I'm about to delete a class or a method, it's because it shouldn't be there, so I prefer to just delete it, and then find all of the red underlined usages and fix them individually.
Keith Lea wrote:
That is what 'Safe Delete' does :) Try it - you'll love it :)
Cheers,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
No, Safe Delete bothers me with dialogs and find usages results popping up, I prefer to not work so rushed-like. :)
Keith Lea wrote:
As in "you can't rush art"?
:)
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
I suppose it's all down to whether you like to Fix First, Break Later or
vice-versa. Good thing about safe delete is that it doesn't leave you
with an uncompilable code base for the time it takes to code round the
deletion of a class.
N.
Dmitry Lomov (JetBrains) wrote:
>>No, Safe Delete bothers me with dialogs and find usages results popping
>>up, I prefer to not work so rushed-like. :)
Hi Dmitry.
I know that the window shows the usages correctly - I agree with this. But, what the window does not allow me to do is to go ahead and delete once I have seen the uses. In 3.0.5 there was another button that said 'Do Refactor'. I think this button was there in Aurora at sometime too.
Saqib wrote:
Saqib,
Safe Delete behaves differently from other refactorings. If 'safe delete'
finds some usages that are not safe to delete, it shows them to you but
does not let you do refactoring (it is a safe delete after all).
The idea is: you want to get a correct code after refactoring. So if there
are any usages that prevent deleting an entity, you will need to correct
them. Correcting them means modifications to the code, but refactoring
cannot run on modified code. So 'Do refactor' button is pointless.
This behaviour has not been changed since 3.0.
Friendly,
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"
I cannot see the purpose of Safe Delete refactoring which does not check any usages at all. I want to delete a variable and all its usages rather than go through hundreds of them and modify them manually.
If Safe Delete is just to prevent accidental deletion of something which is referenced else where, is there any feature to allow refactor and delete an unwanted component and all its usages?
Hello,
Please share the code sample or a sample project at YouTrack: https://youtrack.jetbrains.com/issues/IDEA
where the "safe delete" doesn't work for you. Thank you