Add internal action for reactivating post-open project activity

This commit is contained in:
Nikolay Krasko
2018-02-14 17:56:48 +03:00
parent 8a655b70e0
commit 86dfc1ae2c
4 changed files with 46 additions and 17 deletions
+2 -1
View File
@@ -6,7 +6,8 @@ dependencies {
compile(project(":compiler:light-classes")) compile(project(":compiler:light-classes"))
compile(project(":compiler:frontend.java")) compile(project(":compiler:frontend.java"))
compileOnly(intellijDep()) { includeJars("annotations", "openapi", "idea", "extensions", "util", "velocity", "boot", "gson", compileOnly(intellijDep()) { includeJars("annotations", "openapi", "idea", "extensions", "util", "velocity", "boot", "gson",
"swingx-core", "forms_rt", "jdom", "log4j", "guava", "asm-all", rootProject = rootProject) } "swingx-core", "forms_rt", "jdom", "log4j", "guava", "asm-all", "picocontainer",
rootProject = rootProject) }
compileOnly(commonDep("com.google.code.findbugs", "jsr305")) compileOnly(commonDep("com.google.code.findbugs", "jsr305"))
compileOnly(intellijPluginDep("junit")) { includeJars("idea-junit") } compileOnly(intellijPluginDep("junit")) { includeJars("idea-junit") }
@@ -0,0 +1,19 @@
/*
* Copyright 2000-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.actions.internal
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.project.impl.ProjectImpl
import org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent
class ReactivePostOpenProjectActionsAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project as? ProjectImpl ?: return
val configureComponent = project.getComponentInstancesOfType(KotlinConfigurationCheckerComponent::class.java).single()
configureComponent.performProjectPostOpenActions()
}
}
@@ -70,26 +70,30 @@ class KotlinConfigurationCheckerComponent(project: Project) : AbstractProjectCom
super.projectOpened() super.projectOpened()
StartupManager.getInstance(myProject).registerPostStartupActivity { StartupManager.getInstance(myProject).registerPostStartupActivity {
ApplicationManager.getApplication().executeOnPooledThread { performProjectPostOpenActions()
DumbService.getInstance(myProject).waitForSmartMode() }
}
for (module in getModulesWithKotlinFiles(myProject)) { fun performProjectPostOpenActions() {
module.getAndCacheLanguageLevelByDependencies() ApplicationManager.getApplication().executeOnPooledThread {
} DumbService.getInstance(myProject).waitForSmartMode()
val libraries = findOutdatedKotlinLibraries(myProject) for (module in getModulesWithKotlinFiles(myProject)) {
if (!libraries.isEmpty()) { module.getAndCacheLanguageLevelByDependencies()
ApplicationManager.getApplication().invokeLater { }
notifyOutdatedKotlinRuntime(myProject, libraries)
} val libraries = findOutdatedKotlinLibraries(myProject)
} if (!libraries.isEmpty()) {
if (!isSyncing) { ApplicationManager.getApplication().invokeLater {
val excludeModules = collectModulesWithOutdatedRuntime(libraries) notifyOutdatedKotlinRuntime(myProject, libraries)
showConfigureKotlinNotificationIfNeeded(myProject, excludeModules)
} else {
notificationPostponed = true
} }
} }
if (!isSyncing) {
val excludeModules = collectModulesWithOutdatedRuntime(libraries)
showConfigureKotlinNotificationIfNeeded(myProject, excludeModules)
} else {
notificationPostponed = true
}
} }
} }
+5
View File
@@ -46,6 +46,11 @@
class="org.jetbrains.kotlin.idea.internal.makeBackup.CreateIncrementalCompilationBackup"> class="org.jetbrains.kotlin.idea.internal.makeBackup.CreateIncrementalCompilationBackup">
<add-to-group group-id="KotlinInternalGroup"/> <add-to-group group-id="KotlinInternalGroup"/>
</action> </action>
<action id="ReactivePostOpenProjectActionsAction" class="org.jetbrains.kotlin.idea.actions.internal.ReactivePostOpenProjectActionsAction"
text="Kotlin Project Post-Open Activity">
<add-to-group group-id="KotlinInternalGroup"/>
</action>
</actions> </actions>
<extensions defaultExtensionNs="com.intellij"> <extensions defaultExtensionNs="com.intellij">