diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/gradle/DifferentKotlinGradleVersionInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/gradle/DifferentKotlinGradleVersionInspection.kt index 2a1b461fa87..be823fa87b4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/gradle/DifferentKotlinGradleVersionInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/gradle/DifferentKotlinGradleVersionInspection.kt @@ -106,8 +106,11 @@ class DifferentKotlinGradleVersionInspection : GradleBaseInspection() { val KOTLIN_PLUGIN_PATH_MARKER = "${KotlinWithGradleConfigurator.GROUP_ID}/${KotlinWithGradleConfigurator.GRADLE_PLUGIN_ID}/" private fun getHeuristicKotlinPluginVersion(classpathStatement: GrCallExpression): String? { - val argument = classpathStatement.getChildrenOfType().firstOrNull() ?: return null - val grLiteral = argument.children.firstOrNull()?.let { it as? GrLiteral } ?: return null + val argumentList = when { + classpathStatement is GrMethodCall -> classpathStatement.argumentList + else -> classpathStatement.getChildrenOfType().singleOrNull() + } ?: return null + val grLiteral = argumentList.children.firstOrNull() as? GrLiteral ?: return null if (grLiteral is GrString && grLiteral.injections.size == 1) { val versionInjection = grLiteral.injections.first() ?: return null diff --git a/idea/testData/inspections/gradleWrongPluginVersion/inspectionData/expected.xml b/idea/testData/inspections/gradleWrongPluginVersion/inspectionData/expected.xml index 31a12cf600d..70cfa7b0ca9 100644 --- a/idea/testData/inspections/gradleWrongPluginVersion/inspectionData/expected.xml +++ b/idea/testData/inspections/gradleWrongPluginVersion/inspectionData/expected.xml @@ -52,4 +52,13 @@ Kotlin Gradle and IDE plugins versions are different Kotlin version that is used for building with Gradle (0.0.1) differs from the one bundled into the IDE plugin ($PLUGIN_VERSION) + + + wrongPluginVersionWithBracesCall.gradle + 6 + light_idea_test_case + + Kotlin Gradle and IDE plugins versions are different + Kotlin version that is used for building with Gradle (0.0.1) differs from the one bundled into the IDE plugin ($PLUGIN_VERSION) + diff --git a/idea/testData/inspections/gradleWrongPluginVersion/wrongPluginVersionWithBracesCall.gradle b/idea/testData/inspections/gradleWrongPluginVersion/wrongPluginVersionWithBracesCall.gradle new file mode 100644 index 00000000000..e9d671f6ed6 --- /dev/null +++ b/idea/testData/inspections/gradleWrongPluginVersion/wrongPluginVersionWithBracesCall.gradle @@ -0,0 +1,11 @@ +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:0.0.1") + } +} + +apply plugin: 'java' +apply plugin: 'kotlin' \ No newline at end of file