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 152775 - Instant Renaming refactoring in C goes wrong
Summary: Instant Renaming refactoring in C goes wrong
Status: RESOLVED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Vladimir Voskresensky
URL: http://silveiraneto.net/downloads/net...
Keywords:
: 157302 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-11-08 12:45 UTC by silveiraneto
Modified: 2011-11-09 16:08 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 119626


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description silveiraneto 2008-11-08 12:45:06 UTC
http://silveiraneto.net/downloads/netbeans_bug_c_renaming_refactoring.ogg

I was recording a screencast about C/C++ live renaming refactoring (Ctrl+R) and instead of that I recorded a bug. This
feature usually works, but two times this happened with me.
Unfortunately, I don't know how to reproduce this bug but I guess that this video can help.

I was using NB 6.5 rc2.
Comment 1 Leonid Lenyashin 2008-11-08 13:25:26 UTC
How to view the video? My browser does not understand it.
Comment 2 soldatov 2008-11-08 13:43:12 UTC
I see such video in MPlayer (http://www.mplayerhq.hu/design7/dload.html)
Comment 3 Vladimir Voskresensky 2008-11-08 18:31:31 UTC
What is your OS? 
Could you send me your file.
I created the file with your content on Linux:
#include <malloc.h>

typedef struct _Matrix {
    int size;
    float M[][];
} Matrix;

Matrix* new_matrix(int size) {
    int i, j;
    Matrix* mymatrix = (Matrix*) calloc(sizeof(Matrix), 1);
    mymatrix->size = size;
    mymatrix->M = calloc(sizeof(float*), mymatrix->size);
    for(i = 0; i < mymatrix-size; i++) {
        mymatrix->M[i] = calloc(sizeof(float), mymatrix->size+1);
        for(j=0; j < mymatrix->size + 1; j++) {
            mymatrix->M[i][j]=0;
        }
    }
    return mymatrix;
}

but it works OK
I think, could be something with line feed if you are on Windows...
Thanks,
Vladimir.
Comment 4 silveiraneto 2008-11-09 00:39:40 UTC
Sources:
http://code.google.com/p/clustersystemsolver/source/browse/trunk/Matrix.c
http://code.google.com/p/clustersystemsolver/source/browse/trunk/Matrix.h

No, I'm using Linux too.
I had performed the code refactoring in C code before without errors, even refactoring more 'hard' than this one, like
change a field of a struct and it worked. But, as I said, that was the second time I got this bug.
Comment 5 Vladimir Voskresensky 2008-11-09 00:51:35 UTC
Hm... I checked out source project and was unable to reproduce... 
Is it reproducible with  mymatrix variable each time or randomly?
Comment 6 silveiraneto 2008-11-09 01:08:15 UTC
Try this.
1) Open the matrix.c file and preform a renaming refactoring using Ctrl+R on the newmatrix variable.
2) Open the matrix.h file and play a little bit with the entities in the Navigation tab.
3) Back to matrix.c try find (Ctrl+F) the newmatrix variable.
4) Perform the renaming refactoring again.
Comment 7 Vladimir Voskresensky 2008-11-09 01:31:09 UTC
Couldn't reproduce 100% with your scenario :-(
But I've seen the problem once after Undo actions! 
Comment 8 Vladimir Voskresensky 2008-11-09 01:41:46 UTC
I got it 100%!
Just press Ctrl-R twice and start typing => your problem

If press Cltr-R a lot and start typing => exception
SEVERE: End offset of removed text 296 > getLength()=295
javax.swing.text.BadLocationException: End offset of removed text 296 > getLength()=295
        at org.netbeans.editor.BaseDocument.remove(BaseDocument.java:876)
[catch] at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:157)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at org.netbeans.modules.cnd.refactoring.actions.SyncDocumentRegion.sync(SyncDocumentRegion.java:155)
        at org.netbeans.modules.cnd.refactoring.actions.InstantRenamePerformer.insertUpdate(InstantRenamePerformer.java:243)
        at org.netbeans.editor.BaseDocument.insertString(BaseDocument.java:802)
        at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:655)
        at javax.swing.text.JTextComponent.replaceSelection(JTextComponent.java:1351)
        at javax.swing.JEditorPane.replaceSelection(JEditorPane.java:1202)
        at org.netbeans.editor.BaseKit$DefaultKeyTypedAction.replaceSelection(BaseKit.java:1177)
        at org.netbeans.editor.BaseKit$DefaultKeyTypedAction$1.run(BaseKit.java:1102)
        at org.netbeans.editor.GuardedDocument.runAtomicAsUser(GuardedDocument.java:324)
        at org.netbeans.editor.BaseKit$DefaultKeyTypedAction.actionPerformed(BaseKit.java:1084)
        at org.netbeans.editor.ext.ExtKit$ExtDefaultKeyTypedAction.actionPerformed(ExtKit.java:1014)
        at org.netbeans.editor.BaseAction.actionPerformed(BaseAction.java:297)
        at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636)
        at javax.swing.JComponent.processKeyBinding(JComponent.java:2849)
        at javax.swing.JComponent.processKeyBindings(JComponent.java:2884)
        at javax.swing.JComponent.processKeyEvent(JComponent.java:2812)
        at java.awt.Component.processEvent(Component.java:5818)
        at java.awt.Container.processEvent(Container.java:2058)
        at java.awt.Component.dispatchEventImpl(Component.java:4413)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
        at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:697)
        at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:962)
        at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:834)
        at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:661)
        at java.awt.Component.dispatchEventImpl(Component.java:4285)
        at java.awt.Container.dispatchEventImpl(Container.java:2116)
        at java.awt.Window.dispatchEventImpl(Window.java:2440)
        at java.awt.Component.dispatchEvent(Component.java:4243)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
        at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Comment 9 Vladimir Voskresensky 2008-11-09 02:36:04 UTC
fixed:
http://hg.netbeans.org/main?cmd=changeset;node=6622fb2fcf5c
Comment 10 Vladimir Voskresensky 2008-11-09 02:37:10 UTC
would like to see in in Patch1 
Comment 11 Quality Engineering 2008-11-09 16:26:27 UTC
Integrated into 'main-golden', will be available in build *200811091401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/6622fb2fcf5c
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: fixed IZ#152775: Instant Renaming refactoring in C goes wrong
Comment 12 Alexander Pepin 2008-11-20 21:45:24 UTC
verified in build 200811200201
Comment 13 pslechta 2008-11-21 15:07:15 UTC
The fix was ported into release65_repository.

http://hg.netbeans.org/release65_fixes/rev/ccbb2ac2d4f9
Comment 14 Alexander Pepin 2008-12-02 12:56:30 UTC
verified in nb6.5 with patch1
Comment 15 silveiraneto 2008-12-11 23:04:15 UTC
The bug is corrected in NetBeans 6.5 final.
I tried, is working just fine. =) Thank you guys.
Comment 16 Vladimir Voskresensky 2009-02-10 16:43:32 UTC
*** Issue 157302 has been marked as a duplicate of this issue. ***
Comment 17 stiffuser 2011-11-01 19:49:59 UTC
Notice that a number of new reports for 7.0 and 7.0.1 are coming in and being classified as duplicates of this bug.
Comment 18 Vladimir Voskresensky 2011-11-02 07:09:37 UTC
(In reply to comment #17)
> Notice that a number of new reports for 7.0 and 7.0.1 are coming in and being
> classified as duplicates of this bug.
Where can I have a look at such reports about 7.0 && 7.0.1?
Have you updated your IDE in update center today?

Could you provide steps to reproduce, please?

Thanks,
Vladimir.
Comment 19 soldatov 2011-11-02 07:38:43 UTC
(In reply to comment #18)
> (In reply to comment #17)
> > Notice that a number of new reports for 7.0 and 7.0.1 are coming in and being
> > classified as duplicates of this bug.
> Where can I have a look at such reports about 7.0 && 7.0.1?
http://statistics.netbeans.org/exceptions/detail.do?id=119626
Comment 20 Vladimir Voskresensky 2011-11-02 10:06:28 UTC
(In reply to comment #19)
> > Where can I have a look at such reports about 7.0 && 7.0.1?
> http://statistics.netbeans.org/exceptions/detail.do?id=119626
Thanks! What about steps to reproduce?
Comment 21 Vladimir Voskresensky 2011-11-08 10:29:24 UTC
Could someone, please, give me reproducible test case or any other hints how to get exception
Comment 22 Vladimir Voskresensky 2011-11-08 15:17:54 UTC
fixed
http://hg.netbeans.org/cnd-main/rev/98261df35116
Comment 23 Vladimir Voskresensky 2011-11-08 21:16:39 UTC
extra fix
 http://hg.netbeans.org/cnd-main/rev/877112b61f2d
Comment 24 Quality Engineering 2011-11-09 16:08:32 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/98261df35116
User: Vladimir Voskresensky <vv159170@netbeans.org>
Log: fixed #152775 - Instant Renaming refactoring in C goes wrong
- handle issues with main region