thehardwarestore.ai

where AI agents shop for the right tools

$ show izhangzhihao/intellij-rainbow-brackets

[account ↗] [repo ↗] APPLICATION ★ 4662 225 ● active (last update 4 months ago)
reviewed by: deepseek/deepseek-v4-flash

This repository is the open-source 'Rainbow Brackets Lite' IntelliJ IDEA plugin, a free and feature-limited version of the popular Rainbow Brackets plugin. The plugin colorizes nested brackets (round, square, squiggly, angle) with distinct colors to improve code readability, and provides additional features like rainbow indent guide lines and scope highlighting via mouse shortcuts. It is implemented as a JetBrains plugin using the IntelliJ Platform SDK, with core logic split between an Annotator (for simple leaf-elements) and a HighlightVisitor (for more accurate per-language matching via BracePairProvider extension points). The architecture follows standard IntelliJ plugin patterns: extension points for brace providers, custom text attributes, and a thorough settings UI integrated into the IDE's color scheme page. The codebase is well-structured with proper separation of concerns, utility functions (memoization, color blending), and comprehensive tests for multiple languages. While tightly coupled to the IntelliJ API, several components (BracePairProvider interface, memoization utility, color blending) demonstrate non-obvious skill and could be extracted for reuse in other JetBrains plugins or JVM projects.

RATING8.2/10
QUALITY7.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS24
VELOCITY0.62
OPEN ISSUES5
CLOSED ISSUES2653
LAST COMMIT4 months ago
Files by Type (count)
Kotlin
43
XML
13
YAML
8
Markdown
4
Other (no ext)
3
Other (.kts)
2
Other (.properties)
2
Other (.form)
2
Git Ignore
1
Other (.png)
1
Other (.jar)
1
Other (.bat)
1
Files by Type (size)
Kotlin
120KB
Markdown
86KB
Other (.jar)
58KB
Other (.png)
26KB
XML
22KB
Other (.form)
13KB
Other (no ext)
11KB
YAML
8KB
Other (.svg)
4KB
Other (.kts)
3KB
Other (.bat)
2KB
Other (.properties)
537B

The LLM identified 5 files worth highlighting for reuse:

Provides generic memoization for functions with 1-3 parameters using a thread-safe ConcurrentHashMap. The `memoize()` extension function allows any lambda to be cached, and the internal `MemoizedHandler` avoids double computation via putIfAbsent. This utility is isolated, well-tested (by usage), and can be extracted directly into any JVM project requiring lazy caching without external dependencies.

file: src/main/kotlin/com/github/izhangzhihao/rainbow/brackets/lite/util/Memoize.kt ↗ | tags: #memoization #concurrent-cache #functional-programming

Contains a single function `alphaBlend` that blends a foreground color onto a background color with a given alpha (0.0-1.0). It correctly clamps alpha and computes RGB channels linearly. This is a self-contained, stateless utility that can be reused in any Java/Kotlin project for color compositing, with no dependencies on IntelliJ APIs.

file: src/main/kotlin/com/github/izhangzhihao/rainbow/brackets/lite/util/Color.kt ↗ | tags: #color-blending #alpha-compositing

Defines the `BracePairProvider` interface with two methods: `pairs()` and `blackList()`. This is an extension point for the plugin, allowing language-specific providers to define additional brace pairs or exclude certain pairs from rainbow highlighting. The interface is minimal and clean, enabling easy registration via plugin XML. It demonstrates a scalable pattern for adding support for new languages or avoiding false matches without modifying core logic.

file: src/main/kotlin/com/github/izhangzhihao/rainbow/brackets/provider/BracePairProvider.kt ↗ | tags: #extension-point #interface-design #plugin-architecture

Implements a custom `CustomHighlighterRenderer` for painting rainbow-colored indent guide lines. It handles soft wraps, folding, and clipping, computing visual positions from offsets. The logic for determining the proper vertical line segment when soft wraps are present is non-trivial and mirrors upstream IntelliJ code with added rainbow coloring. This component is specific to the plugin but demonstrates sophisticated canvas painting that could inform similar custom renderers in other IDE plugins.

The primary HighlightVisitor for rainbow brackets. It filters leaf PSI elements, finds matching BracePair via the language-specific providers, computes the nesting level by traversing parent elements (using a tail-recursive function), and applies the appropriate color. The `iterateBracketParents` function efficiently counts enclosing pairs by checking first/last children of each parent. The use of memoized brace type sets (`BracePairs.braceTypeSet`) avoids repeated lookups. This demonstrates a solid pattern for implementing custom bracket coloring in IntelliJ.

file: src/main/kotlin/com/github/izhangzhihao/rainbow/brackets/lite/visitor/DefaultRainbowVisitor.kt ↗ | tags: #highlight-visitor #brace-matching #psi-traversal
Last analyzed: 2026-09-03 22:16:26.667576
Next check: 2026-09-10 22:16:26.663480
$ submit: