This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 196956 - Remove refactoring removes whole file
Summary: Remove refactoring removes whole file
Status: RESOLVED INVALID
Alias: None
Product: php
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.0.1
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-22 11:47 UTC by Vladimir Riha
Modified: 2011-03-28 08:52 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2011-03-22 11:47:23 UTC
Maybe this should be ENHANCEMENT, but seems to me as a bug now.

Steps to reproduce:
1. Define some class in php fileA, then in include fileA in fileB
2. Use the class from fileA in fileB
3. Safely remove the class defined in fileA
=> fileB is removed even hough it contained other code

Product Version: NetBeans IDE Dev (Build 201103210400)
Java: 1.6.0_24; Java HotSpot(TM) Client VM 19.1-b02
System: Windows XP version 5.1 running on x86; Cp1250; cs_CZ (nb)
Comment 1 OndrejBrejla 2011-03-23 08:32:35 UTC
It doesn't work just in Win XP? Because it seems that it works for me in Ubuntu.
Comment 2 Vladimir Riha 2011-03-23 08:34:56 UTC
I'll try Ubuntu probably on Monday
Comment 3 Vladimir Riha 2011-03-28 08:12:06 UTC
What happens in ubuntu:

1. Define some class in php fileA and function outside the class, then include fileA in fileB
2. Use the class from fileA in fileB
3. Safely remove the class defined in fileA
=> fileA is removed, code in fileB remains (even the usage of removed class)

I tried to rename the class the same way I had tried to remove it and renaming works. In Ubuntu, after selecting Refactor|Safely delete (right click on class name, for instance "class Foo{"),  dialog is opened saying: "Search for usage and safely delete fileA.php". Is it possible that it really deletes only the file, not the class?

fileA:
class Foo {
    var $bar = 2;
}

$foobar = new Foo();
echo "Echo " . $foobar->bar . " bars";
function mm(){}

fileB:
include 'newEmptyPHP.php';
$foobar = new Foo();
echo "Echo " . $foobar->bar . " bars";
function mmw(){}



Product Version: NetBeans IDE Dev (Build 201103280400)
Java: 1.6.0_24; Java HotSpot(TM) Client VM 19.1-b02
System: Linux version 2.6.32-24-generic running on i386; UTF-8; en_US (nb)
Comment 4 Vladimir Riha 2011-03-28 08:22:53 UTC
The same happens on windows xp, I'll try to find the original project from first comment and see what is different.
Comment 5 OndrejBrejla 2011-03-28 08:42:04 UTC
If I try your use case and try to safely delete the Foo class, it writes me "Search for usages and delete fileA.php" (because it really removes whole file, you can invoke that delete dialog everywhere in the file). So it seems that it only "check for usages"...it doesn't remove references from another files. 

Then I click on "Refactor" button and my assumption was right I think. There is list of warnings, where is said that "References to elements in selected file were found. Remove all references to these elements in order to safely delete your file.". It saids YOU to remove all references. 

So you could click on "Show usages..." button and according to shown usages "Remove all references to deleted file - manually". Then in the "Usages" window you can rerun your "Safely Delete" action...and if you have removed all usages, then no warning is detected and "Safely Remove" action is processed without any interruptions.

So:

"Safely Delete" action only means, that "before removing whole file" is invoked "Find Usages" action to INFORM you, that there are some reference usages...so that YOU should remove them.

So it seems like that it's feature and everything works properly for me...or are there just another issues? Or am I wrong with my explanation? Thanks.
Comment 6 Vladimir Riha 2011-03-28 08:52:05 UTC
You are right, I completely misunderstood this refactoring. Thank you for explaining.

As soon as I get to the original project I'll try it again to see if I used it also incorrectly. So for now I change the bug to INVALID