Ability to disable migration detection (KT-23401)
-- to disable
This commit is contained in:
@@ -117,6 +117,11 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
||||||
text="Run Code Migrations">
|
text="Run Code Migrations">
|
||||||
|
<!-- TODO: Not assigned to any group because there should be a panel for filling migration options -->
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action id="KotlinCodeMigrationToggle" class="org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction"
|
||||||
|
text="Enable migrations detection (experimental)">
|
||||||
<add-to-group group-id="KotlinToolsGroup"/>
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
||||||
text="Run Code Migrations">
|
text="Run Code Migrations">
|
||||||
|
<!-- TODO: Not assigned to any group because there should be a panel for filling migration options -->
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action id="KotlinCodeMigrationToggle" class="org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction"
|
||||||
|
text="Enable migrations detection (experimental)">
|
||||||
<add-to-group group-id="KotlinToolsGroup"/>
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
||||||
text="Run Code Migrations">
|
text="Run Code Migrations">
|
||||||
|
<!-- TODO: Not assigned to any group because there should be a panel for filling migration options -->
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action id="KotlinCodeMigrationToggle" class="org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction"
|
||||||
|
text="Enable migrations detection (experimental)">
|
||||||
<add-to-group group-id="KotlinToolsGroup"/>
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
|||||||
@@ -118,6 +118,11 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
||||||
text="Run Code Migrations">
|
text="Run Code Migrations">
|
||||||
|
<!-- TODO: Not assigned to any group because there should be a panel for filling migration options -->
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action id="KotlinCodeMigrationToggle" class="org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction"
|
||||||
|
text="Enable migrations detection (experimental)">
|
||||||
<add-to-group group-id="KotlinToolsGroup"/>
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
||||||
text="Run Code Migrations">
|
text="Run Code Migrations">
|
||||||
|
<!-- TODO: Not assigned to any group because there should be a panel for filling migration options -->
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action id="KotlinCodeMigrationToggle" class="org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction"
|
||||||
|
text="Enable migrations detection (experimental)">
|
||||||
<add-to-group group-id="KotlinToolsGroup"/>
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
||||||
text="Run Code Migrations">
|
text="Run Code Migrations">
|
||||||
|
<!-- TODO: Not assigned to any group because there should be a panel for filling migration options -->
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action id="KotlinCodeMigrationToggle" class="org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction"
|
||||||
|
text="Enable migrations detection (experimental)">
|
||||||
<add-to-group group-id="KotlinToolsGroup"/>
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,11 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
|
|
||||||
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
<action id="KotlinCodeMigration" class="org.jetbrains.kotlin.idea.migration.CodeMigrationAction"
|
||||||
text="Run Code Migrations">
|
text="Run Code Migrations">
|
||||||
|
<!-- TODO: Not assigned to any group because there should be a panel for filling migration options -->
|
||||||
|
</action>
|
||||||
|
|
||||||
|
<action id="KotlinCodeMigrationToggle" class="org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction"
|
||||||
|
text="Enable migrations detection (experimental)">
|
||||||
<add-to-group group-id="KotlinToolsGroup"/>
|
<add-to-group group-id="KotlinToolsGroup"/>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.idea.configuration.ui.MigrationNotificationDialog
|
|||||||
import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID
|
import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID
|
||||||
import org.jetbrains.kotlin.idea.framework.MAVEN_SYSTEM_ID
|
import org.jetbrains.kotlin.idea.framework.MAVEN_SYSTEM_ID
|
||||||
import org.jetbrains.kotlin.idea.migration.CodeMigrationAction
|
import org.jetbrains.kotlin.idea.migration.CodeMigrationAction
|
||||||
|
import org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction
|
||||||
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
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.versions.LibInfo
|
import org.jetbrains.kotlin.idea.versions.LibInfo
|
||||||
@@ -43,11 +44,19 @@ class KotlinMigrationProjectComponent(val project: Project) {
|
|||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun onImportAboutToStart() {
|
fun onImportAboutToStart() {
|
||||||
|
if (!CodeMigrationToggleAction.isEnabled(project)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
old = MigrationState.build(project)
|
old = MigrationState.build(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun onImportFinished() {
|
fun onImportFinished() {
|
||||||
|
if (!CodeMigrationToggleAction.isEnabled(project)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
new = MigrationState.build(project)
|
new = MigrationState.build(project)
|
||||||
|
|
||||||
val migrationInfo = prepareMigrationInfo(old, new) ?: return
|
val migrationInfo = prepareMigrationInfo(old, new) ?: return
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ package org.jetbrains.kotlin.idea.configuration.ui
|
|||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.openapi.ui.DialogWrapper
|
import com.intellij.openapi.ui.DialogWrapper
|
||||||
import org.jetbrains.kotlin.idea.configuration.MigrationInfo
|
import org.jetbrains.kotlin.idea.configuration.MigrationInfo
|
||||||
|
import org.jetbrains.kotlin.idea.migration.CodeMigrationToggleAction
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
|
|
||||||
internal class MigrationNotificationDialog(project: Project?, migrationInfo: MigrationInfo) : DialogWrapper(project, false) {
|
internal class MigrationNotificationDialog(val project: Project, migrationInfo: MigrationInfo) : DialogWrapper(project, false) {
|
||||||
private val form = MigrationNotificationForm()
|
private val form = MigrationNotificationForm()
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -21,12 +22,20 @@ internal class MigrationNotificationDialog(project: Project?, migrationInfo: Mig
|
|||||||
form.apiVersionInfo.isVisible = migrationInfo.oldApiVersion != migrationInfo.newApiVersion
|
form.apiVersionInfo.isVisible = migrationInfo.oldApiVersion != migrationInfo.newApiVersion
|
||||||
form.apiVersionInfo.text = "API version: ${migrationInfo.oldApiVersion} to ${migrationInfo.newApiVersion}"
|
form.apiVersionInfo.text = "API version: ${migrationInfo.oldApiVersion} to ${migrationInfo.newApiVersion}"
|
||||||
|
|
||||||
|
form.disableMigrationDetectionCheckBox.isSelected = !CodeMigrationToggleAction.isEnabled(project)
|
||||||
|
|
||||||
init()
|
init()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun createCenterPanel(): JComponent = form.mainPanel
|
override fun createCenterPanel(): JComponent = form.mainPanel
|
||||||
|
|
||||||
private fun saveSettings() {
|
private fun saveSettings() {
|
||||||
|
CodeMigrationToggleAction.setEnabled(project, !form.disableMigrationDetectionCheckBox.isSelected)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun doCancelAction() {
|
||||||
|
saveSettings()
|
||||||
|
super.doCancelAction()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun doOKAction() {
|
override fun doOKAction() {
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Disable migration detection"/>
|
<text value="Disable migrations detection"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
@@ -5,7 +5,18 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.migration
|
package org.jetbrains.kotlin.idea.migration
|
||||||
|
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
|
|
||||||
class CodeMigrationAction : CodeInspectionAction("Code Migration", "Code migration") {
|
class CodeMigrationAction : CodeInspectionAction("Code Migration", "Code migration") {
|
||||||
|
override fun update(e: AnActionEvent?) {
|
||||||
|
super.update(e)
|
||||||
|
|
||||||
|
val project = e?.project
|
||||||
|
if (project != null) {
|
||||||
|
e.presentation.isEnabledAndVisible = CodeMigrationToggleAction.isEnabled(project)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun getHelpTopic(): String {
|
override fun getHelpTopic(): String {
|
||||||
return "reference.dialogs.cleanup.scope"
|
return "reference.dialogs.cleanup.scope"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.migration
|
||||||
|
|
||||||
|
import com.intellij.ide.util.PropertiesComponent
|
||||||
|
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||||
|
import com.intellij.openapi.actionSystem.ToggleAction
|
||||||
|
import com.intellij.openapi.project.Project
|
||||||
|
|
||||||
|
class CodeMigrationToggleAction : ToggleAction() {
|
||||||
|
override fun isSelected(e: AnActionEvent): Boolean {
|
||||||
|
val project = e.project ?: return false
|
||||||
|
return isEnabled(project)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setSelected(e: AnActionEvent, state: Boolean) {
|
||||||
|
val project = e.project ?: return
|
||||||
|
setEnabled(project, state)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val MIGRATION_OPTION = "kotlin.migration.detection.enabled"
|
||||||
|
|
||||||
|
fun setEnabled(project: Project, state: Boolean) {
|
||||||
|
PropertiesComponent.getInstance(project).setValue(MIGRATION_OPTION, state, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isEnabled(project: Project): Boolean {
|
||||||
|
return PropertiesComponent.getInstance(project).getBoolean(MIGRATION_OPTION, true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user