Convert MavenImportListener into an application service
Relates to #KT-38407
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
6e5b288500
commit
c2c8d81b49
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.maven
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.startup.StartupActivity
|
||||
import org.jetbrains.idea.maven.project.MavenImportListener
|
||||
import org.jetbrains.idea.maven.project.MavenProject
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
||||
@@ -14,9 +15,11 @@ import org.jetbrains.kotlin.idea.configuration.KotlinMigrationProjectService
|
||||
import org.jetbrains.kotlin.idea.configuration.notifyOutdatedBundledCompilerIfNecessary
|
||||
import org.jetbrains.kotlin.idea.util.ProgressIndicatorUtils.runUnderDisposeAwareIndicator
|
||||
|
||||
class MavenImportListener(val project: Project) : MavenProjectsManager.Listener {
|
||||
init {
|
||||
project.messageBus.connect(project).subscribe(
|
||||
// BUNCH: 192
|
||||
class MavenImportListener : StartupActivity {
|
||||
|
||||
override fun runActivity(project: Project) {
|
||||
project.messageBus.connect().subscribe(
|
||||
MavenImportListener.TOPIC,
|
||||
MavenImportListener { _: Collection<MavenProject>, _: List<Module> ->
|
||||
runUnderDisposeAwareIndicator(project) {
|
||||
@@ -26,12 +29,14 @@ class MavenImportListener(val project: Project) : MavenProjectsManager.Listener
|
||||
}
|
||||
)
|
||||
|
||||
MavenProjectsManager.getInstance(project)?.addManagerListener(this)
|
||||
MavenProjectsManager.getInstance(project)?.addManagerListener(object : MavenProjectsManager.Listener {
|
||||
override fun projectsScheduled() {
|
||||
runUnderDisposeAwareIndicator(project) {
|
||||
KotlinMigrationProjectService.getInstance(project).onImportAboutToStart()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun projectsScheduled() {
|
||||
runUnderDisposeAwareIndicator(project) {
|
||||
KotlinMigrationProjectService.getInstance(project).onImportAboutToStart()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.maven
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.idea.maven.project.MavenImportListener
|
||||
import org.jetbrains.idea.maven.project.MavenProject
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinMigrationProjectService
|
||||
import org.jetbrains.kotlin.idea.configuration.notifyOutdatedBundledCompilerIfNecessary
|
||||
import org.jetbrains.kotlin.idea.util.ProgressIndicatorUtils.runUnderDisposeAwareIndicator
|
||||
|
||||
// BUNCH: 192
|
||||
class MavenImportListener(val project: Project) : MavenProjectsManager.Listener {
|
||||
init {
|
||||
project.messageBus.connect(project).subscribe(
|
||||
MavenImportListener.TOPIC,
|
||||
MavenImportListener { _: Collection<MavenProject>, _: List<Module> ->
|
||||
runUnderDisposeAwareIndicator(project) {
|
||||
notifyOutdatedBundledCompilerIfNecessary(project)
|
||||
KotlinMigrationProjectService.getInstance(project).onImportFinished()
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
MavenProjectsManager.getInstance(project)?.addManagerListener(this)
|
||||
}
|
||||
|
||||
override fun projectsScheduled() {
|
||||
runUnderDisposeAwareIndicator(project) {
|
||||
KotlinMigrationProjectService.getInstance(project).onImportAboutToStart()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user