$ show antlr/intellij-plugin-v4
The antlr/intellij-plugin-v4 repository is an IntelliJ IDEA plugin that provides comprehensive language support for ANTLR v4 grammar files (.g4). It offers syntax highlighting, real-time error checking, code navigation, refactoring capabilities (such as rule extraction and inlining), live parse tree preview, grammar profiling, and code generation. The plugin integrates deeply with the IntelliJ Platform SDK, implementing extension points like FileTypeFactory, ParserDefinition, SyntaxHighlighterFactory, ExternalAnnotator, StructureViewFactory, CompletionContributor, and custom tool windows. Its architecture follows a modular design where core functionality is separated into concerns such as parsing, preview, refactoring, and configuration, utilizing patterns like the adaptor pattern for ANTLR integration, background processing for UI responsiveness, and specialized token streams for incremental parsing.
The LLM identified 4 files worth highlighting for reuse:
Provides a wrapper for ANTLR CharStreams that applies case transformation strategies (e.g., lower, upper, invert) on-the-fly during parsing. Enables case-insensitive preview of grammars without modifying the original grammar, demonstrating a non-obvious solution for handling case sensitivity in language previews.
Implements a token stream that returns only tokens within a specified character range, enabling efficient incremental parsing for editor features like live preview and error checking. Correctly handles token boundaries and state, showcasing expertise in adapting ANTLR's streaming model for interactive environments.
Monitors ANTLR lexer execution in a background thread with timeout protection to prevent UI hangs caused by problematic lexer rules (e.g., left recursion). Demonstrates a robust pattern for isolating potentially blocking operations in interactive language tools.
Contains utility methods for performing grammar refactorings (rule extraction, inlining, literal rule generation) while maintaining grammatical correctness. Handles complex AST modifications and symbol updates, offering a reusable domain-specific library for ANTLR grammar manipulation.