Files
openide/platform/syntax/syntax-api
Mikhail Filippov 67e3eba466 [build] IJPL-232588 update Kotlin compiler to 2.3.20-RC2
(cherry picked from commit 02cf3f93e77aa26b098c5c0d52caa4cf1af5078c)

IJ-MR-194445

GitOrigin-RevId: 05535bc07df7b591784f6973de9e8ce1751041f5
2026-03-04 22:14:34 +00:00
..

Syntax Library

IntelliJ Platform Syntax Library provides an engine for parsing files. See Syntax PSI library for more information on how to build PSI tree

Main concepts

com.intellij.platform.syntax.SyntaxElementType represents a type of a node in the syntax tree (both for leafs and composites).

com.intellij.platform.syntax.parser.SyntaxTreeBuilder allows parsing the tree. You can obtain an instance of SyntaxTreeBuilder with the help of com.intellij.platform.syntax.parser.SyntaxTreeBuilderFactory.

com.intellij.platform.syntax.parser.ProductionResultKt.prepareProduction allows to obtain the raw result of parsing.

com.intellij.platform.syntax.lexer.Lexer provides lexing functionality.

Example of usage

val builder = SyntaxTreeBuilderFactory.builder(
  text = "my file text", 
  whitespaces = setOf(SyntaxTokenTypes.WHITE_SPACE),
  comments = emptySet(),
  lexer = myLexer
)
val marker = builder.mark()
parseMyFileContent()
marker.done(type = MyLangSyntaxElementTypes.FILE)

val production = prepareProduction(builder = builder)