Dropping components cleanup
#KT-38407 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
d2a26e9049
commit
8979b98fc0
+1
@@ -38,6 +38,7 @@ val KOTLIN_CONSOLE_KEY = Key.create<Boolean>("kotlin.console")
|
|||||||
/**
|
/**
|
||||||
* Tested in OutOfBlockModificationTestGenerated
|
* Tested in OutOfBlockModificationTestGenerated
|
||||||
*/
|
*/
|
||||||
|
// BUNCH: 193
|
||||||
class KotlinCodeBlockModificationListener(
|
class KotlinCodeBlockModificationListener(
|
||||||
modificationTracker: PsiModificationTracker,
|
modificationTracker: PsiModificationTracker,
|
||||||
project: Project,
|
project: Project,
|
||||||
|
|||||||
+1
@@ -39,6 +39,7 @@ val KOTLIN_CONSOLE_KEY = Key.create<Boolean>("kotlin.console")
|
|||||||
/**
|
/**
|
||||||
* Tested in OutOfBlockModificationTestGenerated
|
* Tested in OutOfBlockModificationTestGenerated
|
||||||
*/
|
*/
|
||||||
|
// BUNCH: 193
|
||||||
class KotlinCodeBlockModificationListener(project: Project) : PsiTreeChangePreprocessor {
|
class KotlinCodeBlockModificationListener(project: Project) : PsiTreeChangePreprocessor {
|
||||||
private val treeAspect: TreeAspect = TreeAspect.getInstance(project)
|
private val treeAspect: TreeAspect = TreeAspect.getInstance(project)
|
||||||
|
|
||||||
|
|||||||
+26
-23
@@ -9,7 +9,6 @@ import com.intellij.ProjectTopics
|
|||||||
import com.intellij.notification.Notification
|
import com.intellij.notification.Notification
|
||||||
import com.intellij.notification.NotificationType
|
import com.intellij.notification.NotificationType
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
|
||||||
import com.intellij.openapi.application.ModalityState
|
import com.intellij.openapi.application.ModalityState
|
||||||
import com.intellij.openapi.application.ReadAction.nonBlocking
|
import com.intellij.openapi.application.ReadAction.nonBlocking
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
@@ -27,6 +26,8 @@ import org.jetbrains.kotlin.idea.caches.project.getModuleInfosFromIdeaModel
|
|||||||
import org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryNameUtil.isGradleLibraryName
|
import org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryNameUtil.isGradleLibraryName
|
||||||
import org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryNameUtil.parseIDELibraryName
|
import org.jetbrains.kotlin.idea.configuration.klib.KotlinNativeLibraryNameUtil.parseIDELibraryName
|
||||||
import org.jetbrains.kotlin.idea.klib.KlibCompatibilityInfo.IncompatibleMetadata
|
import org.jetbrains.kotlin.idea.klib.KlibCompatibilityInfo.IncompatibleMetadata
|
||||||
|
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
||||||
|
import org.jetbrains.kotlin.idea.util.application.isUnitTestMode
|
||||||
import org.jetbrains.kotlin.idea.versions.UnsupportedAbiVersionNotificationPanelProvider
|
import org.jetbrains.kotlin.idea.versions.UnsupportedAbiVersionNotificationPanelProvider
|
||||||
import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion
|
import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion
|
||||||
import org.jetbrains.kotlin.konan.library.KONAN_STDLIB_NAME
|
import org.jetbrains.kotlin.konan.library.KONAN_STDLIB_NAME
|
||||||
@@ -34,6 +35,20 @@ import org.jetbrains.kotlin.konan.library.KONAN_STDLIB_NAME
|
|||||||
// BUNCH: 192
|
// BUNCH: 192
|
||||||
/** TODO: merge [KotlinNativeABICompatibilityChecker] in the future with [UnsupportedAbiVersionNotificationPanelProvider], KT-34525 */
|
/** TODO: merge [KotlinNativeABICompatibilityChecker] in the future with [UnsupportedAbiVersionNotificationPanelProvider], KT-34525 */
|
||||||
class KotlinNativeABICompatibilityChecker : StartupActivity {
|
class KotlinNativeABICompatibilityChecker : StartupActivity {
|
||||||
|
override fun runActivity(project: Project) {
|
||||||
|
val service = KotlinNativeABICompatibilityCheckerService.getInstance(project)
|
||||||
|
project.messageBus.connect().subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener {
|
||||||
|
override fun rootsChanged(event: ModuleRootEvent) {
|
||||||
|
// run when project roots are changes, e.g. on project import
|
||||||
|
service.validateKotlinNativeLibraries()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
service.validateKotlinNativeLibraries()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class KotlinNativeABICompatibilityCheckerService(private val project: Project) {
|
||||||
|
|
||||||
private sealed class LibraryGroup(private val ordinal: Int) : Comparable<LibraryGroup> {
|
private sealed class LibraryGroup(private val ordinal: Int) : Comparable<LibraryGroup> {
|
||||||
|
|
||||||
@@ -48,34 +63,21 @@ class KotlinNativeABICompatibilityChecker : StartupActivity {
|
|||||||
object User : LibraryGroup(2)
|
object User : LibraryGroup(2)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val cachedIncompatibleLibrariesPerProject = mutableMapOf<Project, MutableSet<String>>()
|
private val cachedIncompatibleLibraries = mutableSetOf<String>()
|
||||||
|
|
||||||
override fun runActivity(project: Project) {
|
internal fun validateKotlinNativeLibraries() {
|
||||||
project.messageBus.connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener {
|
if (isUnitTestMode() || project.isDisposed) return
|
||||||
override fun rootsChanged(event: ModuleRootEvent) {
|
|
||||||
// run when project roots are changes, e.g. on project import
|
|
||||||
validateKotlinNativeLibraries(project)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
validateKotlinNativeLibraries(project)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun validateKotlinNativeLibraries(project: Project) {
|
|
||||||
if (ApplicationManager.getApplication().isUnitTestMode || project.isDisposed)
|
|
||||||
return
|
|
||||||
|
|
||||||
val backgroundJob: Ref<CancellablePromise<*>> = Ref()
|
val backgroundJob: Ref<CancellablePromise<*>> = Ref()
|
||||||
val disposable = Disposable {
|
val disposable = Disposable {
|
||||||
cachedIncompatibleLibrariesPerProject.remove(project)
|
|
||||||
backgroundJob.get()?.let(CancellablePromise<*>::cancel)
|
backgroundJob.get()?.let(CancellablePromise<*>::cancel)
|
||||||
}
|
}
|
||||||
Disposer.register(project, disposable)
|
Disposer.register(project, disposable)
|
||||||
|
|
||||||
backgroundJob.set(
|
backgroundJob.set(
|
||||||
nonBlocking<List<Notification>> {
|
nonBlocking<List<Notification>> {
|
||||||
val librariesToNotify = getLibrariesToNotifyAbout(project)
|
val librariesToNotify = getLibrariesToNotifyAbout()
|
||||||
prepareNotifications(project, librariesToNotify)
|
prepareNotifications(librariesToNotify)
|
||||||
}
|
}
|
||||||
.finishOnUiThread(ModalityState.defaultModalityState()) { notifications ->
|
.finishOnUiThread(ModalityState.defaultModalityState()) { notifications ->
|
||||||
notifications.forEach {
|
notifications.forEach {
|
||||||
@@ -83,7 +85,7 @@ class KotlinNativeABICompatibilityChecker : StartupActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.expireWith(project) // cancel job when project is disposed
|
.expireWith(project) // cancel job when project is disposed
|
||||||
.coalesceBy(this@KotlinNativeABICompatibilityChecker) // cancel previous job when new one is submitted
|
.coalesceBy(this@KotlinNativeABICompatibilityCheckerService) // cancel previous job when new one is submitted
|
||||||
.withDocumentsCommitted(project)
|
.withDocumentsCommitted(project)
|
||||||
.submit(AppExecutorUtil.getAppExecutorService())
|
.submit(AppExecutorUtil.getAppExecutorService())
|
||||||
.onProcessed {
|
.onProcessed {
|
||||||
@@ -92,13 +94,12 @@ class KotlinNativeABICompatibilityChecker : StartupActivity {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getLibrariesToNotifyAbout(project: Project): Map<String, NativeKlibLibraryInfo> {
|
private fun getLibrariesToNotifyAbout(): Map<String, NativeKlibLibraryInfo> {
|
||||||
val incompatibleLibraries = getModuleInfosFromIdeaModel(project)
|
val incompatibleLibraries = getModuleInfosFromIdeaModel(project)
|
||||||
.filterIsInstance<NativeKlibLibraryInfo>()
|
.filterIsInstance<NativeKlibLibraryInfo>()
|
||||||
.filter { !it.compatibilityInfo.isCompatible }
|
.filter { !it.compatibilityInfo.isCompatible }
|
||||||
.associateBy { it.libraryRoot }
|
.associateBy { it.libraryRoot }
|
||||||
|
|
||||||
val cachedIncompatibleLibraries = cachedIncompatibleLibrariesPerProject.computeIfAbsent(project) { mutableSetOf() }
|
|
||||||
val newEntries = if (cachedIncompatibleLibraries.isNotEmpty())
|
val newEntries = if (cachedIncompatibleLibraries.isNotEmpty())
|
||||||
incompatibleLibraries.filterKeys { it !in cachedIncompatibleLibraries }
|
incompatibleLibraries.filterKeys { it !in cachedIncompatibleLibraries }
|
||||||
else
|
else
|
||||||
@@ -110,7 +111,7 @@ class KotlinNativeABICompatibilityChecker : StartupActivity {
|
|||||||
return newEntries
|
return newEntries
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun prepareNotifications(project: Project, librariesToNotify: Map<String, NativeKlibLibraryInfo>): List<Notification> {
|
private fun prepareNotifications(librariesToNotify: Map<String, NativeKlibLibraryInfo>): List<Notification> {
|
||||||
if (librariesToNotify.isEmpty())
|
if (librariesToNotify.isEmpty())
|
||||||
return emptyList()
|
return emptyList()
|
||||||
|
|
||||||
@@ -222,5 +223,7 @@ class KotlinNativeABICompatibilityChecker : StartupActivity {
|
|||||||
|
|
||||||
private val NOTIFICATION_TITLE get() = KotlinGradleNativeBundle.message("error.incompatible.libraries.title")
|
private val NOTIFICATION_TITLE get() = KotlinGradleNativeBundle.message("error.incompatible.libraries.title")
|
||||||
private const val NOTIFICATION_GROUP_ID = "Incompatible Kotlin/Native libraries"
|
private const val NOTIFICATION_GROUP_ID = "Incompatible Kotlin/Native libraries"
|
||||||
|
|
||||||
|
fun getInstance(project: Project): KotlinNativeABICompatibilityCheckerService = project.getServiceSafe()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ class GradleScriptDefinitionsContributor(private val project: Project) : ScriptD
|
|||||||
reload()
|
reload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
project.messageBus.connect(project).subscribe(GradleSettingsListener.TOPIC, listener)
|
project.messageBus.connect().subscribe(GradleSettingsListener.TOPIC, listener)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: control flow here depends on suppressing exceptions from loadGradleTemplates calls
|
// NOTE: control flow here depends on suppressing exceptions from loadGradleTemplates calls
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import com.intellij.ui.EditorNotifications
|
|||||||
|
|
||||||
class JvmStartupActivity : StartupActivity {
|
class JvmStartupActivity : StartupActivity {
|
||||||
override fun runActivity(project: Project) {
|
override fun runActivity(project: Project) {
|
||||||
val connection = project.messageBus.connect(project)
|
val connection = project.messageBus.connect()
|
||||||
connection.subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener {
|
connection.subscribe(ProjectTopics.PROJECT_ROOTS, object : ModuleRootListener {
|
||||||
override fun rootsChanged(event: ModuleRootEvent) {
|
override fun rootsChanged(event: ModuleRootEvent) {
|
||||||
EditorNotifications.getInstance(project).updateAllNotifications()
|
EditorNotifications.getInstance(project).updateAllNotifications()
|
||||||
|
|||||||
+1
-2
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.idea.configuration.getModulesWithKotlinFiles
|
|||||||
import org.jetbrains.kotlin.idea.configuration.notifyOutdatedBundledCompilerIfNecessary
|
import org.jetbrains.kotlin.idea.configuration.notifyOutdatedBundledCompilerIfNecessary
|
||||||
import org.jetbrains.kotlin.idea.configuration.ui.notifications.notifyKotlinStyleUpdateIfNeeded
|
import org.jetbrains.kotlin.idea.configuration.ui.notifications.notifyKotlinStyleUpdateIfNeeded
|
||||||
import org.jetbrains.kotlin.idea.project.getAndCacheLanguageLevelByDependencies
|
import org.jetbrains.kotlin.idea.project.getAndCacheLanguageLevelByDependencies
|
||||||
import org.jetbrains.kotlin.idea.util.ProgressIndicatorUtils
|
|
||||||
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
import org.jetbrains.kotlin.idea.util.application.getServiceSafe
|
||||||
import org.jetbrains.kotlin.idea.util.application.isUnitTestMode
|
import org.jetbrains.kotlin.idea.util.application.isUnitTestMode
|
||||||
import java.util.concurrent.Callable
|
import java.util.concurrent.Callable
|
||||||
@@ -46,7 +45,7 @@ class KotlinConfigurationCheckerStartupActivity : StartupActivity {
|
|||||||
NotificationDisplayType.STICKY_BALLOON, true
|
NotificationDisplayType.STICKY_BALLOON, true
|
||||||
)
|
)
|
||||||
|
|
||||||
val connection = project.messageBus.connect(project)
|
val connection = project.messageBus.connect()
|
||||||
connection.subscribe(ProjectDataImportListener.TOPIC, ProjectDataImportListener {
|
connection.subscribe(ProjectDataImportListener.TOPIC, ProjectDataImportListener {
|
||||||
notifyOutdatedBundledCompilerIfNecessary(project)
|
notifyOutdatedBundledCompilerIfNecessary(project)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,5 +3,6 @@
|
|||||||
<postStartupActivity implementation="org.jetbrains.kotlin.ide.konan.KotlinNativeABICompatibilityChecker"/>
|
<postStartupActivity implementation="org.jetbrains.kotlin.ide.konan.KotlinNativeABICompatibilityChecker"/>
|
||||||
|
|
||||||
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.klib.KlibLoadingMetadataCache" />
|
<applicationService serviceImplementation="org.jetbrains.kotlin.idea.klib.KlibLoadingMetadataCache" />
|
||||||
|
<projectService serviceImplementation="org.jetbrains.kotlin.ide.konan.KotlinNativeABICompatibilityCheckerService" />
|
||||||
</extensions>
|
</extensions>
|
||||||
</idea-plugin>
|
</idea-plugin>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFromTemplate"/>
|
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewFromTemplate"/>
|
||||||
</action>
|
</action>
|
||||||
|
|
||||||
<group id = "ConvertJavaToKotlinGroup">
|
<group id="ConvertJavaToKotlinGroup">
|
||||||
<separator/>
|
<separator/>
|
||||||
<action id="ConvertJavaToKotlin" class="org.jetbrains.kotlin.idea.actions.JavaToKotlinAction">
|
<action id="ConvertJavaToKotlin" class="org.jetbrains.kotlin.idea.actions.JavaToKotlinAction">
|
||||||
<keyboard-shortcut keymap="$default" first-keystroke="control alt shift K"/>
|
<keyboard-shortcut keymap="$default" first-keystroke="control alt shift K"/>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.idea.util.ProgressIndicatorUtils.runUnderDisposeAwar
|
|||||||
class KotlinMigrationProjectComponent : StartupActivity {
|
class KotlinMigrationProjectComponent : StartupActivity {
|
||||||
|
|
||||||
override fun runActivity(project: Project) {
|
override fun runActivity(project: Project) {
|
||||||
val connection = project.messageBus.connect(project)
|
val connection = project.messageBus.connect()
|
||||||
connection.subscribe(ProjectDataImportListener.TOPIC, ProjectDataImportListener {
|
connection.subscribe(ProjectDataImportListener.TOPIC, ProjectDataImportListener {
|
||||||
runUnderDisposeAwareIndicator(project) {
|
runUnderDisposeAwareIndicator(project) {
|
||||||
KotlinMigrationProjectService.getInstance(project).onImportFinished()
|
KotlinMigrationProjectService.getInstance(project).onImportFinished()
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class KotlinFacetSettingsProviderImpl(private val project: Project) : KotlinFace
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
project.messageBus.connect(project).subscribe(
|
project.messageBus.connect().subscribe(
|
||||||
ProjectTopics.PROJECT_ROOTS,
|
ProjectTopics.PROJECT_ROOTS,
|
||||||
object : ModuleRootListener {
|
object : ModuleRootListener {
|
||||||
override fun rootsChanged(event: ModuleRootEvent) {
|
override fun rootsChanged(event: ModuleRootEvent) {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class LibraryEffectiveKindProviderImpl(project: Project) : LibraryEffectiveKindP
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
project.messageBus.connect(project).subscribe(
|
project.messageBus.connect().subscribe(
|
||||||
ProjectTopics.PROJECT_ROOTS,
|
ProjectTopics.PROJECT_ROOTS,
|
||||||
object : ModuleRootListener {
|
object : ModuleRootListener {
|
||||||
override fun rootsChanged(event: ModuleRootEvent) {
|
override fun rootsChanged(event: ModuleRootEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user