ReSharper Platform SDK
 
Because ReSharper Platform SDK undefined is still in development, this documentation may not be entirely accurate and is subject to change.

Project File Language Service

Last modified: 04 July 2023

If a custom language defines a ProjectFileType, it must also associate that file type with a PSI language type, which ReSharper can use to build a PSI tree of the file's contents. The IProjectFileLanguageService interface provides this functionality, and can be considered as a bridge between the Project Model and the PSI.

The project file language service is implemented as a per-file type component. Given a ProjectFileType, it is possible to retrieve that file type's project file language service, which exposes the custom language's PsiLanguageType. This can be used as the key to retrieve all per-language components, and get access to the custom language's lexer and parser, to build a PSI tree.

The IProjectFileLanguageService interface is as follows:

The members are as follows:

  • LanguageType - confusingly called LanguageType, this is the singleton instance of the derived ProjectFileType class that represents the Project Model file type of this language.

  • Icon - the IconId of the icon used to represent this file. This is used whenever ReSharper needs to display the icon for a file of this type, such as in the Find Results tool window. See the section on icons for more details on icons.

  • GetPreprocessorDefines - retrieves a list of preprocessor symbols that are defined for the current project, as this affects the parsing of the PSI tree. This is typically only required for compiled languages in a project where the project itself has a specific language, e.g. a C# project.