From 4af278ba9fd5665292d6a34669e09168f1377cd2 Mon Sep 17 00:00:00 2001 From: tangcent Date: Sun, 19 Nov 2023 16:20:39 +0800 Subject: [PATCH] Refactor: Preventing runtime.channel() from throwing exceptions on missing implementations (#1074) --- .../com/itangcent/idea/plugin/rule/StandardJdkRuleParser.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/StandardJdkRuleParser.kt b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/StandardJdkRuleParser.kt index a61006e3f..3c83cd4af 100644 --- a/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/StandardJdkRuleParser.kt +++ b/idea-plugin/src/main/kotlin/com/itangcent/idea/plugin/rule/StandardJdkRuleParser.kt @@ -8,6 +8,7 @@ import com.itangcent.annotation.script.ScriptTypeName import com.itangcent.common.text.TemplateEvaluator import com.itangcent.common.text.TemplateUtils import com.itangcent.common.text.union +import com.itangcent.common.utils.safe import com.itangcent.idea.plugin.api.export.ExportChannel import com.itangcent.idea.plugin.utils.LocalStorage import com.itangcent.idea.plugin.utils.RegexUtils @@ -270,7 +271,9 @@ abstract class StandardJdkRuleParser : ScriptRuleParser() { private val actionContext by lazy { ActionContext.getContext() } fun channel(): String? { - return actionContext?.instance(ExportChannel::class)?.channel() + return safe { + actionContext?.instance(ExportChannel::class)?.channel() + } } fun projectName(): String? {