The ReSharper API

ReSharper provides Open API, which is the same API that has been used to create all the features of ReSharper.

Note

As we would like to introduce you to only some basic concepts related to creating plugins in this book, we will quickly describe only the most important ones.

From an architectural point of view, the ReSharper API is divided into the following three layers:

  • Platform
  • Program Structure Interface (PSI)
  • Features

When you are working on a plugin project, you can easily find the related assemblies based on their names, which are as follows:

  • JetBrains.Platform.ReSharper.*
  • JetBrains.ReSharper.Psi.*
  • JetBrains.ReSharper.Features.* and JetBrains.ReSharper.Feature.Services.*

The hierarchy of these levels is presented in the following screenshot:

The ReSharper API

It is important to understand the responsibilities of these layers.

Platform

Platform is the first base layer, which allows you to work directly with the Visual Studio API.

The most important modules that you can find here are as follows:

  • Project model: This is used to work with the Visual Studio project
  • Text control: This allows you to work with the Visual Studio editor
  • Utils: This provides some useful tools for reading/writing XML, specialized collections, filesystem path, and so on
  • Component model: This provides the ReSharper IoC container

In the case of the component model, there are two types of components: shell components (created when the Visual Studio shell is created) and solution components (created when the Visual Studio solution is opened).

Program Structure Interface (PSI)

PSI is the most used layer as it serves as a parser for languages supported by ReSharper. It builds Abstract Syntax Tree (AST), which you can access and navigate to through your plugin.

Features and plugins

In the top level, we have the features and plugins that we can see in ReSharper, such as navigation, code competition, and live templates. As you can see, built-in features are on the same level as plugins, which means that you, as a plugin developer, have access to the same methods as JetBrains developers, who create new features.

Daemons

Additionally, you can find JetBrains.ReSharper.Daemon.* assemblies, which are responsible for background tasks and code analysis.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.213.44