API Migration


I am currently trialling Resharper 8 and I am currently looking at writing a plugin to allow the development team to easily migrate a project/solution between 2 different versions of an internal API.

I have got as far as getting a list of files contained within a solution.
I am now looking to replace text within files, what would be the best way of doing this?

Would it be better to use the IPsiSourceFile or a IFile interface?
It is possible to loop through the tokens collection?



1 comment
Comment actions Permalink

Depending on the complexity of your migration, and if this is a one-off migration, you might be better off writing something simpler than a ReSharper plugin to edit the text you've got - perhaps some simple search and replace would be more appropriate for this particular task?

I'm saying this because the ReSharper API is more geared towards refactoring, rather than bulk migrating. That is, it's intended to work with abstract syntax tree (AST) transformations, rather than text replacement. It's possible to modify the text directly, using IDocument or ITextControl, and it's also possible to create new nodes in the syntax tree and manipulate what's already there.

The main page of the development guide is here: http://confluence.jetbrains.com/display/NETCOM/ReSharper+8+Plugin+Development, there are some notes on working with ITextControl here: http://confluence.jetbrains.com/display/NETCOM/2.05+TextControl+%28R8%29 and creating elements for the syntax tree here: http://confluence.jetbrains.com/display/NETCOM/3.02+Creating+Code+Elements+%28R8%29



Please sign in to leave a comment.