mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ExecutorAction — be tolerant to incompatible plugins
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,6 +26,8 @@ import com.intellij.openapi.actionSystem.ActionManager
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.diagnostic.catchAndLog
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.util.Key
|
||||
|
||||
/**
|
||||
@@ -40,8 +42,10 @@ class ExecutorAction private constructor(private val myOrigin: AnAction,
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LOG = logger<ExecutorAction>()
|
||||
private val CONFIGURATION_CACHE = Key.create<List<ConfigurationFromContext>>("ConfigurationFromContext")
|
||||
|
||||
@JvmStatic
|
||||
fun getActions(order: Int): Array<AnAction> {
|
||||
return ExecutorRegistry.getInstance().registeredExecutors.map {
|
||||
ExecutorAction(ActionManager.getInstance().getAction(it.contextActionId), it, order)
|
||||
@@ -63,9 +67,11 @@ class ExecutorAction private constructor(private val myOrigin: AnAction,
|
||||
return emptyList()
|
||||
}
|
||||
return RunConfigurationProducer.getProducers(context.project).mapNotNull {
|
||||
val configuration = it.createLightConfiguration(context) ?: return@mapNotNull null
|
||||
val settings = RunnerAndConfigurationSettingsImpl(RunManagerImpl.getInstanceImpl(context.project), configuration, false)
|
||||
ConfigurationFromContextImpl(it, settings, context.psiLocation)
|
||||
LOG.catchAndLog {
|
||||
val configuration = it.createLightConfiguration(context) ?: return@mapNotNull null
|
||||
val settings = RunnerAndConfigurationSettingsImpl(RunManagerImpl.getInstanceImpl(context.project), configuration, false)
|
||||
ConfigurationFromContextImpl(it, settings, context.psiLocation)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,13 +27,15 @@ inline fun Logger.debug(e: Exception? = null, lazyMessage: () -> String) {
|
||||
}
|
||||
}
|
||||
|
||||
inline fun Logger.catchAndLog(runnable: () -> Unit) {
|
||||
inline fun <T> Logger.catchAndLog(runnable: () -> T): T? {
|
||||
try {
|
||||
runnable()
|
||||
return runnable()
|
||||
}
|
||||
catch (e: ProcessCanceledException) {
|
||||
return null
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
error(e)
|
||||
return null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user