public override object VisitPackageStatement(PackageStatementContext context) { var id = (Result)(Visit(context.id())); var obj = ""; var extend = (new list <string>()); if (context.packageStaticStatement() != null) { var item = context.packageStaticStatement(); var r = (Result)(Visit(item)); obj += r.text; } if (context.packageFieldStatement() != null) { var item = context.packageFieldStatement(); var r = (Result)(Visit(item)); obj += r.text; extend += (list <string>)(r.data); } if (context.packageNewStatement() != null) { var item = context.packageNewStatement(); var r = (string)(Visit(item)); obj += (new System.Text.StringBuilder().Append("public ").Append(id.text).Append(" ").Append(r)).to_str(); } obj += BlockRight + Wrap; var header = ""; if (context.annotationSupport() != null) { header += Visit(context.annotationSupport()); } header += (new System.Text.StringBuilder().Append(id.permission).Append(" partial class ").Append(id.text)).to_str(); var template = ""; var templateContract = ""; if (context.templateDefine() != null) { var item = (TemplateItem)(Visit(context.templateDefine())); template += item.Template; templateContract = item.Contract; header += template; } if (extend.length > 0) { var temp = extend[0]; foreach (var i in range(1, extend.length - 1, 1, true, true)) { temp += "," + extend[i]; } header += ":" + temp; } header += templateContract + BlockLeft + Wrap; obj = header + obj; return(obj); }
public override object VisitPackageStatement(PackageStatementContext context) { var id = ((Result)Visit(context.id())); var obj = ""; var extend = (new List <string>()); if (context.packageFieldStatement() != null) { var item = context.packageFieldStatement(); var r = ((Result)Visit(item)); obj += (new System.Text.StringBuilder().Append("public ").Append(id.text).Append(r.text)).To_Str(); extend.Append_all(((List <string>)r.data)); } if (context.packageNewStatement() != null) { var item = context.packageNewStatement(); var r = ((string)Visit(item)); obj += (new System.Text.StringBuilder().Append("public ").Append(id.text).Append(" ").Append(r)).To_Str(); } obj += BlockRight + Wrap; var header = ""; if (context.annotationSupport() != null) { header += Visit(context.annotationSupport()); } header += (new System.Text.StringBuilder().Append(id.permission).Append(" partial class ").Append(id.text)).To_Str(); var template = ""; var template_contract = ""; if (context.templateDefine() != null) { var item = ((TemplateItem)Visit(context.templateDefine())); template += item.template; template_contract = item.contract; header += template; } if (extend.Size() > 0) { var temp = extend[(0)]; foreach (var i in 1.Up_until(extend.Size())) { temp += "," + extend[(i)]; } header += ":" + temp; } header += template_contract + BlockLeft + Wrap; obj = header + obj; return(obj); }
public override object VisitPackageStatement([NotNull] PackageStatementContext context) { var id = (Result)Visit(context.id()); var obj = ""; var Init = ""; var extend = ""; if (context.extend() != null) { extend = (string)((Result)Visit(context.extend())).data; } // 获取构造数据 var paramConstructor = (string)Visit(context.parameterClausePackage()); Init += "public " + id.text + paramConstructor; // 加载继承 if (context.extend() != null) { Init += " :base " + ((Result)Visit(context.extend())).text; } Init += BlockLeft; foreach (var item in context.packageSupportStatement()) { obj += Visit(item); } if (context.packageOverrideStatement() != null) { obj += (string)Visit(context.packageOverrideStatement()); } // 处理构造函数 if (context.packageInitStatement() != null) { Init += Visit(context.packageInitStatement()); } Init += BlockRight; obj = Init + obj; obj += BlockRight + Terminate + Wrap; var header = ""; if (context.annotationSupport() != null) { header += Visit(context.annotationSupport()); } header += $"{id.permission} partial class {id.text}"; // 泛型 if (context.templateDefine() != null) { header += Visit(context.templateDefine()); } if (extend.Length > 0) { header += ":"; if (extend.Length > 0) { header += extend; } } header += Wrap + BlockLeft + Wrap; obj = header + obj; foreach (var item in context.protocolImplementStatement()) { obj += $"{id.permission} partial class {id.text} {(string)Visit(item)} {Wrap}"; } return(obj); }