How-To's

ReSharper 7 Overview for Plugin Developers

Every new release of ReSharper brings new features and possibilities for plugin writers, and also introduces changes in the API — sometimes small, sometimes substantial — that plugin writers need to accomodate to get their plugins supported under the new release. This blog post is an overview of the significant changes that have been made in the API as well as changes in the SDK that were made to make developers’ lives easier.

Support for New Languages

Since the release of the ReSharper SDK, we have consistently received questions on how to use the SDK to create support for new programming languages. While the functionality was always there, we thought we’d step up our game a little and, in the 7.0 release, we offer a comprehensive set of tools and samples that greatly simplify the process of adding support for new languages.

The Tools

Support of new languages in ReSharper necessitates the construction of lexers and parsers for those languages, and subsequent adaptation of the generated structures to interoperate with the rest of the ReSharper API. To make the process easier, the SDK now ships with a Tools folder that contains the following:

  • CsLex — a tool for creating lexical analysers for different languages.

  • parserGen — a tool for creating ReSharper-compatible parsers.

  • Java — this folder contains the IKVM infrastructure which permits the running of the Java-based parser generator.

  • MSBuild — contains build tasks that can be used to automate lexer and parser construction.

When put together, the above tools allow the plugin developer to define the appropriate lexing/parsing structures and generate ReSharper-compatible code.

The Samples

One of the packaged tools, parserGen, consumes parser definitions (PSI files) which are themselves part of a well-defined language. So we thought: why not kill two birds with one stone? As a result, the SDK comes with a PsiPlugin sample that supports the PSI file format. This serves two purposes:

  • The sample plugin itself fully illustrates the various aspects of creation of ReSharper plugins with new language support. In addition, the plugin comes with a comprehensive set of tests, demonstrating how language plugins should be tested.

  • The plugin offers comprehensive support when working with parser definition (PSI) files. Thus, the plugin itself is indispensable to developers working with new language definitions.

In addition to the sample that comes with the SDK, you might want to check out FSharper — an open-source ReSharper plugin that aims to enhance ReSharper with full F# support. FSharper is a community-driven effort, so contributions are most welcome.

Multi-Level Bulb Menus

The support for multi-level bulb menus (a.k.a. submenus) has been in ReSharper for a while, but wasn’t always easy to work with. In ReSharper 7, we made the API simple and accessible. The new BulbMenu-based API is now available to use in components such as Quick-Fixes and Context Actions — perfect for those rare cases when you ‘need to go deeper’. To find out more, check out the Quick-Fixes and Context Actions section of the Plugin Development Guide.

Odds and Ends

A few more minor changes are worth mentioning.

First, we are still transitioning to a new way of dealing with multi-language files (such as, e.g., JSON embedded in HTML in JS Windows Store apps). The new mechanism, called injected PSI, has caused certain minor changes to both the way PSI files are acquired as well as the ways in which daemons function. To learn more about these changes, check out the Multi-Language PSI and Daemons and Daemon Stages sections respectively.

Also, due to the introduction of theming in Visual Studio 2012 as well as our migration to WPF-based UI, the API for handling images within ReSharper has changed. To help you make the transition, the SDK ships with special build actions that can help you compile your image resources in the correct way, whether they are XAML vector graphics or ordinary PNG images. See the Icons section for more details.

We have summarized possible migration issues in a separate section of the Dev Guide titled Migration from ReSharper 6.x. If you are a plugin developer and have encountered a migration issue that we haven’t documented, please let us know and we’ll add it to the migration guide.

A Big Thank-You

Lastly, we’d like to thank all plugin developers for being part of the ReSharper ecosystem and making ReSharper even more awesome. Thanks everyone!

And if you’re not a plugin developer yet, but have an idea for that awesome plugin, why not grab the SDK today and give it a go? Remember – we’re always happy to help, so feel free to ask us questions on StackOverflow, our Forums, via Twitter (@jetbrains) or any other way you find convenient.

Once again, thanks — and happy coding!

image description