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.
|
* 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.module.Module
|
||||||
import com.intellij.openapi.project.Project
|
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.MavenImportListener
|
||||||
import org.jetbrains.idea.maven.project.MavenProject
|
import org.jetbrains.idea.maven.project.MavenProject
|
||||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
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.configuration.notifyOutdatedBundledCompilerIfNecessary
|
||||||
import org.jetbrains.kotlin.idea.util.ProgressIndicatorUtils.runUnderDisposeAwareIndicator
|
import org.jetbrains.kotlin.idea.util.ProgressIndicatorUtils.runUnderDisposeAwareIndicator
|
||||||
|
|
||||||
class MavenImportListener(val project: Project) : MavenProjectsManager.Listener {
|
// BUNCH: 192
|
||||||
init {
|
class MavenImportListener : StartupActivity {
|
||||||
project.messageBus.connect(project).subscribe(
|
|
||||||
|
override fun runActivity(project: Project) {
|
||||||
|
project.messageBus.connect().subscribe(
|
||||||
MavenImportListener.TOPIC,
|
MavenImportListener.TOPIC,
|
||||||
MavenImportListener { _: Collection<MavenProject>, _: List<Module> ->
|
MavenImportListener { _: Collection<MavenProject>, _: List<Module> ->
|
||||||
runUnderDisposeAwareIndicator(project) {
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,4 @@
|
|||||||
<idea-plugin>
|
<idea-plugin>
|
||||||
<project-components>
|
|
||||||
<component>
|
|
||||||
<implementation-class>org.jetbrains.kotlin.idea.maven.MavenImportListener</implementation-class>
|
|
||||||
</component>
|
|
||||||
</project-components>
|
|
||||||
|
|
||||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||||
<projectConfigurator implementation="org.jetbrains.kotlin.idea.maven.configuration.KotlinJavaMavenConfigurator"/>
|
<projectConfigurator implementation="org.jetbrains.kotlin.idea.maven.configuration.KotlinJavaMavenConfigurator"/>
|
||||||
<projectConfigurator implementation="org.jetbrains.kotlin.idea.maven.configuration.KotlinJavascriptMavenConfigurator"/>
|
<projectConfigurator implementation="org.jetbrains.kotlin.idea.maven.configuration.KotlinJavascriptMavenConfigurator"/>
|
||||||
@@ -109,12 +103,6 @@
|
|||||||
implementation="org.jetbrains.kotlin.idea.maven.inspections.KotlinMavenUnresolvedReferenceQuickFixProvider" />
|
implementation="org.jetbrains.kotlin.idea.maven.inspections.KotlinMavenUnresolvedReferenceQuickFixProvider" />
|
||||||
</extensions>
|
</extensions>
|
||||||
|
|
||||||
<module-components>
|
|
||||||
<component>
|
|
||||||
<implementation-class>org.jetbrains.kotlin.idea.maven.KotlinImporterComponent</implementation-class>
|
|
||||||
</component>
|
|
||||||
</module-components>
|
|
||||||
|
|
||||||
<actions>
|
<actions>
|
||||||
<group id="KotlinMavenGenerate">
|
<group id="KotlinMavenGenerate">
|
||||||
<separator />
|
<separator />
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<idea-plugin>
|
||||||
|
<extensions defaultExtensionNs="com.intellij">
|
||||||
|
<postStartupActivity implementation="org.jetbrains.kotlin.idea.maven.MavenImportListener"/>
|
||||||
|
|
||||||
|
<moduleService serviceImplementation="org.jetbrains.kotlin.idea.maven.KotlinImporterComponent"/>
|
||||||
|
</extensions>
|
||||||
|
</idea-plugin>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<idea-plugin>
|
||||||
|
<project-components>
|
||||||
|
<component>
|
||||||
|
<implementation-class>org.jetbrains.kotlin.idea.maven.MavenImportListener</implementation-class>
|
||||||
|
</component>
|
||||||
|
</project-components>
|
||||||
|
</idea-plugin>
|
||||||
@@ -22,6 +22,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle</depends>
|
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle</depends>
|
||||||
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle</depends>
|
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle</depends>
|
||||||
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
||||||
|
<depends optional="true" config-file="maven-common.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
||||||
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle.java</depends>
|
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle.java</depends>
|
||||||
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle.java</depends>
|
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle.java</depends>
|
||||||
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
||||||
|
<depends optional="true" config-file="maven-common.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
||||||
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle.java</depends>
|
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle.java</depends>
|
||||||
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle.java</depends>
|
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle.java</depends>
|
||||||
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
||||||
|
<depends optional="true" config-file="maven-common.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
||||||
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle</depends>
|
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle</depends>
|
||||||
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle</depends>
|
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle</depends>
|
||||||
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
||||||
|
<depends optional="true" config-file="maven-common.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
||||||
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle.java</depends>
|
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle.java</depends>
|
||||||
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle.java</depends>
|
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle.java</depends>
|
||||||
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
||||||
|
<depends optional="true" config-file="maven-common.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
||||||
<depends optional="true" config-file="kotlin-copyright.xml">com.intellij.copyright</depends>
|
<depends optional="true" config-file="kotlin-copyright.xml">com.intellij.copyright</depends>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle.java</depends>
|
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle.java</depends>
|
||||||
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle.java</depends>
|
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle.java</depends>
|
||||||
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
||||||
|
<depends optional="true" config-file="maven-common.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
||||||
<depends optional="true" config-file="kotlin-copyright.xml">com.intellij.copyright</depends>
|
<depends optional="true" config-file="kotlin-copyright.xml">com.intellij.copyright</depends>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
|||||||
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle</depends>
|
<depends optional="true" config-file="gradle-java.xml">org.jetbrains.plugins.gradle</depends>
|
||||||
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle</depends>
|
<depends optional="true" config-file="kotlin-gradle-testing.xml">org.jetbrains.plugins.gradle</depends>
|
||||||
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
<depends optional="true" config-file="gradle-groovy.xml">org.intellij.groovy</depends>
|
||||||
|
<depends optional="true" config-file="maven-common.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
<depends optional="true" config-file="maven.xml">org.jetbrains.idea.maven</depends>
|
||||||
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
<depends optional="true" config-file="testng-j.xml">TestNG-J</depends>
|
||||||
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
<depends optional="true" config-file="coverage.xml">Coverage</depends>
|
||||||
|
|||||||
Reference in New Issue
Block a user