Show migration when changes are in kts files or inside buildSrc dir (KT-27329)
#KT-27329 Fixed
This commit is contained in:
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
|||||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||||
import org.jetbrains.kotlin.idea.util.runReadActionInSmartMode
|
import org.jetbrains.kotlin.idea.util.runReadActionInSmartMode
|
||||||
import org.jetbrains.kotlin.idea.versions.LibInfo
|
import org.jetbrains.kotlin.idea.versions.LibInfo
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
class KotlinMigrationProjectComponent(val project: Project) {
|
class KotlinMigrationProjectComponent(val project: Project) {
|
||||||
@Volatile
|
@Volatile
|
||||||
@@ -148,12 +149,19 @@ class KotlinMigrationProjectComponent(val project: Project) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val checkedFiles = HashSet<File>()
|
||||||
|
|
||||||
|
project.basePath?.let { projectBasePath ->
|
||||||
|
checkedFiles.add(File(projectBasePath))
|
||||||
|
}
|
||||||
|
|
||||||
val changedFiles = ChangeListManager.getInstance(project).affectedPaths
|
val changedFiles = ChangeListManager.getInstance(project).affectedPaths
|
||||||
for (changedFile in changedFiles) {
|
for (changedFile in changedFiles) {
|
||||||
val extension = changedFile.extension
|
val extension = changedFile.extension
|
||||||
when (extension) {
|
when (extension) {
|
||||||
"gradle" -> return true
|
"gradle" -> return true
|
||||||
"properties" -> return true
|
"properties" -> return true
|
||||||
|
"kts" -> return true
|
||||||
"iml" -> return true
|
"iml" -> return true
|
||||||
"xml" -> {
|
"xml" -> {
|
||||||
if (changedFile.name == "pom.xml") return true
|
if (changedFile.name == "pom.xml") return true
|
||||||
@@ -162,6 +170,19 @@ class KotlinMigrationProjectComponent(val project: Project) {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"kt", "java", "groovy" -> {
|
||||||
|
val dirs: Sequence<File> = generateSequence(changedFile) { it.parentFile }
|
||||||
|
.drop(1) // Drop original file
|
||||||
|
.takeWhile { it.isDirectory }
|
||||||
|
|
||||||
|
val isInBuildSrc = dirs
|
||||||
|
.takeWhile { checkedFiles.add(it) }
|
||||||
|
.any { it.name == BUILD_SRC_FOLDER_NAME }
|
||||||
|
|
||||||
|
if (isInBuildSrc) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,6 +235,8 @@ fun MigrationInfo.isLanguageVersionUpdate(old: LanguageVersion, new: LanguageVer
|
|||||||
return oldLanguageVersion <= old && newLanguageVersion >= new
|
return oldLanguageVersion <= old && newLanguageVersion >= new
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private const val BUILD_SRC_FOLDER_NAME = "buildSrc"
|
||||||
private const val KOTLIN_GROUP_ID = "org.jetbrains.kotlin"
|
private const val KOTLIN_GROUP_ID = "org.jetbrains.kotlin"
|
||||||
|
|
||||||
private fun maxKotlinLibVersion(project: Project): LibInfo? {
|
private fun maxKotlinLibVersion(project: Project): LibInfo? {
|
||||||
|
|||||||
Reference in New Issue
Block a user