Skip to content

Migrate to k2#127

Open
animalet wants to merge 2 commits into
arunkumar9t2:mainfrom
animalet:migrate-to-k2
Open

Migrate to k2#127
animalet wants to merge 2 commits into
arunkumar9t2:mainfrom
animalet:migrate-to-k2

Conversation

@animalet

@animalet animalet commented Mar 31, 2026

Copy link
Copy Markdown

Proposed Changes

Note: This is a work-in-progress contribution. I have not worked on IntelliJ plugins before, and the plugin has not been fully end-to-end tested yet. I'm filing this PR in case it helps unblock K2 support, since the repository appears to be unmaintained. Feedback and corrections are very welcome.

Starting from IntelliJ 2025.1, K2 mode is enabled by default. Plugins using K1-only APIs and without a K2 compatibility declaration will not load. This PR migrates the plugin to use PSI-only alternatives and modernizes the build infrastructure.

K1 → PSI migration (zero dependency on the K1 analysis engine):

  • findAnnotation(FqName)annotationEntries + shortName matching
  • getKotlinFqName()KtClassOrObject.fqName (PSI property)
  • getReturnTypeReference()KtNamedFunction.typeReference (PSI property)
  • getContainingClass()PsiTreeUtil.getParentOfType()

K2 compatibility declaration:

  • Added <supportsKotlinPluginMode supportsK2="true" /> to plugin.xml
  • Bumped since-build to 242 (IntelliJ 2024.2+)
  • Made org.jetbrains.android optional with a separate scabbard-android.xml

Build modernization:

  • Gradle 7.5.1 → 8.13
  • Kotlin 1.6.21 → 2.0.21
  • JVM target 1.8 → 17
  • IntelliJ SDK 202 → 2024.2
  • IntelliJ Gradle Plugin 1.0 → 1.17.4
  • Dagger 2.42 → 2.51.1, Dokka 1.5.0 → 1.9.20
  • Converted scabbard-gradle-plugin/build.gradle to Kotlin DSL
  • Various Gradle 8 / Kotlin 2.0 API migrations

Testing

  • ./gradlew :scabbard-idea-plugin:buildPlugin — builds successfully
  • ./gradlew :scabbard-idea-plugin:verifyPlugin — passes
  • Installed plugin locally in IntelliJ with K2 enabled — no ClassNotFoundException or NoSuchMethodError in IDE logs
  • Plugin was not fully end-to-end tested with gutter icon navigation

Issues Fixed

Closes #126

NOTE: The PR has been Vibe coded using Claude Opus 4.6 model

@animalet animalet marked this pull request as ready for review March 31, 2026 13:55
@animalet animalet requested a review from arunkumar9t2 as a code owner March 31, 2026 13:55
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.

Support Kotlin in K2 Mode for plugin

1 participant