Make DifferentKotlinGradleVersionInspection inpection work for classpath call with braces
This commit is contained in:
+5
-2
@@ -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<GrCommandArgumentList>().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<GrCommandArgumentList>().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
|
||||
|
||||
+9
@@ -52,4 +52,13 @@
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Kotlin Gradle and IDE plugins versions are different</problem_class>
|
||||
<description>Kotlin version that is used for building with Gradle (0.0.1) differs from the one bundled into the IDE plugin ($PLUGIN_VERSION)</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>wrongPluginVersionWithBracesCall.gradle</file>
|
||||
<line>6</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="wrongPluginVersionWithBracesCall.gradle" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Kotlin Gradle and IDE plugins versions are different</problem_class>
|
||||
<description>Kotlin version that is used for building with Gradle (0.0.1) differs from the one bundled into the IDE plugin ($PLUGIN_VERSION)</description>
|
||||
</problem>
|
||||
</problems>
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:0.0.1")
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'kotlin'
|
||||
Reference in New Issue
Block a user