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 231706 - Find Usages finds all occurences, regardless of context
Summary: Find Usages finds all occurences, regardless of context
Status: RESOLVED DUPLICATE of bug 218660
Alias: None
Product: php
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal (vote)
Assignee: Ondrej Brejla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-24 10:53 UTC by berniev
Modified: 2013-06-24 14:32 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (75.76 KB, text/plain)
2013-06-24 10:53 UTC, berniev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description berniev 2013-06-24 10:53:41 UTC
Product Version = NetBeans IDE Dev (Build 201306212301)
Operating System = Linux version 3.0.0-32-generic-pae running on i386
Java; VM; Vendor = 1.7.0_21
Runtime = OpenJDK Client VM 23.7-b01

Further to the last couple of reports, this one has been annoying me for ages:

<?php

class Test {

	public function Fred() {
		return 1;
	}

}

class Test2 {

	public function Fred() {
		return 2;
	}

}

class Test3 {

	private function Fred() {
		return 3;
	}

}

$a = new Test;
$b = $b->Fred(); // Right-Click->FindUsages on Fred()

Gives:
(php) ProjectName
    FolderName
        FileName
             5: public function Fred(){
           13:  public function Fred(){
            21: private function Fred(){
            28: $b=$b->Fred();

1) The actual structure in use is:
(php) ProjectName
    FolderName
        Folder2Name   <= Not shown
            FileName

2) This is a request for show usages, not search, so list all occurences found is not very useful,  should be just the correct context ie the one in line 5 (?);

3) In the Find Usages dialog box there is a superfluous check box 'Find Usages'. Why??
Comment 1 berniev 2013-06-24 10:53:48 UTC
Created attachment 136208 [details]
IDE log
Comment 2 Ondrej Brejla 2013-06-24 12:53:56 UTC
It's known behavior that FU finds methods from unrelated types. But it has some sense. One can use some dynamic typing and then proper type can't be resolved (you met some of these issue in that "new $class" issue ;), so that's why we try to offer more results and let user to select the proper one. 

And that's also why there is a need of "preview" in rename refactoring. FU and Rename refactoring uses the same results (it's the one infrastructure).

I can adjust that behavior, that the only exact types will be resolved...but then I'll get many and many regressions, that someone used that crapy dynamic sh*t and NB didn't offered that method so refactoring broke his code :)

So this approach is, for these days, the golden mean... I know that it's anoying (I hated that too when I developed some PHP applications), but can't do anything with that right now. Sorry :(

I have a big task for that for some of next releases.

*** This bug has been marked as a duplicate of bug 218660 ***
Comment 3 berniev 2013-06-24 14:32:44 UTC
If it's easily doable to find all or find just related types then a simple choice in the dialogue box (replacing the redundant one?) would make those of us not so golden quite happier.

Right now refactoring is -still- dangerous if you forget to check closely the preview. I've done that a couple of times and got a big surprise later when unrelated class functions didn't work any more.

Looking forward to the fruits of your big task!