Skip to content

Use IDEA code highlighting functionality#922

Merged
egorikftp merged 1 commit into
mainfrom
feature/idea-code-hightlight
Mar 2, 2026
Merged

Use IDEA code highlighting functionality#922
egorikftp merged 1 commit into
mainfrom
feature/idea-code-hightlight

Conversation

@egorikftp

Copy link
Copy Markdown
Member
Before After
image image
image image

📝 Changelog

If this PR introduces user-facing changes, please update the relevant Unreleased section in changelogs:

@egorikftp egorikftp requested a review from t-regbs March 2, 2026 08:18
@egorikftp egorikftp force-pushed the feature/idea-code-hightlight branch from c6c1d04 to 83af629 Compare March 2, 2026 08:19
@coderabbitai

coderabbitai Bot commented Mar 2, 2026

Copy link
Copy Markdown

Walkthrough

Replaces the previous highlights system in the IDEA plugin with a HighlightedCode-based approach: removes the highlightsCore dependency and the KtCodeViewer component; adds CodeHighlight utilities (rememberCodeHighlight, HighlightedCode value class, underline DSL) and an EditorText composable; updates call sites and function signatures to accept HighlightedCode and adjusts previews to use ProjectPreviewTheme. The changelog gains an Unreleased entry.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Use IDEA code highlighting functionality' directly and specifically describes the main change in the PR, which involves migrating to IDEA code highlighting for code tooltips.
Description check ✅ Passed The PR description includes issue reference (#920), visual before/after comparisons, and the changelog checklist template, adequately documenting the changes.
Linked Issues check ✅ Passed All code changes implement the migration to IDEA code highlighting (#920): new highlighting utilities created, deprecated components removed, and all usages updated to leverage IDEA's native highlighting.
Out of Scope Changes check ✅ Passed All changes are directly related to the IDEA code highlighting migration (#920). No unrelated modifications detected in the codebase changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/idea-code-hightlight

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt (1)

25-29: Preview doesn't demonstrate EditorText functionality.

The preview renders a plain Text component instead of using the EditorText composable it's meant to showcase. However, since rememberCodeHighlight requires LocalProject context (provided by ProjectPreviewTheme), this preview would need to be updated to use ProjectPreviewTheme like other previews in this PR.

♻️ Suggested fix
+import io.github.composegears.valkyrie.jewel.highlight.rememberCodeHighlight
+
 `@Preview`
 `@Composable`
-private fun EditorTextPreview() = PreviewTheme(alignment = Alignment.Center) {
-    Text(text = "editor text style")
+private fun EditorTextPreview() = ProjectPreviewTheme(alignment = Alignment.Center) {
+    EditorText(code = rememberCodeHighlight(text = "val x: Int = 42"))
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt`
around lines 25 - 29, The EditorTextPreview currently renders a plain Text
instead of using the EditorText composable and lacks the LocalProject context
required by rememberCodeHighlight; update the preview function EditorTextPreview
to wrap its content in ProjectPreviewTheme (like other previews in this PR) so
LocalProject is provided, and instantiate EditorText (not Text) with an
appropriate sample code string and any required params so rememberCodeHighlight
can run in preview.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeHighlight.kt`:
- Around line 24-61: The underline end index is off-by-one because addStyle
expects an exclusive end; update the styling loop in rememberCodeHighlight to
use range.endInclusive + 1 (or range.last + 1) when calling addStyle for each
entry in dsl.ranges (from UnderlineDsl), and clamp the computed end to the
annotated string length to avoid out-of-bounds indices when building the
AnnotatedString with SpanStyle.

---

Nitpick comments:
In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt`:
- Around line 25-29: The EditorTextPreview currently renders a plain Text
instead of using the EditorText composable and lacks the LocalProject context
required by rememberCodeHighlight; update the preview function EditorTextPreview
to wrap its content in ProjectPreviewTheme (like other previews in this PR) so
LocalProject is provided, and instantiate EditorText (not Text) with an
appropriate sample code string and any required params so rememberCodeHighlight
can run in preview.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc5f8f2 and 83af629.

📒 Files selected for processing (9)
  • tools/idea-plugin/CHANGELOG.md
  • tools/idea-plugin/build.gradle.kts
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeHighlight.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeTooltip.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/KtCodeViewer.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/mode/iconpack/common/CodeTooltipHeader.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/mode/iconpack/common/IconPackEditor.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/settings/tabs/generator/GeneratorSettingsScreen.kt
💤 Files with no reviewable changes (2)
  • tools/idea-plugin/build.gradle.kts
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/KtCodeViewer.kt

@egorikftp egorikftp force-pushed the feature/idea-code-hightlight branch 2 times, most recently from ac13252 to 9275c61 Compare March 2, 2026 08:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt (1)

25-29: Preview does not exercise the EditorText composable.

The preview renders a plain Text with a hardcoded string instead of using the EditorText composable with rememberCodeHighlight. This means the actual rendering path isn't being previewed. Additionally, other files in this PR use ProjectPreviewTheme (which provides LocalProject), but this preview uses PreviewTheme.

Since rememberCodeHighlight requires LocalProject.current (per CodeHighlight.kt), using ProjectPreviewTheme would be necessary to properly preview EditorText.

Suggested fix
 `@Preview`
 `@Composable`
-private fun EditorTextPreview() = PreviewTheme(alignment = Alignment.Center) {
-    Text(text = "editor text style")
+private fun EditorTextPreview() = ProjectPreviewTheme(alignment = Alignment.Center) {
+    EditorText(code = rememberCodeHighlight(text = "val example: String = \"Hello\""))
 }

Also update the import:

-import io.github.composegears.valkyrie.jewel.tooling.PreviewTheme
+import io.github.composegears.valkyrie.jewel.tooling.ProjectPreviewTheme
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt`
around lines 25 - 29, The preview currently renders a plain Text instead of
exercising EditorText and doesn't provide LocalProject; update EditorTextPreview
to wrap its content in ProjectPreviewTheme (so LocalProject is available) and
call EditorText using rememberCodeHighlight with a sample code string to
exercise the actual rendering path (keep the PreviewTheme import replaced by
ProjectPreviewTheme import). Ensure you reference EditorTextPreview, EditorText,
rememberCodeHighlight, ProjectPreviewTheme and LocalProject when making the
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt`:
- Around line 25-29: The preview currently renders a plain Text instead of
exercising EditorText and doesn't provide LocalProject; update EditorTextPreview
to wrap its content in ProjectPreviewTheme (so LocalProject is available) and
call EditorText using rememberCodeHighlight with a sample code string to
exercise the actual rendering path (keep the PreviewTheme import replaced by
ProjectPreviewTheme import). Ensure you reference EditorTextPreview, EditorText,
rememberCodeHighlight, ProjectPreviewTheme and LocalProject when making the
change.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 83af629 and 9275c61.

📒 Files selected for processing (9)
  • tools/idea-plugin/CHANGELOG.md
  • tools/idea-plugin/build.gradle.kts
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeHighlight.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeTooltip.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/KtCodeViewer.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/mode/iconpack/common/CodeTooltipHeader.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/mode/iconpack/common/IconPackEditor.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/settings/tabs/generator/GeneratorSettingsScreen.kt
💤 Files with no reviewable changes (2)
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/KtCodeViewer.kt
  • tools/idea-plugin/build.gradle.kts
✅ Files skipped from review due to trivial changes (1)
  • tools/idea-plugin/CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/mode/iconpack/common/CodeTooltipHeader.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeHighlight.kt

@egorikftp egorikftp force-pushed the feature/idea-code-hightlight branch from 9275c61 to ff30bc6 Compare March 2, 2026 09:13

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeHighlight.kt (1)

33-35: Consider adding project as a remember key.

If the project instance ever changes during the composable's lifecycle, the cached codeHighlighter would become stale. While this is unlikely in typical usage, adding project as a key would make the code more defensive.

♻️ Optional: Add project as remember key
-    val codeHighlighter = remember { CodeHighlighterFactory.getInstance(project).createHighlighter() }
+    val codeHighlighter = remember(project) { CodeHighlighterFactory.getInstance(project).createHighlighter() }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeHighlight.kt`
around lines 33 - 35, The remember block that creates codeHighlighter should
include the current project as a key so the cached highlighter is recreated if
LocalProject.current changes; update the remember usage around
CodeHighlighterFactory.getInstance(project).createHighlighter() to pass project
as the key (i.e., remember(project) { ... }) so codeHighlighter is always valid
for the current LocalProject.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeHighlight.kt`:
- Around line 33-35: The remember block that creates codeHighlighter should
include the current project as a key so the cached highlighter is recreated if
LocalProject.current changes; update the remember usage around
CodeHighlighterFactory.getInstance(project).createHighlighter() to pass project
as the key (i.e., remember(project) { ... }) so codeHighlighter is always valid
for the current LocalProject.

ℹ️ Review info

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9275c61 and ff30bc6.

📒 Files selected for processing (9)
  • tools/idea-plugin/CHANGELOG.md
  • tools/idea-plugin/build.gradle.kts
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeHighlight.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/CodeTooltip.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/KtCodeViewer.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/mode/iconpack/common/CodeTooltipHeader.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/mode/iconpack/common/IconPackEditor.kt
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/settings/tabs/generator/GeneratorSettingsScreen.kt
💤 Files with no reviewable changes (2)
  • tools/idea-plugin/build.gradle.kts
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/highlight/KtCodeViewer.kt
🚧 Files skipped from review as they are similar to previous changes (3)
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/ui/screen/settings/tabs/generator/GeneratorSettingsScreen.kt
  • tools/idea-plugin/CHANGELOG.md
  • tools/idea-plugin/src/main/kotlin/io/github/composegears/valkyrie/jewel/EditorText.kt

@egorikftp egorikftp merged commit 701426e into main Mar 2, 2026
3 checks passed
@egorikftp egorikftp deleted the feature/idea-code-hightlight branch March 2, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[IntelliJ] Migrate to IDEA code highlighter for code tooltips

2 participants