check for project disposed in NewKotlinActivityAction (EA-82450 - assert: ComponentManagerImpl.getPicoContainer)

This commit is contained in:
Dmitry Jemerov
2016-08-11 19:57:56 +02:00
parent 7e1d8fb8f5
commit ef791fedde
@@ -183,14 +183,21 @@ class NewKotlinActivityAction: AnAction(KotlinIcons.ACTIVITY) {
override fun update(e: AnActionEvent) {
val view = LangDataKeys.IDE_VIEW.getData(e.dataContext)
val module = LangDataKeys.MODULE.getData(e.dataContext)
val facet = if (module != null) AndroidFacet.getInstance(module) else null
val facet = getKotlinFacet(e)
val presentation = e.presentation
val isProjectReady = facet != null && isProjectReady(facet)
presentation.text = "Kotlin Activity" + if (isProjectReady) "" else " (Project not ready)"
presentation.isVisible = view != null && facet != null && isVisible(facet)
}
private fun getKotlinFacet(e: AnActionEvent): AndroidFacet? {
val project = e.project
if (project == null || project.isDisposed) return null
val module = LangDataKeys.MODULE.getData(e.dataContext)
val facet = if (module != null) AndroidFacet.getInstance(module) else null
return facet
}
private fun isVisible(facet: AndroidFacet): Boolean {
try {
val shouldSetVisible = AndroidFacet::class.memberFunctions.singleOrNull {