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.
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
will investigate
It looks as a duplicate of #175576, doesn't it?
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]
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.
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"
FYI, issue is not reproducible in Beta and in trunk from 21 Oct We didn't have any code changes in our affected components.
Investigating...
It's caused by http://hg.netbeans.org/main-golden/rev/04860c675e0c. We are now looking for the fix.
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
*** Issue 175646 has been marked as a duplicate of this issue. ***
*** Issue 175816 has been marked as a duplicate of this issue. ***
*** Bug 176517 has been marked as a duplicate of this bug. ***