Skip to content

Commit f27ead5

Browse files
committed
[WIP] K2 Support
1 parent 69f1c83 commit f27ead5

File tree

8 files changed

+586
-32
lines changed

8 files changed

+586
-32
lines changed

build.gradle

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
buildscript {
2-
ext.kotlinVersion = '1.8.10'
2+
ext.kotlinVersion = '2.0.0'
33
repositories {
44
mavenCentral()
55
}
@@ -10,23 +10,23 @@ buildscript {
1010

1111
plugins {
1212
id 'java'
13-
id 'org.jetbrains.intellij' version '1.15.0'
14-
id 'org.jetbrains.kotlin.jvm' version '1.8.10'
13+
id 'org.jetbrains.intellij' version '1.17.3'
14+
id 'org.jetbrains.kotlin.jvm' version '2.0.0'
1515
}
1616

1717
sourceCompatibility = JavaVersion.VERSION_11
1818
targetCompatibility = JavaVersion.VERSION_11
1919

2020
intellij {
21-
version = '2023.1.4'
21+
version = '2024.1.1'
2222
plugins = ['Kotlin', 'java']
2323
pluginName = 'kotlin-fill-class'
2424
updateSinceUntilBuild = false
2525
publishPlugin {
2626
token = System.getenv('TOKEN')
2727
}
2828
patchPluginXml {
29-
sinceBuild = '221.5080.210'
29+
sinceBuild = '241.14494.240'
3030
}
3131
}
3232

@@ -35,6 +35,7 @@ version '1.0.23'
3535

3636
repositories {
3737
mavenCentral()
38+
maven { url 'https://cache-redirector.jetbrains.com/maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-ide-plugin-dependencies' }
3839
}
3940

4041
configurations {
@@ -43,6 +44,15 @@ configurations {
4344

4445
dependencies {
4546
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
47+
compileOnly 'org.jetbrains.kotlin:high-level-api-for-ide:2.0.0-ij241-276', {
48+
exclude group: 'org.jetbrains.kotlin', module: 'analysis-api'
49+
}
50+
compileOnly 'org.jetbrains.kotlin:high-level-api-fir-for-ide:2.0.0-ij241-276', {
51+
exclude group: 'org.jetbrains.kotlin', module: 'analysis-api-fir'
52+
}
53+
compileOnly 'org.jetbrains.kotlin:high-level-api-fe10-for-ide:2.0.0-ij241-276', {
54+
exclude group: 'org.jetbrains.kotlin', module: 'analysis-api-fe10'
55+
}
4656

4757
// Lorem : An extremely useful Lorem Ipsum generator for Java!
4858
implementation 'com.thedeanda:lorem:2.1'
@@ -84,3 +94,17 @@ task ktlintFormat(type: JavaExec, group: "formatting") {
8494
args "-F", "src/**/*.kt"
8595
}
8696

97+
tasks {
98+
runIde {
99+
systemProperty("idea.kotlin.plugin.use.k2", true)
100+
}
101+
}
102+
103+
kotlin {
104+
compilerOptions {
105+
freeCompilerArgs.add("-Xcontext-receivers")
106+
}
107+
compilerOptions {
108+
apiVersion = org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0
109+
}
110+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.github.suusan2go.kotlinfillclass.helper
2+
3+
import com.intellij.util.SystemProperties
4+
5+
object K2SupportHelper {
6+
fun isK2PluginEnabled(): Boolean = SystemProperties.getBooleanProperty("idea.kotlin.plugin.use.k2", false)
7+
}

src/main/kotlin/com/github/suusan2go/kotlinfillclass/inspections/BaseFillClassInspection.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.suusan2go.kotlinfillclass.inspections
22

3+
import com.github.suusan2go.kotlinfillclass.helper.K2SupportHelper
34
import com.github.suusan2go.kotlinfillclass.helper.PutArgumentOnSeparateLineHelper
45
import com.intellij.codeInsight.template.TemplateBuilderImpl
56
import com.intellij.codeInspection.LocalQuickFix
@@ -71,6 +72,7 @@ abstract class BaseFillClassInspection(
7172
holder: ProblemsHolder,
7273
isOnTheFly: Boolean,
7374
) = valueArgumentListVisitor(fun(element: KtValueArgumentList) {
75+
if (K2SupportHelper.isK2PluginEnabled()) return
7476
val callElement = element.parent as? KtCallElement ?: return
7577
val descriptors = analyze(callElement).ifEmpty { return }
7678
val description = if (descriptors.any { descriptor -> descriptor is ClassConstructorDescriptor }) {

0 commit comments

Comments
 (0)