IDE assistance for KotlinPoet format strings β catch mistakes before your tests do.
Brings first-class IDE support for CodeBlock format strings directly into IntelliJ IDEA. If you use KotlinPoet to generate Kotlin code, this plugin helps you write format strings confidently β with real-time validation, smart navigation, inline documentation, and a live preview of what your builder chain will produce.
Note
Results are approximations. This plugin is a development aid, not a code generator. Some previews may differ from the actual KotlinPoet runtime output (e.g., import resolution, indent context, variables). When in doubt, trust your tests.
- π΄ Inspections β Missing arguments, extra arguments, type mismatches, invalid named keys, and format syntax errors, all reported inline with quick fixes.
- π¨ Syntax Highlighting β Placeholders (
%L,%S,%T, β¦) and control symbols (Β«,Β»,β₯,β€, β¦) are highlighted in a distinct color so they stand out from surrounding string content. - π Navigate to Argument β
Ctrl+Click(orCmd+Click) on a placeholder jumps straight to the argument it is bound to. - π Inline Documentation β Hover over any placeholder or control symbol for a quick-doc popup with a description and a link to the official KotlinPoet docs.
- β
Completion β Typing
%inside a CodeBlock format string pops up a completion list for all supported placeholders (%L,%S,%T,%N,%M,%P,%%). - π Find Usages β Find all format-string positions that reference a particular argument, alongside the argument declaration itself.
- πͺ Chain Preview Tool Window β A bottom tool window that shows the approximated output of the entire CodeBlock builder chain at the current caret, complete with per-call metadata, state-machine violations, and an indented text preview.
- π‘ Inlay Hints β Optional per-call end-of-line hints showing the approximate emission of each builder call,
plus a collapsible block preview above the terminal
build()call.
Click to expand
- Open Settings / Preferences β Plugins β Marketplace.
- Search for KotlinPoet Assistant.
- Click Install and restart the IDE.
- Download the latest
.zipfrom Releases. - Open Settings / Preferences β Plugins β βοΈ β Install Plugin from Diskβ¦
- Select the downloaded file and restart.
Requirements:
- IntelliJ IDEA 2025.2+ (build 252+)
- Kotlin plugin enabled with K2 (bundled)
- Your project uses KotlinPoet β₯ 1.x
All inspections are grouped under KotlinPoet in Settings β Editor β Inspections.
| Inspection | Default Level | What it detects |
|---|---|---|
| Missing argument | Error | A placeholder like %L with no corresponding argument β causes IllegalArgumentException at runtime |
| Extra argument | Error / Info | An argument with no matching placeholder β runtime crash for relative/positional, informational for named maps |
| Argument type mismatch | Warning / Info | Passing a Boolean where %T expects a TypeName, etc. |
| Named argument case | Warning | A key in addNamed(β¦, mapOf(β¦)) that doesn't start with a lowercase letter β KotlinPoet enforces [a-z]+[\w_]* |
| Format syntax | Error | Dangling %, unknown placeholder type (%Z), invalid positional index (%0L), or mixed argument styles |
Each inspection comes with one or more quick fixes:
- Remove extra argument β deletes the surplus argument from the call site.
- Rename 'X' to 'x' β renames an uppercase named-argument key in both the format string and the map literal simultaneously.
- Escape as
%%β replaces a dangling%with the correct literal-percent escape. - Remove invalid format token β deletes an unknown placeholder type like
%Z. - Fix index to
%1Xβ repairs a zero-based positional index to the 1-based form KotlinPoet expects. - Convert to named / relative / positional style β resolves mixed-style errors with a live template that lets you name each placeholder interactively.
Placeholders (%L, %2S, %food:T, β¦) and control symbols (Β«, Β», β₯, β€, %%, Β·, β’) receive their own color
key so they are visually distinct from the rest of the string. Colors respect the active theme.
Every placeholder in a format string is a navigable reference. Ctrl+Click on %L jumps to the expression passed as
that argument. Find Usages on an argument expression highlights every placeholder that references it across the file.
Supports relative, positional, and named (addNamed) styles inline or variable.
Hover the cursor over any placeholder or control symbol to see:
- A short description of what it emits.
- The accepted argument types.
- A direct link to the corresponding section of the KotlinPoet documentation.
Typing % inside a KotlinPoet format string argument immediately opens a completion list.
Each item shows the placeholder letter, a human-readable type label, and a short description.
Works in add, addStatement, addCode, addNamed, beginControlFlow, nextControlFlow, and CodeBlock.of.
Open via View β Tool Windows β KotlinPoet Chain (or the bottom bar button).
Move the caret into any KotlinPoet builder call to see:
- A per-call row for every call in the chain, with the method name, semantic tag (
[stmt],[begin],[end], β¦), and an approximation of what that call emits. - State machine violations highlighted in red β e.g., an
endControlFlow()with no matchingbeginControlFlow(), or an unclosedΒ«statement. - A text preview section showing the indented, rendered approximation of the full CodeBlock.
- Clickable call names that navigate back to that call in the editor.
Important
Approximation notice: The preview is a best-effort static analysis. Dynamic arguments (variables, function calls)
may appear as [%L]. Import handling and runtime indent context are not simulated.
Limitation notice: Nested CodeBlocks are supported with one depth limit. Only the current call of the caret is shown and updated on change. Violations can't be detected in all cases or can be a false positive.
Enable in Settings β Editor β Inlay Hints β Others β Kotlin β KotlinPoet code preview.
- Per-call hints β a faint end-of-line annotation showing the approximate output of each builder call.
- Chain preview hint β a collapsible block element above the terminal
build()(orof()) call showing the full indented preview. Click to expand/collapse.
Both hints are configurable: max preview lines, max line length, and individual on/off toggles.
| Style | Example | Supported |
|---|---|---|
| Relative | add("I ate %L %L", 3, "tacos") |
β |
| Positional | add("I ate %2L %1L", "tacos", 3) |
β |
| Named | addNamed("I ate %count:L %food:L", map) |
β |
addStatement |
addStatement("val x = %L", 42) |
β |
beginControlFlow / nextControlFlow / endControlFlow |
beginControlFlow("if (%L)", cond) |
β |
CodeBlock.of / buildCodeBlock { } |
CodeBlock.of("%T()", MyClass::class) |
β |
addKdoc |
addKdoc("@param %L the value", "name") |
β (without preview yet) |
| Custom delegating wrappers | Your own extension or method with CodeBlock.Builder |
β (detected automatically*) |
- Dynamic format strings (variables, string templates
"$var") are not analyzed β the plugin only processes string literals and literal concatenations. trimIndent(),trimMargin(), and similar transformations applied to the format string are not supported. (stay tuned for a future feature!)- The chain preview is an approximation β import resolution, runtime indent context, and
%Ncollision avoidance are not simulated. - Named argument validation is skipped when the map is passed as an external variable (not an inline
mapOf(β¦)literal), to avoid false positives or can't resolve the variable. - Requires K2 compiler mode (IntelliJ 2025.2+, Kotlin plugin with K2 enabled). K1 is not supported.
- Not all KotlinPoet methods arenβt supported yet.
- Not all custom wrappers arenβt supported yet.
If the IDE captures an exception from this plugin, a Report to GitHub button will appear in the error balloon. Clicking it:
- Copies the full stack trace to your clipboard.
- Opens a pre-filled GitHub issue with your IDE version, OS, and JVM info.
Please paste the stack trace into the issue before submitting β it is in your clipboard.
You can also open an issue manually in the issue tracker.
Contributions are welcome! A few areas where help is especially appreciated:
- Translations β The plugin UI is currently in English and Spanish. If you'd like to add a language,
open a PR adding a
messages/MyBundle_XX.propertiesfile. - IntelliJ version support β If you need support for an older or newer IntelliJ build range, please open an issue and we'll check compatibility.
- Bug reports and feature requests β Use the issue tracker.
git clone https://github.com/kingg22/kotlinpoet-assistant-plugin.git
cd kotlinpoet-assistant-plugin
# Run the IDE with the plugin loaded
./gradlew runIde
# Run all tests
./gradlew check
# Build the distributable zip
./gradlew buildPluginApache 2.0 License β Β© 2026 Rey Acosta (Kingg22)
This plugin is not affiliated with or endorsed by Square or KotlinPoet.
Made with β€οΈ by Rey A. with help from Claude Β· Report an issue Β· KotlinPoet Official docs








