[MonoDevelop] Refactoring

Ben Motmans ben.motmans at gmail.com
Thu Jun 30 18:12:02 EDT 2005


Hi,

Like some of you already know, i'm working on refactoring support in
MonoDevelop.
Now, my question to you all is, how should the refactoring behave in MD ?

my current ideas (some of them are partially implemented):

* Encapsulate fields : http://tremor.be/encapsulate_fields.png
   - if inside a class, show a dialog with all fields, method
visibility, field visibility, insertion point, only select the fields
without an existing property
   - if one or more fields are selected, generate the properties
without any other user input if a shortcut is pressed, or show the
dialog with the getter and setter of the fields selected when
selecting "encapsulate fields" from a popup menu
   - insertion point: after constructor, before first property, after
last property, end of file, "Properties" region, current position
   - do we need preview (no) ? should it be undoable by 1 undo command (yes)?

* Generate constructor : http://tremor.be/generate_constructor.png
   - the combobox lists the available constructors from the current
class and the base class, and there is a listview with all fields from
the current class, and the selected constructor
   - generate a constructor without any user input when 1 or more
fields are selected ?
   - insertion point: start of file, before first constructor, after
last constructor, "Constructor" region, current position
   - do we need preview (no) ? should it be undoable by 1 undo command (yes)?

* Rename
   - rename types, variables, fields, properties, ...
   - when renaming fields, there is an extra option to also rename the
properties
   - do we need preview (yes)? should it be undoable by 1 undo command
? --> can we even undo, since it is possible that we modify more then
1 file, so should we set preview on by default ?

* Implement interface
   - create a keyboard shortcut to generate all methods of the
implemented interfaces + abstract methods of the base class
   - show a checklist with all properties and/or methods from an interface
   - posibility to make the class abstract if not all the members of
the interface are selected (+ posibility to change the constructor
access modifier from public to protected/internal)
   - insertion point: after last constructor, region with the name of
the interface at the end of the file, end of file, current position
   - do we need preview (no) ? should it be undoable by 1 undo command ? (yes)

* Generate method stub
   - insertion point: after last constructor, before first method,
after last method, end of file, , current position
   - do we need preview (no) ? should it be undoable by 1 undo command ? (yes)

* Change variable
   - change the type of a variable, and automatically change all
corresponding casts, ... to the new type
   - do we need preview (yes) ? should it be undoable by 1 undo command ? (yes)

* Sort members
   - posibility to sort all members of the class
   - sort in regions, sort alphabetically, sort members according to
their type (field, constructor, method, ...)
   - do we need preview (yes) ? should it be undoable by 1 undo
command ? (no idea)

* Format code : http://tremor.be/codeformat_settings.png
   - preferences that can be changed by the users, used by the
refactoring service to generate code according to the user preferences
   - "Format Code" command, to reformat the current file according to
the user preferences

* ...

* Resources:
   - http://bugzilla.ximian.com/show_bug.cgi?id=62616
   - http://bugzilla.ximian.com/show_bug.cgi?id=62621
   - http://www-128.ibm.com/developerworks/library/os-ecref/
   - http://www.refactoring.com/
   - http://www.intellij.org/twiki/bin/view/Main/RefactoringSuggestionsForIDEA
   - http://refactoring.netbeans.org/refactorings/specifications.html
   - http://java.sun.com/developer/technicalArticles/tools/refactoring/
   - http://www.devexpress.com/Support/BestPractices/IDE/Refactor/

* Random facts
   - refactor service is language independant, so other languages like
vb.net and boo can benefit from it (offcourse, they have to implement
a parser first)
   - the code format settings are also language independant, all the
settings are defined in an .xml file and the preferences dialog is
created dynamically, so adding preferences for another language is
nothing more then creating an .xml file
   - since the C# parser in monodevelop isn't completely finished, i
have no idea how long it is going to take to finish refactoring
support, since i never looked at the parser service in detail i was
hoping i could get some help with it, or maybe port the changes in the
parser from sharpdevelop into monodevelop (if there are any changes)

Let me know what you think, what features would you like to see in
monodevelop, ...
-- Ben


More information about the Monodevelop-list mailing list