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.

0
15 comments

Did you enable "Search in comments and strings"?

0

Yeh - are you seeing the same problem?

0

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.

0

Here is a screenshot of the problem.



Attachment(s):
SafeDeleteProblem.jpg
0

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

0

Keith,

BTW, why don't you use Safe Delete? Any special reason?
Is your motto: "my classes and methods are forever"? :))

Friendly,
Dmitry

0

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.

0

Keith Lea wrote:

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.

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!"

0

No, Safe Delete bothers me with dialogs and find usages results popping up, I prefer to not work so rushed-like. :)

0

Keith Lea wrote:

No, Safe Delete bothers me with dialogs and find usages results popping
up, I prefer to not work so rushed-like. :)


As in "you can't rush art"?

:)
Dmitry
--
Dmitry Lomov
Software Developer
JetBrains Inc.
http://www.jetbrains.com
"Develop with pleasure!"

0

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:

Keith Lea wrote:

>>No, Safe Delete bothers me with dialogs and find usages results popping
>>up, I prefer to not work so rushed-like. :)


As in "you can't rush art"?

:)
Dmitry

0

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.

0

Saqib wrote:

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,
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!"

0

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?

0

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 

0

Please sign in to leave a comment.