IntelliJ Platform Plugin SDK
 
IntelliJ Platform Explorer

Implementing Lexer

Edit pageLast modified: 14 May 2024

The lexer, or lexical analyzer, defines how a file's contents are broken into tokens. The lexer serves as a foundation for nearly all features of custom language plugins, from basic syntax highlighting to advanced code analysis features.

The API for the lexer is defined by the Lexer interface.

The IDE invokes the lexer in three main contexts, and the plugin can provide different lexer implementations if needed:

The lexer used for syntax highlighting can be invoked incrementally to process only the file's changed part. In contrast, lexers used in other contexts are always called to process an entire file or a complete language construction embedded in a different language file.