Bug 148114 - Move-refactor should be disabled within C/C++ Project view
Summary: Move-refactor should be disabled within C/C++ Project view
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 3.1   Edit
Hardware: PC Linux
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-21 16:19 EDT by Brent Nicolle CLA
Modified: 2020-09-04 15:22 EDT (History)
1 user (show)

See Also:


Attachments
Disable dropping translation unit members inside CView (1.01 KB, patch)
2006-06-22 04:19 EDT, Anton Leherbauer CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Nicolle CLA 2006-06-21 16:19:17 EDT
Tested in CDT 3.1.0 (I200606210500) upon investigation of bug 141484#c2.
(on linux, but platform independent) (tested prior to fix for 141484)

Move-Refactor looks significantly broken in CDT.

Create a two-class project (X and Y), and add a member A to X.
Notice that you can drag A around the C/C++ Projects View.

Symptoms:
1. Drag a member variable (X::)A onto class Y and A becomes a global variable declared just before Y (expected: class member).
2. Drag A into class Y (on top of another member of Y) and you get a Refactoring Exception dialog stating "invalid sibling"... but A is deleted from X!
3. Repeat #2 with "X.h" and/or "Y.h" closed and you get a "C Model Exception: C Model Status [!element.doesNotExist!]" error dialog, but no code change.

This behaviour and the absence of "Refactor > Move" from the context menu indicates to me that CDT still does not support move refactoring.
Dragging anything anywhere in the C/C++ Project View should be disabled (yet still allow drag to other parts of the workbench).
Users of our product (or even users of JDT) are likely to be surprised by the brokenness of Move-Refactor.

The severity of #2 deleting code (conceivably an inline function body) is the scary one.  You can undo the change IF you notice it's gone, but the editor will have already saved half of the refactoring.  It is not immediately obvious.

Granted, correct implementation of Move-Refactor is a great big feature.

Disabling Move-Refactor (ie. turning the cursor into a no-parking sign) is the easiest short-term fix.
Comment 1 Anton Leherbauer CLA 2006-06-22 04:19:23 EDT
Created attachment 45064 [details]
Disable dropping translation unit members inside CView

That's quite an easy and safe change. 
I am not sure, though, if everyone is OK with disabling it completely, but I wonder if anyone ever relied on that feature at all, given its apparent flaws.
Comment 2 Chris Recoskie CLA 2006-06-22 07:49:05 EDT
I think we can go ahead and apply this for 3.1.  The only other viable alternative right now would be to make move refactoring work, and obviously there is not sufficient time for that for 3.1.

I suggest fixing this and then and open a separate enhancement for enabling move refactoring (if there isn't such a Bugzilla already).
Comment 3 Doug Schaefer CLA 2006-06-22 08:50:23 EDT
I am surprised we are hearing about this now. But, if the feature doesn't work correctly and there's no undo support, then we should turn it off for now.
Comment 4 Anton Leherbauer CLA 2006-06-22 10:17:10 EDT
(In reply to comment #2)
> I suggest fixing this and then and open a separate enhancement for enabling
> move refactoring (if there isn't such a Bugzilla already).

I think the generic refactoring enhancement request (bug 75364) covers this already.

I'll commit this then.
Comment 5 Anton Leherbauer CLA 2006-06-22 10:59:08 EDT
Committed the fix.
Comment 6 Brent Nicolle CLA 2006-06-23 15:29:10 EDT
Thankyou very much Anton!
Verified with 3.1.0 I20060623 on Linux RedHat.

Note:
One side-effect is that moving a file from one directory to another is also
not possible from C/C++ Projects View anymore.  Since moving a file implies
correcting any #include statements (which doesn't happen), this is probably
a bonus side-effect.  It is still possible to move files from
the Navigator view of course, where the user is unlikely to expect any
refactoring of #include statements.

Comment 7 Doug Schaefer CLA 2006-06-23 15:50:08 EDT
No, it's not OK. People move files around all the time. Please test these things before submitting.
Comment 8 Doug Schaefer CLA 2006-06-24 10:17:37 EDT
I have backed out the change. We'll have to try again post 3.1 and only disable drag and drop of elements in a ITranslationUnit, or integrate it with the LTK refactoring so we can get undo support.
Comment 9 Anton Leherbauer CLA 2006-06-26 02:57:28 EDT
(In reply to comment #6)
> One side-effect is that moving a file from one directory to another is also
> not possible from C/C++ Projects View anymore.  

I checked that this is still possible and I cannot see why it should be disabled. Could you verify once more, please?
Comment 10 Chris Recoskie CLA 2006-06-26 09:24:49 EDT
(In reply to comment #9)
> (In reply to comment #6)
> > One side-effect is that moving a file from one directory to another is also
> > not possible from C/C++ Projects View anymore.  
> I checked that this is still possible and I cannot see why it should be
> disabled. Could you verify once more, please?

The move operation for the file can still be done, but you get the "no-parking" sign the whole time while you do it.  This leads the user to believe they cannot drag n' drop the file anywhere, even though they still can.
Comment 11 Anton Leherbauer CLA 2006-06-27 05:31:25 EDT
It appears that the behaviour is platform dependent. My observation is:
- On WinXP everything works as expected.
- On Linux/GTK (RedHat EL 4), I cannot move files (copying works), 
  although the DnD feedback cursor gives the impression that it is possible.

I tried with CDT I200606120500 (RC3), I200606230500 and I200606261600 (RC4?) - it's all the same, ie. moving files was broken before the patch was applied and it is still broken after the patch has been backed out. 

Sorry for being a nuisance, but I need to clarify this.
Comment 12 Brent Nicolle CLA 2006-06-27 15:56:39 EDT
I suspected this was platform dependent behaviour I was seeing.
I attempted to reproduce on Windows yesterday, but ran into download issues.

From your investigation, it's obvious that the Linux behaviour is an
independent bug.
Sorry Anton that my comment led to your patch being rejected.
Comment 13 Anton Leherbauer CLA 2006-07-21 05:41:23 EDT
Are there still any concerns that the patch breaks DnD of files in the C/C++ Projects view?
Comment 14 Doug Schaefer CLA 2006-07-21 10:52:41 EDT
I'm still concerned if that's what you mean? Whatever you do to fix this, make sure that you can still move files around in the project in the C/C++ Project View.
Comment 15 Anton Leherbauer CLA 2006-07-24 05:10:07 EDT
To be clear, my believe is that the patch does not break file DnD (comment 11), but I may have overlooked something and I cannot test each and every possible configuration, therefore I would like confirmation from those who have expressed concerns that the patch would break the DnD of files (comment 6, comment 7, comment 10).
I just wanted to make sure I really don't break anything before applying the same patch once more.
BTW, I have created bug 151571 for the file DnD problem on Linux-GTK.
Comment 16 Chris Recoskie CLA 2006-07-24 08:22:08 EDT
> configuration, therefore I would like confirmation from those who have
> expressed concerns that the patch would break the DnD of files (comment 6,
> comment 7, comment 10).

Well the patch hasn't changed, and it was broken for me on Windows XP when I last tried it out (comment #10), so I would think it would still behave as I indicated in comment #10.
Comment 17 Anton Leherbauer CLA 2006-07-24 09:10:13 EDT
Comment on attachment 45064 [details]
Disable dropping translation unit members inside CView

My apologies. You are right. The patch indeed breaks DnD of files. I don't know how I could overlook this. Sorry for all the confusion.