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 163313 - [67cat][php]Editor won't allow refactor/rename variable
Summary: [67cat][php]Editor won't allow refactor/rename variable
Status: RESOLVED FIXED
Alias: None
Product: php
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: rmatous
URL:
Keywords:
: 157503 159399 163638 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-04-21 22:38 UTC by dancehands
Modified: 2009-06-01 16:21 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 dancehands 2009-04-21 22:39:00 UTC
I haven't figured out why sometimes it works fine and sometimes it doesn't - but basically when I'm editing a PHP file
sometimes I can put my cursor on a variable, use the Refactor menu to Rename a variable. About half of the time, though,
the Refactor submenu items are all disabled so I can't Rename a variable. This is really frustrating since it seems
inconsistent and I haven't figured out what causes it to disable...

I have tried making sure that the file is saved before I try to refactor. Didn't solve the issue.
I also tried making sure there were no parsing errors indicated, and there weren't. Didn't solve the issue.

I'm not sure what else to check to see what's preventing the refactor submenu items from working.

If/when this happens again, what information can/should I capture to help pinpoint the cause of this problem?
Comment 1 Filip Zamboj 2009-04-28 15:20:40 UTC
please, attach build number and try to give us two scenarios. One when it works and one when it doesn't work - I mean
exact steps to reproduce step by step. 

Thanks a lot! 
Comment 2 dancehands 2009-04-29 19:25:18 UTC
fzamboj,

I've been running the daily builds for about a month now. Here's the specifics on the version I'm running right now:

Product Version: NetBeans IDE 6.7 Beta (Build 200904242137)
Java: 1.6.0_13; Java HotSpot(TM) Client VM 11.3-b02
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
Userdir: C:\Documents and Settings\Chris\.netbeans\6.7beta

FYI this is the PHP bundle of the app, not the entire full bundle with Java and C++ etc. Only PHP.

DOESN'T WORK (for .php file)
-----------------------------
1. Create a brand new "PHP Application" type of PHP project
2. Replace all contents of the generated index.php file with:

<?php
$test = 'some string';
echo "what " . $test;
$test .= ' goes here';
echo $test;
?>

3. Save the file.
4. Higlight the first variable instance of $test and hit CTRL-R to refactor (or go to the Refactor menu). You'll notice
that all submenu items are disabled.

Actually, I can't figure out how to get it to work at all now. That's the simplest of scenarios - just one project (the
new one I created) with just 1 file (index.php) and it won't event work in that case.

I've tried getting the refactoring to work in my other large projects and it won't work there either in PHP files.

WORKS (for a .js file)
-----------------------------
1. In the same new project you created above, right-click on the Source Files node in the Projects pane and select New
-> JavaScript File
2. Give the file a name and click okay so it's added to the project.
3. Replace all contents of that file with:

var sTest = '';
sTest = 'Some text';
sTest += ' goes here';

4. Highlight the first instance of the sTest variable and hit CTRL-R (or use the Refactor menu and choose Rename submenu
item) and it prompts you for the new variable name. Side question - in NB 6.5 it never prompted me with a dialog it just
started renaming the variable in the editor as I typed. Did this functionality change to now use a dialog? Just curious.

Again, I'm not sure why I can't get it work on ANY .php files now. I work on PHP files all day long so if I do come
across a situation where it works I'll definitely let you know.

Maybe it's an issue with the PHP bundle of NetBeans?

Anything else I can provide to help you pinpoint the problem let me know. I'm more than happy to try to give more
helpful information! :)
I did perform the exact same set of steps, but for .js javascript file and it works okay.
Comment 3 dancehands 2009-04-29 19:37:24 UTC
When I hit CTRL-R to do the refactoring I get this warning in the console window:

WARNING [org.netbeans.modules.parsing.impl.TaskProcessor]: ParserManager.parse called in AWT event thread by:
org.netbeans.modules.csl.editor.InstantRenameAction.actionPerformed(InstantRenameAction.java:120)
Comment 4 dancehands 2009-04-30 16:54:29 UTC
I just figured out when I _can_ refactor/rename successfully in PHP:

1. Create a brand new PHP Application project.
2. Replace the contents of the generated index.php with a sample class, like this:

<?php
class MyTest {
  function MyTest() {
    $myString = 'this is  test';
    $myString .= ' of refactoring';
    return $myString;
  }
}
?>

3. Highlight the first instance of the $myString variable and hit CTRL-R to refactor/rename.

It works as expected.

So it seems that refactoring/renaming in a PHP file that just has procedural lines of code doesn't work and throws a
warning in the console, but in a class object it works just fine.

Interestingly if I use these contents in the index.php file:

<?php
$test = '';
$test .= 'some text';
echo $test;

class MyTest {
  function MyTest() {
    $myString = 'this is  test';
    $myString .= ' of refactoring';
    return $myString;
  }
}
?>

I can't refactor the "$test" variable, but I _can_ refactor the $myString variable. Again, maybe this points to the fact
that inside of a class object the refactoring works fine, but not outside of class objects.
Comment 5 dancehands 2009-04-30 16:57:37 UTC
I just figured out when I _can_ refactor/rename successfully in PHP:

1. Create a brand new PHP Application project.
2. Replace the contents of the generated index.php with a sample class, like this:

<?php
class MyTest {
  function MyTest() {
    $myString = 'this is  test';
    $myString .= ' of refactoring';
    return $myString;
  }
}
?>

3. Highlight the first instance of the $myString variable and hit CTRL-R to refactor/rename.

It works as expected.

So it seems that refactoring/renaming in a PHP file that just has procedural lines of code doesn't work and throws a
warning in the console, but in a class object it works just fine.

Interestingly if I use these contents in the index.php file:

<?php
//won't refactor
$test = '';
$test .= 'some text';
echo $test;

class MyTest {
  function MyTest() {
    //does refactor
    $myString = 'this is  test';
    $myString .= ' of refactoring';
    return $myString;
  }
}
?>

I can't refactor the "$test" variable, but I _can_ refactor the $myString variable. Again, maybe this points to the fact
that inside of a class object the refactoring works fine, but not outside of class objects.
Comment 6 dancehands 2009-04-30 17:00:21 UTC
Sorry - didn't mean to post twice. After I hit submit it somehow took me to the summary for a totally different issue.
Bizarre.
Comment 7 rmatous 2009-05-04 17:43:52 UTC
http://hg.netbeans.org/web-main/rev/f9ef080eefe8

Fixed: until real rename refactoring => instant rename enabled even on publicly visible class members, classes, ...\

For QA: deserves some testing
Comment 8 Quality Engineering 2009-05-05 07:49:28 UTC
Integrated into 'main-golden', will be available in build *200905050201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/f9ef080eefe8
User: Radek Matous <rmatous@netbeans.org>
Log: #163313 [67cat][php]Editor won't allow refactor/rename variable
Comment 10 dancehands 2009-05-06 19:38:32 UTC
Confirmed fixed in today's build:

Product Version: NetBeans IDE Dev (Build 200905051401)
Java: 1.6.0_13; Java HotSpot(TM) Client VM 11.3-b02
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)

Should I mark the item as "verified" or "closed"? I wasn't sure so I left it as "resolved fixed".
Comment 11 rmatous 2009-05-14 17:00:49 UTC
*** Issue 157503 has been marked as a duplicate of this issue. ***
Comment 12 rmatous 2009-05-14 17:58:40 UTC
*** Issue 159399 has been marked as a duplicate of this issue. ***
Comment 13 rmatous 2009-05-15 16:10:43 UTC
*** Issue 163638 has been marked as a duplicate of this issue. ***
Comment 14 Filip Zamboj 2009-06-01 16:21:03 UTC
if it works for you, you can close the issue as verified. thanks