Skip to content

Commit

Permalink
[change] cs-editor-json需要使用单独的target,并且从当前target中获取topModule而不是editor…
Browse files Browse the repository at this point in the history
….topModule环境变量
  • Loading branch information
pirunxi committed Apr 17, 2024
1 parent 5850f37 commit e845331
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/Luban.CSharp/CodeTarget/CsharpEditorJsonCodeTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand All @@ -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},
Expand Down

0 comments on commit e845331

Please sign in to comment.