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.
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?
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!
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.
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)
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.
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.
Sorry - didn't mean to post twice. After I hit submit it somehow took me to the summary for a totally different issue. Bizarre.
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
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
http://hg.netbeans.org/web-main/rev/f9ef080eefe8
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".
*** Issue 157503 has been marked as a duplicate of this issue. ***
*** Issue 159399 has been marked as a duplicate of this issue. ***
*** Issue 163638 has been marked as a duplicate of this issue. ***
if it works for you, you can close the issue as verified. thanks