Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 215042 - When trying to rename/refactor method (or see usages) it's finding methods of this same name of any existing class
When trying to rename/refactor method (or see usages) it's finding methods of...
Status: RESOLVED DUPLICATE of bug 218660
Product: php
Classification: Unclassified
Component: Refactoring
7.2
All All
: P3 with 2 votes (vote)
: 7.3
Assigned To: Ondrej Brejla
issues@php
72ca-not-a-stopper
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-01 00:42 UTC by turneliusz
Modified: 2012-09-20 07:59 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description turneliusz 2012-07-01 00:42:21 UTC
Rename (refactor) and finding usages seems completely unusable because NetBeans is using trying to find method calls, instead of using his "auto-completion" data.

Is it possible to introduce two methods of refactoring (find usages)?
1. Strict - if NetBeans is not sure (no docblocks), method will be not listed when refactoring.
2. Flexible - NetBeans will just search for any calls like it's doing right now.

EXAMPLES:
1. Find usages finds methods both classes: http://d.pr/i/RFdt
2. Preview of renaming method: http://d.pr/i/g5hJ

Code:

<?php

class Foo
{
    public function testRename()
    {
    }
}

class Bar
{
    public function testRename()
    {
    }
}
Comment 1 Ondrej Brejla 2012-07-02 08:27:31 UTC
Sorry, but it's not a defect...it's an expected behavior. Your "strict" refactoring is quite useless and will lead to broken code...some parts will be refactored and some will not. So the better way is to suggest "all possible methods" (remember some dynamic calls and such) and user is the one, who will choose what to refactor...

But I'll let this issue open...just as an enhancement reminder. Thanks for your response!
Comment 2 turneliusz 2012-07-02 08:33:39 UTC
Thank you for response! Right now with current implementation is hard for me to use that feature. Maybe just a little information like "green" (for strict) and regular "black" font color (for any result) to indicate if NetBeans is "sure" about the displayed usage would be great!
Comment 3 Ondrej Brejla 2012-07-02 08:37:41 UTC
Unfortunately NetBeans can't be never sure...if you make a typo in a PHPDoc, whole refactoring could be broken. It can't be checked in "compile time" so almost everything "could be wrong". It's the general problem of all "non-type-strict" languages...:(
Comment 4 turneliusz 2012-07-02 08:42:34 UTC
Yeah but relaying on docblocks is the only "good enough" choice. IMO search for method calls of the same name across the project is insane! I have more than a 1200 calls of `getName()` method across the codebase. How I can refactor and rename in one class this `getName()` to `getOperationName()`? It's impossible! It's better to relay on docblocks - people know that editor can't find every possible usage of the method - it's dynamic-typing languages and everybody knows that. Process of refactoring should be 2 steps: first using docblocks then using search as fallback.
Comment 5 Ondrej Brejla 2012-07-02 08:47:51 UTC
(In reply to comment #4)
> It's better to relay on docblocks - people know that editor can't find every
I know that, you know that...but it doesn't metter. Even though most of people know that, most of them will complain if we will not suggest "everything" what we should. One call will be missing in the result and people will shout on us :) Trust me that it's not so simple as it looks like ;)

But I agree that whole "refactoring process" should be somehow more clever, definitely.
Comment 6 turneliusz 2012-07-02 09:05:21 UTC
Yes, I agree. The process should be more clear. For me rename and find usages it's the only weak side of the editor. Everything is polished, seems great - only this refactoring acts a little weird.
Comment 7 schkovich 2012-08-23 13:14:08 UTC
I would support having strict and louse refactoring modes.

Current mode is occasionally useless. Try finding usages of method MyClass::init() when working with Zend Framework. You will get completely trashy results. I know that the given example is a bit extreme but it's meant to illustrate the point.

I do understand your points on PHP "louse" nature but there are developers who prefer strong type casting and code in such way. Please support us and give us option to use find usages and/or rename refactoring in a strict mode.
Comment 8 turneliusz 2012-08-23 13:22:08 UTC
Interesting addition would be to be able to filter-out list of found files by directory hierarchy.

Imagine that example with `init()`, the result could be displayed in a tree:

- application/
-- controllers
---- IndexController.php
- library/
-- Zend/
--- Form.php
--- Form/
----- Element.php

This feature would allow to just click on [delete from the result set]. So by just clicking [delete] on "Zend/" we would be able to skip a huge amount of invalid cases found by the louse "refactoring method". Above feature would be extremely useful for me everywhere in NetBeans. I could just delete which I don't want to see, like "search" results which were pointing to places which I've wanted to refactor. After changing the code I would [delete] the entry from result set to indicate what I did already and what I didn't.

Additionally as I said before, simple filter to [delete] all results that are non-strict would be amazing.
Comment 9 Ondrej Brejla 2012-09-20 07:59:57 UTC

*** This bug has been marked as a duplicate of bug 218660 ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo