From e845331dd1a2e2d4876e03765f492c42d440852e Mon Sep 17 00:00:00 2001 From: walon Date: Wed, 17 Apr 2024 09:54:19 +0800 Subject: [PATCH] =?UTF-8?q?[change]=20cs-editor-json=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=8D=95=E7=8B=AC=E7=9A=84target=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E4=B8=94=E4=BB=8E=E5=BD=93=E5=89=8Dtarget=E4=B8=AD?= =?UTF-8?q?=E8=8E=B7=E5=8F=96topModule=E8=80=8C=E4=B8=8D=E6=98=AFeditor.to?= =?UTF-8?q?pModule=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CodeTarget/CsharpEditorJsonCodeTarget.cs | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/Luban.CSharp/CodeTarget/CsharpEditorJsonCodeTarget.cs b/src/Luban.CSharp/CodeTarget/CsharpEditorJsonCodeTarget.cs index 0506ffec..08185e0d 100644 --- a/src/Luban.CSharp/CodeTarget/CsharpEditorJsonCodeTarget.cs +++ b/src/Luban.CSharp/CodeTarget/CsharpEditorJsonCodeTarget.cs @@ -41,25 +41,19 @@ public override void Handle(GenerationContext ctx, OutputFileManifest manifest) } } - private string TopModule => EnvManager.Current.GetOptionOrDefault("editor", "topModule", true, "editor.cfg"); - - private string MakeNameWithTopModule(string name) - { - return TypeUtil.MakeFullName(TopModule, name); - } - public override void GenerateBean(GenerationContext ctx, DefBean bean, CodeWriter writer) { var template = GetTemplate("bean"); var tplCtx = CreateTemplateContext(template); + string topModule = ctx.Target.TopModule; var extraEnvs = new ScriptObject { { "__ctx", ctx}, - { "__top_module", TopModule }, + { "__top_module", topModule }, { "__name", bean.Name }, { "__namespace", bean.Namespace }, - { "__namespace_with_top_module", MakeNameWithTopModule(bean.Namespace) }, - { "__full_name_with_top_module", MakeNameWithTopModule(bean.FullName) }, + { "__namespace_with_top_module", TypeUtil.MakeFullName(topModule, bean.Namespace) }, + { "__full_name_with_top_module", TypeUtil.MakeFullName(topModule, bean.FullName) }, { "__bean", bean }, { "__this", bean }, {"__fields", bean.Fields}, @@ -75,14 +69,15 @@ public override void GenerateEnum(GenerationContext ctx, DefEnum @enum, CodeWrit { var template = GetTemplate("enum"); var tplCtx = CreateTemplateContext(template); + string topModule = ctx.Target.TopModule; var extraEnvs = new ScriptObject { { "__ctx", ctx}, { "__name", @enum.Name }, { "__namespace", @enum.Namespace }, - { "__top_module", TopModule }, - { "__namespace_with_top_module", MakeNameWithTopModule(@enum.Namespace) }, - { "__full_name_with_top_module", MakeNameWithTopModule(@enum.FullName) }, + { "__top_module", topModule }, + { "__namespace_with_top_module", TypeUtil.MakeFullName(topModule, @enum.Namespace) }, + { "__full_name_with_top_module", TypeUtil.MakeFullName(topModule, @enum.FullName) }, { "__enum", @enum }, { "__this", @enum }, { "__code_style", CodeStyle},