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 175578 - Regression in "Refactor|Rename..."
Summary: Regression in "Refactor|Rename..."
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: mslama
URL:
Keywords:
: 175646 175816 176517 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-10-28 10:31 UTC by soldatov
Modified: 2009-11-11 06:13 UTC (History)
3 users (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 soldatov 2009-10-28 10:31:22 UTC
Scenario:
- Create Quote project
- Open module.cc file
- Move cursor on 36th line (Module::) and call context menu. Select "Refactor|Rename..."
- Change Module on Module2 and press Refactor button
==> can't build Quote project

g++    -c -g -Wall -MMD -MP -MF build/Debug/GNU-Linux-x86/quote.o.d -o build/Debug/GNU-Linux-x86/quote.o quote.cc
memory.h:34: error: expected class-name before ‘{’ token
memory.h:34: warning: ‘class Memory’ has virtual functions but non-virtual destructor
memory.h:45: error: multiple types in one declaration
memory.h:45: error: declaration does not declare anything
quote.cc: In function ‘int main(int, char**)’:
quote.cc:205: error: no matching function for call to ‘System::AddModule(Memory*)’
system.h:46: note: candidates are: void System::AddModule(Module2*)
gmake[2]: *** [build/Debug/GNU-Linux-x86/quote.o] Error 1
Comment 1 Vladimir Voskresensky 2009-10-28 10:36:29 UTC
will investigate
Comment 2 Leonid Lenyashin 2009-10-28 10:39:00 UTC
It looks as a duplicate of #175576, doesn't it?
Comment 3 Vladimir Voskresensky 2009-10-28 16:03:06 UTC
Looks like something is broken in implementator of EditorCookie.
I see that some files have several versions of associated documents.
The output [1] with -J-Dnetbeans.debug.editor.document=true -J-Dnetbeans.debug.editor.document.notext=true
shows that 
/home/vv159170/NetBeansProjects/Quote_1/disk.h has two documents:ee522b, 1ee6962
the same issue for /home/vv159170/NetBeansProjects/Quote_1/cpu.h
trace shows that both are "first modification"s

The consequences of this is that cloneable editor support incorrectly tracks created PositionRef objects.
So, the ones created for exact offsets N and M later on returns zeros (0) as getOffset()

[1] trace when call rename for Module->Module2 (from Classes view Ctrl+9)
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@1278afa, mimeType = 'text/x-c++', kitClass
= null, length = 2488,
file=org.netbeans.modules.cnd.loaders.CCDataObject@b1c9f0[/home/vv159170/NetBeansProjects/Quote_1/system.cc] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@ee522b, mimeType = 'text/x-h', kitClass =
null, length = 2051,
file=org.netbeans.modules.cnd.loaders.HDataObject@222422[/home/vv159170/NetBeansProjects/Quote_1/disk.h] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@16f59d6, mimeType = 'text/x-c++', kitClass
= null, length = 2837,
file=org.netbeans.modules.cnd.loaders.CCDataObject@1ee515e[/home/vv159170/NetBeansProjects/Quote_1/cpu.cc] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@98f56c, mimeType = 'text/x-c++', kitClass
= null, length = 2779,
file=org.netbeans.modules.cnd.loaders.CCDataObject@110d623[/home/vv159170/NetBeansProjects/Quote_1/disk.cc] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@1cfc20e, mimeType = 'text/x-h', kitClass =
null, length = 2031,
file=org.netbeans.modules.cnd.loaders.HDataObject@6195c9[/home/vv159170/NetBeansProjects/Quote_1/memory.h] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@13d888e, mimeType = 'text/x-h', kitClass =
null, length = 2072,
file=org.netbeans.modules.cnd.loaders.HDataObject@d86fa8[/home/vv159170/NetBeansProjects/Quote_1/cpu.h] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@1dd9505, mimeType = 'text/x-h', kitClass =
null, length = 2131,
file=org.netbeans.modules.cnd.loaders.HDataObject@16c6ff8[/home/vv159170/NetBeansProjects/Quote_1/system.h] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@ec06eb, mimeType = 'text/x-c++', kitClass
= null, length = 2980,
file=org.netbeans.modules.cnd.loaders.CCDataObject@577474[/home/vv159170/NetBeansProjects/Quote_1/memory.cc] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@a2d2b0, mimeType = 'text/x-h', kitClass =
null, length = 2937,
file=org.netbeans.modules.cnd.loaders.HDataObject@4f9afd[/home/vv159170/NetBeansProjects/Quote_1/module.h] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@cd3e02, mimeType = 'text/x-c++', kitClass
= null, length = 3814,
file=org.netbeans.modules.cnd.loaders.CCDataObject@14e61f7[/home/vv159170/NetBeansProjects/Quote_1/module.cc] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@12d8328, mimeType = 'text/x-c++', kitClass
= null, length = 2837,
file=org.netbeans.modules.cnd.loaders.CCDataObject@1ee515e[/home/vv159170/NetBeansProjects/Quote_1/cpu.cc] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@1d90110, mimeType = 'text/x-c++', kitClass
= null, length = 2488,
file=org.netbeans.modules.cnd.loaders.CCDataObject@b1c9f0[/home/vv159170/NetBeansProjects/Quote_1/system.cc] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@1136646, mimeType = 'text/x-h', kitClass =
null, length = 2072,
file=org.netbeans.modules.cnd.loaders.HDataObject@d86fa8[/home/vv159170/NetBeansProjects/Quote_1/cpu.h] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@1394db4, mimeType = 'text/x-h', kitClass =
null, length = 2131,
file=org.netbeans.modules.cnd.loaders.HDataObject@16c6ff8[/home/vv159170/NetBeansProjects/Quote_1/system.h] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@14dd8d9, mimeType = 'text/x-h', kitClass =
null, length = 2031,
file=org.netbeans.modules.cnd.loaders.HDataObject@6195c9[/home/vv159170/NetBeansProjects/Quote_1/memory.h] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@10a5ed8, mimeType = 'text/x-c++', kitClass
= null, length = 2779,
file=org.netbeans.modules.cnd.loaders.CCDataObject@110d623[/home/vv159170/NetBeansProjects/Quote_1/disk.cc] - first
modification, offset=0[1:1]
BaseDocument.insertString(): doc=org.netbeans.modules.editor.NbEditorDocument@1ee6962, mimeType = 'text/x-h', kitClass =
null, length = 2051,
file=org.netbeans.modules.cnd.loaders.HDataObject@222422[/home/vv159170/NetBeansProjects/Quote_1/disk.h] - first
modification, offset=0[1:1]
Comment 4 Vladimir Voskresensky 2009-10-28 17:07:36 UTC
Btw, I have seen the problem caused by the same reason in Java projects as well.
I have used "Find" action and then opening from "Search Results" window opened file with cursor on the zero position.
Looks like the same root cause.

In our case replacement made in org.netbeans.modules.cnd.refactoring.support.ModificationResult by iterating list of
document's Differences remove and inserts text on the zero position.
Comment 5 Vladimir Voskresensky 2009-10-28 17:19:08 UTC
I have checked and insertion on the zero position instead of replacement occurs in all files which are doubled in the
tracing as insertion with the comment "first modification" 
Comment 6 Vladimir Voskresensky 2009-10-28 17:20:52 UTC
FYI, issue is not reproducible in Beta and in trunk from 21 Oct
We didn't have any code changes in our affected components.
Comment 7 Vitezslav Stejskal 2009-10-29 21:20:52 UTC
Investigating...
Comment 8 Vitezslav Stejskal 2009-10-30 11:32:40 UTC
It's caused by http://hg.netbeans.org/main-golden/rev/04860c675e0c. We are now looking for the fix.
Comment 9 Vitezslav Stejskal 2009-10-30 13:49:32 UTC
There is no obvious simple fix and so after discussion with mslama and jstulach we decided to backout
http://hg.netbeans.org/main-golden/rev/04860c675e0c. The fix is now in jet-main:

http://hg.netbeans.org/jet-main/rev/0b6dc23ea3f4
Comment 10 Vitezslav Stejskal 2009-10-30 14:03:30 UTC
*** Issue 175646 has been marked as a duplicate of this issue. ***
Comment 11 Jesse Glick 2009-11-03 17:33:55 UTC
*** Issue 175816 has been marked as a duplicate of this issue. ***
Comment 12 Alexander Simon 2009-11-11 06:13:37 UTC
*** Bug 176517 has been marked as a duplicate of this bug. ***