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.
Summary: | variable renaming affects variables in other methods | ||
---|---|---|---|
Product: | ruby | Reporter: | jamespb <jamespb> |
Component: | Editing | Assignee: | Torbjorn Norbye <tor> |
Status: | VERIFIED FIXED | ||
Severity: | blocker | CC: | jskrivanek, pjiricka |
Priority: | P1 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Attachments: | Fix merged to release60 |
Description
jamespb
2007-11-25 18:22:20 UTC
build 5469 Product Version: NetBeans Ruby IDE 20071124202613 Java: 1.6.0_01; Java HotSpot(TM) Client VM 1.6.0_01-b06 System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nbrubyide) Userdir: C:\Users\James\AppData\Roaming\.nbrubyide\dev Thanks for the report. I don't see 'name' referenced in the code; were you referring to one of the dynamic vars perhaps (foo, val) ? Also, your build is 6.1 not 6.0, but this code hasn't changed since 6.0 so unlike the other lexing bug you filed this has a high chance of being a problem in 6.0 as well. I'll investigate tomorrow. Sorry about that - 'name' was the original value, 'foo' was the new value. Fixed in trunk: IDE:------------------------------------------------- IDE: [11/26/07 9:00 PM] Committing started cvs server: scheduling file `nestedblocks2.rb.testRename9.rename' for addition cvs server: scheduling file `nestedblocks2.rb' for addition cvs server: scheduling file `nestedblocks2.rb.testNestedBlocks2.occurrences' for addition cvs server: use 'cvs commit' to add these files permanently Checking in test/unit/src/org/netbeans/modules/ruby/RenameHandlerTest.java; /cvs/ruby/editing/test/unit/src/org/netbeans/modules/ruby/RenameHandlerTest.java,v <-- RenameHandlerTest.java new revision: 1.5; previous revision: 1.4 done IDE: [11/26/07 9:00 PM] Diffing finished Checking in test/unit/src/org/netbeans/modules/ruby/OccurrencesFinderTest.java; /cvs/ruby/editing/test/unit/src/org/netbeans/modules/ruby/OccurrencesFinderTest.java,v <-- OccurrencesFinderTest.java new revision: 1.9; previous revision: 1.8 done Checking in src/org/netbeans/modules/ruby/AstUtilities.java; /cvs/ruby/editing/src/org/netbeans/modules/ruby/AstUtilities.java,v <-- AstUtilities.java new revision: 1.18; previous revision: 1.17 done RCS file: /cvs/ruby/editing/test/unit/data/testfiles/nestedblocks2.rb,v done Checking in test/unit/data/testfiles/nestedblocks2.rb; /cvs/ruby/editing/test/unit/data/testfiles/nestedblocks2.rb,v <-- nestedblocks2.rb initial revision: 1.1 done RCS file: /cvs/ruby/editing/test/unit/data/testfiles/nestedblocks2.rb.testRename9.rename,v done Checking in test/unit/data/testfiles/nestedblocks2.rb.testRename9.rename; /cvs/ruby/editing/test/unit/data/testfiles/nestedblocks2.rb.testRename9.rename,v <-- nestedblocks2.rb.testRename9.rename initial revision: 1.1 done RCS file: /cvs/ruby/editing/test/unit/data/testfiles/nestedblocks2.rb.testNestedBlocks2.occurrences,v done Checking in test/unit/data/testfiles/nestedblocks2.rb.testNestedBlocks2.occurrences; /cvs/ruby/editing/test/unit/data/testfiles/nestedblocks2.rb.testNestedBlocks2.occurrences,v <-- nestedblocks2.rb.testNestedBlocks2.occurrences initial revision: 1.1 done IDE: [11/26/07 9:00 PM] Committing finished IDE: [11/26/07 9:00 PM] Diffing finished Now the question is whether we push this into the release branch. James argued that we should, and I'm inclined to agree. I wouldn't hold the release for this single bug fix, but if we are respinning the build for anything else, I'd like to include this fix. It's really simple. Basically, a "break" statement was intended to jump out of an iteration, but because this break statement was inside a switch-statement, it only broke out of the switch. What we need is a labelled break: Index: AstUtilities.java =================================================================== RCS file: /cvs/ruby/editing/src/org/netbeans/modules/ruby/AstUtilities.java,v retrieving revision 1.17 diff -u -r1.17 AstUtilities.java --- AstUtilities.java 4 Nov 2007 09:04:47 -0000 1.17 +++ AstUtilities.java 26 Nov 2007 21:04:09 -0000 @@ -1798,7 +1798,8 @@ } Node leaf = path.root(); + while_loop: while (it.hasNext()) { Node n = it.next(); switch (n.nodeId) { @@ -1813,7 +1814,7 @@ case NodeTypes.SCLASSNODE: case NodeTypes.MODULENODE: leaf = n; - break; + break while_loop; } } This code is basically walking up the AST path looking for the current enclosing method/class/module. When it sees it, it's supposed to stop - but because of this bug, it didn't, and as a result, the whole AST tree was included in the search for block nodes - which is clearly wrong. I've added new unit tests to detect this scenario. I will attach a patch for 6.0 if somebody wants to review it. The fix can be tested in deadlock.netbeans.org build #5489 or later. Created attachment 53509 [details]
Fix merged to release60
Verified in trunk. The fix has been ported into the release60_fixes branch. Checking in AstUtilities.java; /cvs/ruby/editing/src/org/netbeans/modules/ruby/AstUtilities.java,v <-- AstUtilities.java new revision: 1.17.4.1; previous revision: 1.17 done |