[gradle] IDEA-385212 Move build.gradle.kts completion logic from kotlin to gradle plugin

(cherry picked from commit ef914109fee54bee557edb880633bb6111e81718)

IJ-CR-192311

GitOrigin-RevId: 5fe17d9396d3bb94ed7eb2b09443c38ef2f5ba99
This commit is contained in:
Dmitry Kichinsky
2026-02-19 12:33:55 +00:00
committed by intellij-monorepo-bot
parent 7e72b43d1d
commit 577004f2fb
27 changed files with 292 additions and 106 deletions
+1
View File
@@ -473,6 +473,7 @@
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/java/intellij.gradle.java.tests.iml" filepath="$PROJECT_DIR$/plugins/gradle/java/intellij.gradle.java.tests.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/java/toml/intellij.gradle.java.toml.iml" filepath="$PROJECT_DIR$/plugins/gradle/java/toml/intellij.gradle.java.toml.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/jps-plugin/intellij.gradle.jps.iml" filepath="$PROJECT_DIR$/plugins/gradle/jps-plugin/intellij.gradle.jps.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/kotlin/intellij.gradle.kotlin.iml" filepath="$PROJECT_DIR$/plugins/gradle/kotlin/intellij.gradle.kotlin.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/kotlin/tests/intellij.gradle.kotlin.tests.iml" filepath="$PROJECT_DIR$/plugins/gradle/kotlin/tests/intellij.gradle.kotlin.tests.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/native/intellij.gradle.native.iml" filepath="$PROJECT_DIR$/plugins/gradle/native/intellij.gradle.native.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/gradle/native/tooling/intellij.gradle.native.tooling.iml" filepath="$PROJECT_DIR$/plugins/gradle/native/tooling/intellij.gradle.native.tooling.iml" />
+1
View File
@@ -1009,6 +1009,7 @@ plugins/gradle/java/plugin
plugins/gradle/java/properties
plugins/gradle/java/toml
plugins/gradle/jps-plugin
plugins/gradle/kotlin
plugins/gradle/kotlin/tests
plugins/gradle/native
plugins/gradle/native/tooling
+34
View File
@@ -0,0 +1,34 @@
### auto-generated section `build intellij.gradle.kotlin` start
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
resourcegroup(
name = "kotlin_resources",
srcs = glob(["resources/**/*"]),
strip_prefix = "resources"
)
jvm_library(
name = "kotlin",
module_name = "intellij.gradle.kotlin",
visibility = ["//visibility:public"],
srcs = glob(["src/**/*.kt", "src/**/*.java", "src/**/*.form"], allow_empty = True),
resources = [":kotlin_resources"],
deps = [
"@lib//:kotlin-stdlib",
"//platform/core-api:core",
"//platform/util",
"//platform/analysis-api:analysis",
"//plugins/repository-search/common",
"//plugins/gradle/completion",
"//plugins/gradle",
"//platform/analysis-impl",
"//platform/backend/workspace",
"//platform/workspace/storage",
"//platform/editor-ui-api:editor-ui",
"//platform/workspace/jps",
"@lib//:kotlinc-kotlin-compiler-common-provided",
"//java/java-psi-api:psi",
"//java/java-frontback-psi-impl:frontback-psi-impl",
]
)
### auto-generated section `build intellij.gradle.kotlin` end
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="com.intellij.gradle.kotlin" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.platform.core" />
<orderEntry type="module" module-name="intellij.platform.util" />
<orderEntry type="module" module-name="intellij.platform.analysis" />
<orderEntry type="module" module-name="intellij.repository.search.common" />
<orderEntry type="module" module-name="intellij.gradle.completion" />
<orderEntry type="module" module-name="intellij.gradle" />
<orderEntry type="module" module-name="intellij.platform.analysis.impl" />
<orderEntry type="module" module-name="intellij.platform.backend.workspace" />
<orderEntry type="module" module-name="intellij.platform.workspace.storage" />
<orderEntry type="module" module-name="intellij.platform.editor.ui" />
<orderEntry type="module" module-name="intellij.platform.workspace.jps" />
<orderEntry type="library" scope="PROVIDED" name="kotlinc.kotlin-compiler-common" level="project" />
<orderEntry type="module" module-name="intellij.java.psi" />
<orderEntry type="module" module-name="intellij.java.frontback.psi.impl" />
</component>
</module>
@@ -0,0 +1,18 @@
<idea-plugin>
<dependencies>
<plugin id="org.jetbrains.kotlin"/>
<!-- region Generated dependencies - run `Generate Product Layouts` to regenerate -->
<module name="intellij.gradle"/>
<module name="intellij.gradle.completion"/>
<module name="intellij.java.frontback.psi.impl"/>
<module name="intellij.java.psi"/>
<module name="intellij.repository.search.common"/>
<!-- endregion -->
</dependencies>
<extensions defaultExtensionNs="com.intellij">
<completion.contributor language="kotlin"
id="KotlinGradleScriptCompletionContributor"
order="first, before KotlinCompletionContributor, before liveTemplates"
implementationClass="com.intellij.gradle.kotlin.completion.KotlinGradleScriptCompletionContributor"/>
</extensions>
</idea-plugin>
@@ -1,5 +1,5 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.gradle.scripting.shared.completion
package com.intellij.gradle.kotlin.completion
import com.intellij.codeInsight.completion.BaseCompletionLookupArranger
import com.intellij.codeInsight.completion.CompletionParameters
@@ -1,10 +1,12 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.gradle.scripting.shared.completion
package com.intellij.gradle.kotlin.completion
import com.intellij.codeInsight.completion.CompletionContributor
import com.intellij.codeInsight.completion.CompletionType
import org.jetbrains.annotations.ApiStatus
class KotlinGradleScriptCompletionContributor() : CompletionContributor() {
@ApiStatus.Internal
class KotlinGradleScriptCompletionContributor : CompletionContributor() {
init {
extend(CompletionType.BASIC, insideScriptBlockPattern(DEPENDENCIES), KotlinGradleDependenciesCompletionProvider())
}
@@ -1,5 +1,5 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.gradle.scripting.shared.completion
package com.intellij.gradle.kotlin.completion
import com.intellij.openapi.diagnostic.Logger
import com.intellij.patterns.PlatformPatterns.psiElement
+12 -8
View File
@@ -1,17 +1,13 @@
### auto-generated section `build intellij.gradle.kotlin.tests` start
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
resourcegroup(
name = "tests_test_resources",
srcs = glob(["resources/**/*"]),
strip_prefix = "resources"
)
load("@rules_jvm//:jvm.bzl", "jvm_library")
jvm_library(
name = "tests",
visibility = ["//visibility:public"],
srcs = glob([], allow_empty = True),
runtime_deps = [
"//plugins/kotlin/plugin/k2",
"@lib//:kotlin-test",
"@lib//:kotlin-stdlib",
"//platform/core-api:core",
"//platform/util",
@@ -21,7 +17,9 @@ jvm_library(
"//plugins/repository-search/common",
"//plugins/gradle/completion",
"//plugins/gradle/toml",
"//plugins/gradle/kotlin",
"//plugins/gradle",
"//plugins/kotlin/gradle/scripting/kotlin.gradle.scripting.k2:kotlin-gradle-scripting",
]
)
@@ -30,8 +28,9 @@ jvm_library(
module_name = "intellij.gradle.kotlin.tests",
visibility = ["//visibility:public"],
srcs = glob(["test/**/*.kt", "test/**/*.java", "test/**/*.form"], allow_empty = True),
resources = [":tests_test_resources"],
deps = [
"@lib//:assert_j",
"@lib//:kotlin-test",
"@lib//:kotlin-stdlib",
"//platform/core-api:core",
"//platform/util",
@@ -43,6 +42,7 @@ jvm_library(
"//plugins/gradle/completion",
"//plugins/gradle/completion:completion_test_lib",
"//plugins/gradle/toml",
"//plugins/gradle/kotlin",
"//plugins/gradle",
"@lib//:kotlin-test-junit",
"//platform/testFramework",
@@ -55,6 +55,10 @@ jvm_library(
"//plugins/groovy",
"//plugins/groovy:groovy_test_lib",
"//plugins/kotlin/base/test:test_test_lib",
"@lib//:kotlinc-kotlin-compiler-tests",
"//plugins/kotlin/tests-common:common-tests_test_lib",
"//platform/eel-provider",
"//plugins/kotlin/highlighting/highlighting-minimal:kotlin-highlighting-minimal",
],
runtime_deps = [":tests"]
)
@@ -3,10 +3,12 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" packagePrefix="com.intellij.gradle.kotlin.tests" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
<orderEntry type="module" module-name="kotlin.plugin.k2" scope="RUNTIME" />
<orderEntry type="library" name="kotlin-test" level="project" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlin-stdlib" level="project" />
<orderEntry type="module" module-name="intellij.platform.core" />
@@ -17,6 +19,7 @@
<orderEntry type="module" module-name="intellij.repository.search.common" />
<orderEntry type="module" module-name="intellij.gradle.completion" />
<orderEntry type="module" module-name="intellij.gradle.toml" />
<orderEntry type="module" module-name="intellij.gradle.kotlin" />
<orderEntry type="module" module-name="intellij.gradle" />
<orderEntry type="library" scope="TEST" name="kotlin-test-junit" level="project" />
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
@@ -26,5 +29,10 @@
<orderEntry type="module" module-name="kotlin.gradle.gradle-java.tests.shared" scope="TEST" />
<orderEntry type="module" module-name="intellij.groovy" scope="TEST" />
<orderEntry type="module" module-name="kotlin.base.test" scope="TEST" />
<orderEntry type="library" scope="TEST" name="kotlinc.kotlin-compiler-tests" level="project" />
<orderEntry type="module" module-name="intellij.kotlin.common.tests" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.eel.provider" scope="TEST" />
<orderEntry type="module" module-name="intellij.kotlin.gradle.scripting" scope="RUNTIME" />
<orderEntry type="module" module-name="intellij.kotlin.highlighting.minimal" scope="TEST" />
</component>
</module>
@@ -1,7 +0,0 @@
<idea-plugin>
<dependencies>
<module name="intellij.gradle.completion"/>
<module name="intellij.toml.core"/>
<module name="intellij.gradle.toml"/>
</dependencies>
</idea-plugin>
@@ -1,5 +1,5 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.codeInsight.gradle.completion
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.gradle.kotlin.tests.completion
import com.intellij.codeInsight.lookup.Lookup
import com.intellij.openapi.actionSystem.IdeActions
@@ -0,0 +1,123 @@
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.gradle.kotlin.tests.completion
import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.platform.testFramework.assertion.collectionAssertion.CollectionAssertions
import com.intellij.testFramework.ExpectedHighlightingData
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
import com.intellij.testFramework.runInEdtAndWait
import org.assertj.core.api.Assertions.assertThat
import org.jetbrains.kotlin.gradle.AbstractKotlinGradleCodeInsightBaseTest
import org.jetbrains.kotlin.idea.base.highlighting.dsl.DslStyleUtils
import org.jetbrains.kotlin.idea.test.AssertKotlinPluginMode
import org.jetbrains.kotlin.idea.test.UseK2PluginMode
import org.jetbrains.plugins.gradle.frameworkSupport.GradleDsl
import org.jetbrains.plugins.gradle.testFramework.GradleTestFixtureBuilder
import org.jetbrains.plugins.gradle.testFramework.fixtures.application.GradleProjectTestApplication
import org.jetbrains.plugins.gradle.testFramework.util.withBuildFile
import org.jetbrains.plugins.gradle.testFramework.util.withSettingsFile
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.assertNotNull
import org.junit.jupiter.api.assertNull
@UseK2PluginMode
@GradleProjectTestApplication
@AssertKotlinPluginMode
abstract class K2GradleCodeInsightTestCase : AbstractKotlinGradleCodeInsightBaseTest() {
protected fun checkCaret(expression: String) {
assertTrue("<caret>" in expression) { "Please define caret position in build script." }
}
fun testIntention(before: String, after: String, intentionPrefix: String) {
testIntention("build.gradle.kts", before, after, intentionPrefix)
}
fun testIntention(fileName: String, before: String, after: String, intentionPrefix: String) {
checkCaret(before)
writeTextAndCommit(fileName, before)
runInEdtAndWait {
codeInsightFixture.configureFromExistingVirtualFile(getFile(fileName))
val intention = codeInsightFixture.filterAvailableIntentions(intentionPrefix).single()
codeInsightFixture.launchAction(intention)
codeInsightFixture.checkResult(after)
gradleFixture.fileFixture.rollback(fileName)
}
}
fun testNoIntentions(before: String, intentionPrefix: String) {
testNoIntentions("build.gradle.kts", before, intentionPrefix)
}
fun testNoIntentions(fileName: String, before: String, intentionPrefix: String) {
checkCaret(before)
writeTextAndCommit(fileName, before)
runInEdtAndWait {
codeInsightFixture.configureFromExistingVirtualFile(getFile(fileName))
val intentions = codeInsightFixture.filterAvailableIntentions(intentionPrefix)
assertThat(intentions).isEmpty()
}
}
fun testHighlighting(expression: String) = testHighlighting("build.gradle.kts", expression)
fun testHighlighting(relativePath: String, expression: String) {
writeTextAndCommit(relativePath, expression)
runInEdtAndWait {
codeInsightFixture.openFileInEditor(getFile(relativePath))
checkNotNull(codeInsightFixture.editor) { "Fixture is not configured. Call something like configureByFile() or configureByText()" }
val data = ExpectedHighlightingData(
codeInsightFixture.editor.getDocument(), true, true, false, false
)
// manually register DSL_TYPE_SEVERITY to ignore it
val severity = DslStyleUtils.typeById(1).getSeverity(null)
data.registerHighlightingType(severity.name, ExpectedHighlightingData.ExpectedHighlightingSet(severity, false, false))
data.init()
(codeInsightFixture as CodeInsightTestFixtureImpl).collectAndCheckHighlighting(data)
}
}
fun testCompletionStrict(expression: String, vararg completionCandidates: String) =
testCompletion("build.gradle.kts", expression, completionCandidates.toList(), strict = true)
fun testCompletion(relativePath: String, expression: String, completionCandidates: List<String>, strict: Boolean) =
testCompletion(relativePath, expression) { lookupElements ->
assertNotNull(lookupElements) {
"There was only one completion suggestion, so it was auto completed. Please use `testAutoCompletion()` instead."
}
if (strict) CollectionAssertions.assertEqualsUnordered(completionCandidates, lookupElements.map { it.lookupString })
else CollectionAssertions.assertContainsUnordered(completionCandidates, lookupElements.map { it.lookupString })
}
fun testCompletion(relativePath: String, expression: String, checker: (Array<LookupElement>?) -> Unit) {
checkCaret(expression)
writeTextAndCommit(relativePath, expression)
runInEdtAndWait {
codeInsightFixture.configureFromExistingVirtualFile(getFile(relativePath))
checker(codeInsightFixture.completeBasic())
}
}
fun testAutoCompletion(before: String, after: String) = testAutoCompletion("build.gradle.kts", before, after)
fun testAutoCompletion(relativePath: String, before: String, after: String) =
testCompletion(relativePath, before) { lookupElements ->
assertNull(lookupElements) { "There was no or more than one completion suggestion, so it was not auto completed." }
codeInsightFixture.checkResult(after)
}
companion object {
@JvmStatic
protected val WITH_CUSTOM_CONFIGURATIONS_FIXTURE =
GradleTestFixtureBuilder.create("with-custom-configurations") { gradleVersion ->
withSettingsFile(gradleVersion, gradleDsl = GradleDsl.KOTLIN) {
setProjectName("with-custom-configurations")
}
withBuildFile(gradleVersion, gradleDsl = GradleDsl.KOTLIN) {
withKotlinJvmPlugin()
withPrefix { code("val customConf by configurations.creating {}") }
withPrefix { code("val customSourceSet by sourceSets.creating {}") }
}
}
}
}
@@ -1,9 +1,10 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.codeInsight.gradle.completion
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.gradle.kotlin.tests.completion
import com.intellij.codeInsight.completion.CompletionContributor
import com.intellij.codeInsight.completion.CompletionContributorEP
import com.intellij.codeInsight.lookup.Lookup
import com.intellij.gradle.kotlin.completion.KotlinGradleScriptCompletionContributor
import com.intellij.openapi.extensions.DefaultPluginDescriptor
import com.intellij.testFramework.ExtensionTestUtil
import com.intellij.testFramework.TestDataPath
@@ -18,19 +19,24 @@ import org.jetbrains.idea.completion.api.DependencyCompletionRequest
import org.jetbrains.idea.completion.api.DependencyCompletionResult
import org.jetbrains.idea.completion.api.DependencyCompletionService
import org.jetbrains.idea.completion.api.DependencyGroupCompletionRequest
import org.jetbrains.kotlin.gradle.scripting.shared.completion.KotlinGradleScriptCompletionContributor
import org.jetbrains.kotlin.idea.base.test.TestRoot
import org.jetbrains.kotlin.idea.test.AssertKotlinPluginMode
import org.jetbrains.kotlin.idea.test.UseK2PluginMode
import org.jetbrains.kotlin.idea.testFramework.gradle.KotlinGradleProjectTestCase
import org.jetbrains.kotlin.test.TestMetadata
import org.jetbrains.plugins.gradle.testFramework.annotations.BaseGradleVersionSource
import org.jetbrains.plugins.gradle.testFramework.fixtures.application.GradleProjectTestApplication
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
@UseK2PluginMode
@GradleProjectTestApplication
@AssertKotlinPluginMode
@TestRoot("idea/tests/testData/")
@TestDataPath("\$CONTENT_ROOT")
@TestMetadata("../../../idea/tests/testData/gradle/completion/buildGradleKts/dependencies")
abstract class KotlinGradleDependenciesCompletionTest: AbstractKotlinGradleCompletionTest() {
@TestDataPath("/")
@TestMetadata("testData/gradle/completion/buildGradleKts/dependencies")
internal class KotlinGradleDependenciesCompletionTest: AbstractKotlinGradleCompletionTest() {
private val testCompletionService = object : DependencyCompletionService {
override fun suggestCompletions(request: DependencyCompletionRequest): Flow<DependencyCompletionResult> {
@@ -1,5 +1,5 @@
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.gradle.scripting.k2.completion
package com.intellij.gradle.kotlin.tests.completion
import com.intellij.gradle.completion.indexer.GradleLocalRepositoryIndexer
import com.intellij.gradle.completion.indexer.GradleLocalRepositoryIndexerTestImpl
@@ -9,8 +9,7 @@ import com.intellij.platform.eel.provider.LocalEelDescriptor
import com.intellij.testFramework.junit5.TestDisposable
import com.intellij.testFramework.replaceService
import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.scripting.k2.K2GradleCodeInsightTestCase
import org.jetbrains.plugins.gradle.testFramework.annotations.AllGradleVersionsSource
import org.jetbrains.plugins.gradle.testFramework.annotations.BaseGradleVersionSource
import org.junit.jupiter.params.ParameterizedTest
class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase() {
@@ -26,7 +25,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test no suggestions`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -44,7 +43,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test version suggestions after artifact`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -68,7 +67,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test version suggestions after a colon`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -92,7 +91,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test version suggestions`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -115,7 +114,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test version suggestions after a dot`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -138,7 +137,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test version auto completion`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -164,7 +163,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test custom configuration`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -188,7 +187,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test custom string configuration`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -212,7 +211,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test suggestions after org`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -239,7 +238,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test extra artifact suggestions`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -265,7 +264,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test artifact suggestions caret after group`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -292,7 +291,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test artifact suggestions caret after group colon`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -319,7 +318,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test artifact suggestions caret in artifact`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -347,7 +346,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test caret in empty string`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -377,7 +376,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test single part being artifact`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -398,7 +397,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test single part being group`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -420,7 +419,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test single part being artifact or group`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -444,7 +443,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test each part uses contains`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -464,7 +463,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test no suggestions outside dependencies block`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -481,7 +480,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test no suggestions in comments`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -499,7 +498,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test whitespace inside string is tolerated`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -519,7 +518,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test caret after a dash`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -539,7 +538,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named dependencyNotation argument`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -561,7 +560,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
// NAMED ARGUMENTS NOTATION
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named arguments empty group with no name and no version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -586,7 +585,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named arguments partial group with no name and no version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -609,7 +608,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named arguments empty group with name and empty version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -631,7 +630,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named arguments partial group with name and empty version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -657,7 +656,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named arguments empty group with empty name and empty version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -682,7 +681,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named arguments empty group with name and no version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -703,7 +702,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named arguments empty version with group and name`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -725,7 +724,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named arguments empty name with group and empty version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -748,7 +747,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test named arguments partial name with group and empty version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -771,7 +770,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test out-of-order named arguments empty group with name and no version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -792,7 +791,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test out-of-order named arguments empty group with name and empty version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -813,7 +812,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test positional arguments empty group with name and empty version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -834,7 +833,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test positional arguments empty name with group and no version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -857,7 +856,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test positional arguments empty name with group and empty version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -880,7 +879,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test positional arguments partial name with group and no version`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -904,7 +903,7 @@ class KotlinGradleLocalDependencyCompletionTest : K2GradleCodeInsightTestCase()
}
@ParameterizedTest
@AllGradleVersionsSource
@BaseGradleVersionSource
fun `test positional arguments empty version with group and name`(gradleVersion: GradleVersion) {
test(gradleVersion, WITH_CUSTOM_CONFIGURATIONS_FIXTURE) {
configureLocalIndex(
@@ -1,5 +1,5 @@
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.gradle.kotlin.tests
package com.intellij.gradle.kotlin.tests.completion
import com.intellij.codeInsight.lookup.Lookup
import com.intellij.testFramework.replaceService
@@ -14,7 +14,6 @@ import org.jetbrains.idea.completion.api.DependencyCompletionResult
import org.jetbrains.idea.completion.api.DependencyCompletionService
import org.jetbrains.idea.completion.api.DependencyGroupCompletionRequest
import org.jetbrains.idea.completion.api.DependencyVersionCompletionRequest
import org.jetbrains.kotlin.idea.codeInsight.gradle.completion.AbstractKotlinGradleCompletionTest
import org.jetbrains.kotlin.idea.testFramework.gradle.KotlinGradleProjectTestCase
import org.jetbrains.plugins.gradle.testFramework.annotations.BaseGradleVersionSource
import org.jetbrains.plugins.gradle.testFramework.fixtures.application.GradleProjectTestApplication
@@ -149,6 +149,9 @@
- name: lib/modules/intellij.gradle.completion.jar
contentModules:
- name: intellij.gradle.completion
- name: lib/modules/intellij.gradle.kotlin.jar
contentModules:
- name: intellij.gradle.kotlin
- name: lib/modules/intellij.gradle.properties.jar
contentModules:
- name: intellij.gradle.properties
@@ -22,6 +22,7 @@
<module name="intellij.gradle.completion"/>
<module name="intellij.gradle.toml"/>
<module name="intellij.gradle.properties"/>
<module name="intellij.gradle.kotlin"/>
</content>
<dependencies>
@@ -14,7 +14,6 @@ jvm_library(
srcs = glob(["src/**/*.kt", "src/**/*.java", "src/**/*.form"], allow_empty = True),
resources = [":kotlin-gradle-codeInsight-toml_resources"],
deps = [
"//plugins/gradle/completion",
"//plugins/toml/core",
"@lib//:kotlinc-kotlin-compiler-common",
"//platform/core-api:core",
@@ -7,7 +7,6 @@
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="module" module-name="intellij.gradle.completion" />
<orderEntry type="module" module-name="intellij.toml.core" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="kotlinc.kotlin-compiler-common" level="project" />
@@ -1,12 +0,0 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package org.jetbrains.kotlin.idea.k2.codeInsight.gradle.completion
import org.jetbrains.kotlin.idea.codeInsight.gradle.completion.KotlinGradleDependenciesCompletionTest
import org.jetbrains.kotlin.idea.test.AssertKotlinPluginMode
import org.jetbrains.kotlin.idea.test.UseK2PluginMode
import org.jetbrains.plugins.gradle.testFramework.fixtures.application.GradleProjectTestApplication
@UseK2PluginMode
@GradleProjectTestApplication
@AssertKotlinPluginMode
class K2GradleDependenciesCompletionTest: KotlinGradleDependenciesCompletionTest()
@@ -16,7 +16,6 @@ jvm_library(
"@lib//:kotlin-test",
"@lib//:kotlinc-kotlin-compiler-tests",
"//plugins/kotlin/gradle/gradle-java",
"//plugins/repository-search/common",
]
)
@@ -109,11 +108,6 @@ jvm_library(
"//java/java-runtime:rt",
"//platform/execution",
"//plugins/junit",
"//plugins/repository-search/common",
"//plugins/repository-search/common:common_test_lib",
"//plugins/kotlin/gradle/scripting/kotlin.gradle.scripting.shared:kotlin-gradle-scripting-shared",
"//platform/util/text-matching",
"//platform/util/text-matching:text-matching_test_lib",
],
exports = ["@lib//:kotlin-gradle-plugin-idea"],
runtime_deps = [":tests.shared"]
@@ -79,8 +79,5 @@
<orderEntry type="module" module-name="intellij.java.rt" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.execution" scope="TEST" />
<orderEntry type="module" module-name="intellij.junit" scope="TEST" />
<orderEntry type="module" module-name="intellij.repository.search.common" />
<orderEntry type="module" module-name="kotlin.gradle.scripting.shared" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.util.text.matching" scope="TEST" />
</component>
</module>
@@ -129,7 +129,7 @@ abstract class AbstractGradleCodeInsightTest : AbstractKotlinGradleCodeInsightBa
)
}
class TestFile internal constructor(val path: String, val content: String, val directives: Directives)
class TestFile(val path: String, val content: String, val directives: Directives)
companion object {
@JvmStatic
@@ -52,9 +52,6 @@ jvm_library(
"//java/java-psi-api:psi",
"//platform/lang-api:lang",
"//platform/indexing-api:indexing",
"//platform/eel-provider",
"//plugins/repository-search/common",
"//plugins/gradle/completion",
]
)
### auto-generated section `build kotlin.gradle.scripting.shared` end
@@ -47,8 +47,5 @@
<orderEntry type="module" module-name="intellij.java.psi" />
<orderEntry type="module" module-name="intellij.platform.lang" />
<orderEntry type="module" module-name="intellij.platform.indexing" />
<orderEntry type="module" module-name="intellij.platform.eel.provider" />
<orderEntry type="module" module-name="intellij.repository.search.common" />
<orderEntry type="module" module-name="intellij.gradle.completion" />
</component>
</module>
@@ -15,10 +15,6 @@
<extensions defaultExtensionNs="com.intellij">
<internalFileTemplate name="Kotlin Script Gradle"/>
<completion.contributor language="kotlin"
id="KotlinGradleScriptCompletionContributor"
order="first, before KotlinCompletionContributor, before liveTemplates"
implementationClass="org.jetbrains.kotlin.gradle.scripting.shared.completion.KotlinGradleScriptCompletionContributor"/>
</extensions>
<actions resource-bundle="messages.KotlinGradleScriptingBundle">