Skip to content

Drop KaContextReceiver usage for KaContextParameterSymbol#179

Merged
skydoves merged 1 commit into
mainfrom
fix/drop-kacontextreceiver
Jul 3, 2026
Merged

Drop KaContextReceiver usage for KaContextParameterSymbol#179
skydoves merged 1 commit into
mainfrom
fix/drop-kacontextreceiver

Conversation

@skydoves

@skydoves skydoves commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Fixes #177, reported by a JetBrains engineer: IDEA 2026.3 deprecates and drops the context-receiver API surface (KaContextReceiver, KaContextReceiversOwner) see KT-87288 and KT-87310. This migrates the plugin to context parameters (KaContextParameterSymbol), which are stable as of Kotlin 2.4.

IDEA 2026.3 removes KaContextReceiver and KaContextReceiversOwner (KT-87288, KT-87310). Migrate the K2 receiver-stability analysis to KaContextParameterSymbol, which is stable as of Kotlin 2.4. The context type is now read via KaContextParameterSymbol.returnType; stability grading is unchanged, and both required opt-ins (@KaExperimentalApi, @KaImplementationDetail) are already enabled.

Fixes #177
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Updates StabilityAnalyzerK2.kt to use the Kotlin Analysis API's KaContextParameterSymbol (functionSymbol.contextParameters) instead of the obsolete contextReceivers/KaContextReceiver API for receiver stability analysis, adding the corresponding import.

Changes

Context Parameter API Migration

Layer / File(s) Summary
Receiver analysis migrated to context parameters
compose-stability-analyzer-idea/.../StabilityAnalyzerK2.kt
analyzeReceivers now iterates functionSymbol.contextParameters and reads contextParameter.returnType instead of contextReceivers/contextReceiver.type; adds the contextParameters import and updated migration comments.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning Description is off-template and omits the required Goal, Implementation details, Explain examples, and Preparing for review sections. Rewrite the PR body using the repository template and include the missing sections, especially the goal, implementation details, concrete examples, and review/prep steps.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code migrates the reported KaContextReceiver usage to KaContextParameterSymbol as requested in #177.
Out of Scope Changes check ✅ Passed The diff stays in the single analysis file and only performs the API migration described by the issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed Title clearly reflects the main change: replacing context-receiver API usage with context parameters.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/drop-kacontextreceiver

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.

@skydoves skydoves merged commit 7f68d4c into main Jul 3, 2026
9 of 10 checks passed
@skydoves skydoves deleted the fix/drop-kacontextreceiver branch July 3, 2026 10:27

@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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/StabilityAnalyzerK2.kt (1)

191-207: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Guard contextParameters behind a linkage-safe fallback

Kotlin 2.4 introduced KaContextParameterSymbol, but this module still advertises sinceBuild = "242". functionSymbol.contextParameters can throw NoClassDefFoundError / AbstractMethodError on older bundled Kotlin APIs, and the current catch (e: NoSuchMethodError) / catch (e: Exception) won’t catch those. Catch LinkageError (or otherwise guard this access) so the PSI fallback still kicks in on 242-era IDEs.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/StabilityAnalyzerK2.kt`
around lines 191 - 207, The `StabilityAnalyzerK2` path that iterates
`functionSymbol.contextParameters` is not safe on older bundled Kotlin APIs,
since it can throw linkage failures before the PSI fallback runs. Update the
context-parameter branch to guard that access in a linkage-safe way by catching
`LinkageError` (not just `NoSuchMethodError` or `Exception`) or otherwise
checking API availability before reading `contextParameters`. Keep the existing
fallback behavior intact so the analyzer can still recover on 242-era IDEs.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In
`@compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/StabilityAnalyzerK2.kt`:
- Around line 191-207: The `StabilityAnalyzerK2` path that iterates
`functionSymbol.contextParameters` is not safe on older bundled Kotlin APIs,
since it can throw linkage failures before the PSI fallback runs. Update the
context-parameter branch to guard that access in a linkage-safe way by catching
`LinkageError` (not just `NoSuchMethodError` or `Exception`) or otherwise
checking API availability before reading `contextParameters`. Keep the existing
fallback behavior intact so the analyzer can still recover on 242-era IDEs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1780615f-6621-4934-9484-342648e50f52

📥 Commits

Reviewing files that changed from the base of the PR and between a07da87 and 9773366.

📒 Files selected for processing (1)
  • compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/StabilityAnalyzerK2.kt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop usages of KaContextReceiver (obsolete context receivers)

1 participant