+ 2 - 4 | § ¶Refactoring
I've been working lately on a refactoring API for MonoDevelop. The reason for working on this is that I need it for the Glade integration. This integration goes far beyond embedding the Glade windows into the MD workbench: there will be a tight link between the dialog being designed and the class that implements its behavior. Here are some things I have planned (some of them are already working):- A Command for adding a variable for a widget.
- Renaming a widget in the designer will rename the corresponding
field in the class, and will rename also all local references to the
field.
- Adding a signal handler in the designer will create a handler method in the class, using the correct delegate signature.
- Renaming a signal handler in the designer will rename the method in the class, and all local references to the method.
- Renaming the dialog will rename the class.
public class CodeRefactorerSupport for refactoring can be added to any language by implementing an IRefactorer interface, which has more or less the same methods. I'm using the System.CodeDom object model to provide the information needed to generate code. It doesn't mean that the target language needs to have a CodeDom provider, but if it does a lot of functinality will be available by just subclassing BaseRefactorer. In any case, there are some language-specific methods that always need to be implemented.
{
public IClass CreateClass (Project project, string language,
string directory, string namspace, CodeTypeDeclaration type);
public void RenameClass (IClass cls, string newName, RefactoryScope scope);
public MemberReferenceCollection FindClassReferences (IClass cls, RefactoryScope scope);
public IMember AddMember (IClass cls, CodeTypeMember member);
public void RemoveMember (IClass cls, IMember member);
public IMember RenameMember (IClass cls, IMember member, string newName, RefactoryScope scope);
public MemberReferenceCollection FindMemberReferences (IClass cls, IMember member, RefactoryScope scope);
public IMember ReplaceMember (IClass cls, IMember oldMember, CodeTypeMember member);
}
I don't have immediate plans for implementing the GUI for refactoring, so volunteers are welcome