Class PmdKotlinParser

All Implemented Interfaces:
Parser

public final class PmdKotlinParser extends AntlrBaseParser<KotlinNode,KotlinParser.KtKotlinFile>
Adapter for the KotlinParser.

Each parse injects a fresh InterruptibleParserATNSimulator with its own DFA arrays and PredictionContextCache. Using per-parse instances avoids lock contention when PMD parses files in parallel, which would otherwise cause severe performance degradation due to the complexity of the Kotlin grammar.

A per-file parse timeout acts as a safety net. Files exceeding the timeout are skipped with a processing error. The timeout is configured via KotlinLanguageProperties.PARSE_TIMEOUT_SECONDS.

Error handling strategy:

  • Lexer errors (e.g. unrecognized tokens) and Parser errors (e.g. unexpected token structure) are collected and lexing/parsing continues.
  • Further lexer/parser errors are collected as suppressed exceptions.
  • The first occurred lexer/parser exception is thrown at the end and no rules are executed.

PMD reports the file as a ProcessingError and skips rule analysis for it. All other files continue to be processed. Exit code 5 is returned by the CLI if any processing errors occurred (suppressible with --no-fail-on-error).