statler / dxcorecommunityplugins

Automatically exported from code.google.com/p/dxcorecommunityplugins
0 stars 0 forks source link

Add MoveIt facility to reorder blocks with a single keystroke #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A request to provide this facility got shunted in this direction from CR
support[1].  It's a generalised form of [2].

As part of reordering code, I'm looking to be able to tetris around
statements or functions in the same way as Ctrl Up and Down work.  Not
looking for any mad UI, just the ability to swap an item with its next or
previous sibling.

I personally think this belongs in the core product.

... Or is this already available?

[1]
http://www.devexpress.com/Support/Center/p/S130885.aspx?searchtext=reorder&p=T4|
P6|0
[2]
http://www.devexpress.com/Support/Center/p/CS60989.aspx?searchtext=reorder&p=T4|
P6|0

Original issue reported on code.google.com by bartel...@gmail.com on 22 May 2009 at 9:26

GoogleCodeExporter commented 9 years ago
Hey bartelink

I was the one to create the original MoveIt plugin detailed in one of those 
requests.

The biggest issue with this sort of plugin is defining what you want to do....

Keys to "Move the *current item* up or down one place" is unfortunately not 
enough.

Defining the *current item* is the crux of the matter ...

Explicit commands could be created for Types and Members as there is little
difficulty defining which is the current method or type. Indeed I think MoveIt 
had
code to move methods up and down already :)

However as soon as you dip into more granular requirements, things get a bit 
messy.

A statement could stand alone or it could be part of a block, a block could 
stand
alone or be part of a larger block.

The question is over "what is the current block or statement?"

Performing the actual move is relatively easy.

Working out what the user wants to move is the hard bit.

Any Ideas are appreciated.

Original comment by RoryBec...@gmail.com on 22 May 2009 at 10:28

GoogleCodeExporter commented 9 years ago
Hi Rory,

With that level of ambiguity, No wonder it has a strong SEP field attractor!

What I had in mind was an "implicit Ctrl-W" behaviour, so it would be like a 
CtrlW,
CtrlX, <the actual move to the target, be that up or down>, paste.  Except it 
wouldnt
obliterate the clipboard contents.

While this wouldnt be perfect in the same way that Ctrl-W isnt [and breaks down 
a lot
inside statements], it would be undoable and would definitely work well for 
Types and
Methods/Properties/Fields, even if it mightnt DWIM for statements within a 
method.

So the location (start of method, start of type, start of statement) would 
dictate
what's moving. Within a statement, it obviously gets harier -- in this case you 
might
build in minefields of behaviour such as selecting the entire statement (I'm 
thinking
how you'd handle a caret on the 'b' in "a && b").

In summary, I'd focus on statement block, type and method.

--R

Original comment by bartel...@gmail.com on 22 May 2009 at 11:07

GoogleCodeExporter commented 9 years ago
Consider 

-------------------------------------------------------------
If Expression1 then 
    ' Path 1
Else
    'Path 2
    If Expression2 Then 
        ' Path2a
    Else
        ' Path 2b
        Call A 
        Call B
        Call C
    Endif
Endif
-------------------------------------------------------------

If your caret is at "Call B" then move statement/block up/down could refer to
multiple things... the Call B, It's parent If block (In C# it could refer to the
Block for just the else block part), of the master if block that parent's 
everything

Additionally ... What if you activate this from within some part of Expression1 
or
Expression2?

:)

Thoughts?

Original comment by RoryBec...@gmail.com on 22 May 2009 at 1:11

GoogleCodeExporter commented 9 years ago
Re doing it on "Call B", CtrlW would only pick Call B so that defines the 
scope. Also
I'd only allow exchanging of siblings to scope out lots more complexity.

When doing it within Expression1 or Expression1, it could be disabled as Ctrl-W 
didnt
yield a statement node (just an expression). (and if you took the entire If
Expression2 block [including the child blocks]], it wouldnt have a sibling even 
if
you did two selection expansion operations)

I do take your point in that the challenging bit would be designing it in a 
general
way to do allow one to perform the operation with multiple adjacent siblings, 
but in
that case you have CtrlW, CtrlX and friends.

The aim here is to have somethig simple that can be tied to a keystroke.  Then  
if
you want to move two bits together you can either manually drop markers [or have
variants or options dialogs that allow implict dropping but that's more than 
likely
going too far].

This BA role of mine is so black and white :)

Original comment by bartel...@gmail.com on 22 May 2009 at 1:36

GoogleCodeExporter commented 9 years ago
One area where there would be less than ideal real world behaviour is in that
DXCore/CR doesnt have any rules re spacing, so if I have

class T
{
  void m()
  {
  }

  void m2()
  {
  }
}

Then when I move up m2, I dont want it swapping with the blank line, I want it
swapped with m.  Same goes for separator lines between batches of statements 
that
belong together in the programmer's head.  In that case, arguably it should skip
blank lines by default (by doing an implicit second action that can be undone 
if desired)

Original comment by bartel...@gmail.com on 22 May 2009 at 1:49

GoogleCodeExporter commented 9 years ago
http://code.google.com/p/dxcorecommunityplugins/wiki/DX_MoveCode definitely 
plays in 
this space, thanks!

Original comment by bartel...@gmail.com on 24 Nov 2009 at 8:31

GoogleCodeExporter commented 9 years ago
Good to hear.
 :D

Original comment by RoryBec...@gmail.com on 24 Nov 2009 at 9:20

GoogleCodeExporter commented 9 years ago
Good to hear.
 :D

Original comment by RoryBec...@gmail.com on 24 Nov 2009 at 12:51

GoogleCodeExporter commented 9 years ago
Ok I'm just reviewing a few of these issues and I came across this one.

It seems I recently ( last couple of months) addressed this in a new plugin 
DX_MoveCode

(see http://code.google.com/p/dxcorecommunityplugins/wiki/DX_MoveCode)

Screencast coming soon on at http://tv.devexpress.com/Rory%20Becker.tags

Original comment by RoryBec...@gmail.com on 11 Feb 2010 at 10:30

GoogleCodeExporter commented 9 years ago

Original comment by RoryBec...@gmail.com on 11 Feb 2010 at 10:31

GoogleCodeExporter commented 9 years ago
Fantastic, thanks. Added some comments to DX_MoveCode page (that probably 
belong here 
:P)

Original comment by bartel...@gmail.com on 11 Feb 2010 at 11:05