private static void WriteCommonAttributes(IndentWriter writer, SchemaExtension serviceExt) { if (serviceExt.ExchangeIn.IsSome && serviceExt.ExchangeInType.IsSome) { writer.WriteLine( $"[ExchangeIn(ExchangeType.{serviceExt.ExchangeInType.Unwrap()}, \"{serviceExt.ExchangeIn.Unwrap()}\")]"); } else if (serviceExt.ExchangeIn.IsSome) { writer.WriteLine($"[ExchangeIn(name = \"{serviceExt.ExchangeIn.Unwrap()}\")]"); } else if (serviceExt.ExchangeInType.IsSome) { writer.WriteLine($"[ExchangeIn(ExchangeType.{serviceExt.ExchangeInType.Unwrap()})]"); } if (serviceExt.ExchangeIn.IsSome && serviceExt.ExchangeOutType.IsSome) { writer.WriteLine( $"[ExchangeIn(ExchangeType.{serviceExt.ExchangeOutType.Unwrap()}, \"{serviceExt.ExchangeOut.Unwrap()}\")]"); } else if (serviceExt.ExchangeOut.IsSome) { writer.WriteLine($"[ExchangeIn(name = \"{serviceExt.ExchangeOut.Unwrap()}\")]"); } else if (serviceExt.ExchangeOutType.IsSome) { writer.WriteLine($"[ExchangeIn(ExchangeType.{serviceExt.ExchangeOutType.Unwrap()})]"); } serviceExt.RoutingKey.IfSome(p => writer.WriteLine($"[RoutingKey(\"{p}\")]")); }
private void Switch(IReadOnlyList <string> inlines, IndentWriter outlines) { var start = 0; for (; start < inlines.Count; ++start) { if (inlines[start] == "\t\t\tswitch(node.Symbol.ID)") { break; } } outlines.Block("switch(node.Symbol.ID)", () => { for (start += 2; start < inlines.Count; ++start) { var line = inlines[start]; if (line == "\t\t\t}") { outlines.Indend("default:", () => { outlines.WriteLine("throw new NotImplementedException();"); }); break; } line = line.Replace("visitor.", "return (T)"); line = line.Replace(" break;", string.Empty); line = line.TrimStart('\t'); outlines.WriteLine(line); } }); }
private static void PpTerminal(IndentWriter writer, Terminal terminal) { var p = terminal.IsPrivate ? "private " : ""; var a = terminal.IsGenerated ? $"{terminal.Visual} " : ""; writer.Indend($"{terminal.Name} // {p}{a}({terminal.Id})", () => { if (terminal.Raw.Expression is Alternates alternates) { bool more = false; foreach (var alt in alternates.Expressions) { if (more) { writer.Write("| "); } else { writer.Write(": "); } more = true; alt.Dump(writer); writer.WriteLine(); } } else { writer.Write(": "); terminal.Raw.Expression.Dump(writer); writer.WriteLine(); } writer.WriteLine(";"); }); }
private void executeElseNode(JadeModel model, IndentWriter writer, JadeTemplate template) { if (elseNode != null) { elseNode.execute(writer, model, template); } }
public void Generate(Stream stream, string @namespace, ResxResult mainResx, ResxResult localizedResx = null) { using (IndentWriter w = new IndentWriter(stream)) { WriteModule(w, 0, @namespace, mainResx, localizedResx); } }
protected internal override void Print(IndentWriter writer) { writer.WriteLine( "TableLookupNode " + " tableLookupPlan=" + TableLookupPlan); }
public override void StreamDebug(TextWriter target) { var writer = new IndentWriter(target); writer.WriteLine(ToString()); writer.IncIndent(); writer.WriteLine($"Calc From All Levels >= PC Level: {CalcFromPCLevel}"); writer.WriteLine($"Calc For Each Item: {CalcForEachItem}"); writer.WriteLine($"Chance None: {ChanceNone}"); if (ItemList.Count > 0) { writer.WriteLine("Items"); writer.IncIndent(); var table = new Table("Name", "PC Level"); foreach (var item in ItemList) { table.AddRow(item.Name, item.PCLevel); } table.Print(writer); writer.DecIndent(); } writer.DecIndent(); }
/// <summary> /// Generate the lines that show information about subcommands /// </summary> /// <param name="application">The app</param> /// <param name="output">Help text output</param> /// <param name="visibleCommands">Commands not hidden from help text</param> /// <param name="firstColumnWidth">The width of the first column of commands, arguments, and options</param> protected virtual void GenerateCommands( CommandLineApplication application, TextWriter output, IReadOnlyList <CommandLineApplication> visibleCommands, int firstColumnWidth) { if (visibleCommands.Any()) { output.WriteLine(); output.WriteLine("Commands:"); var outputFormat = string.Format(" {{0, -{0}}}{{1}}", firstColumnWidth); var orderedCommands = SortCommandsByName ? visibleCommands.OrderBy(c => c.Name).ToList() : visibleCommands; foreach (var cmd in orderedCommands) { var description = cmd.Description; var wrappedDescription = IndentWriter?.Write(description); var message = string.Format(outputFormat, cmd.Name, wrappedDescription); output.Write(message); output.WriteLine(); } if (application.OptionHelp != null) { output.WriteLine(); output.WriteLine($"Run '{application.Name} [command] --{application.OptionHelp.LongName}' for more information about a command."); } } }
/// <summary> /// Generate the lines that show information about options /// </summary> /// <param name="application">The app</param> /// <param name="output">Help text output</param> /// <param name="visibleOptions">Options not hidden from help text</param> /// <param name="firstColumnWidth">The width of the first column of commands, arguments, and options</param> protected virtual void GenerateOptions( CommandLineApplication application, TextWriter output, IReadOnlyList <CommandOption> visibleOptions, int firstColumnWidth) { if (visibleOptions.Any()) { output.WriteLine(); output.WriteLine("Options:"); var outputFormat = string.Format(" {{0, -{0}}}{{1}}", firstColumnWidth); foreach (var opt in visibleOptions) { var enumNames = ExtractNamesFromEnum(opt.UnderlyingType); var description = enumNames.Any() ? $"{opt.Description}\nAllowed values are: {string.Join(", ", enumNames)}" : opt.Description; var wrappedDescription = IndentWriter?.Write(description); var message = string.Format(outputFormat, Format(opt), wrappedDescription); output.Write(message); output.WriteLine(); } } }
protected override void GenerateOptions(CommandLineApplication application, TextWriter output, IReadOnlyList <CommandOption> visibleOptions, int firstColumnWidth) { if (visibleOptions.Any()) { output.WriteLine(); output.WriteLine("Options:"); var outputFormat = $" {{0, -{firstColumnWidth}}}{{1}}"; var visibleCategorizedOptions = application.Options.OfType <StrykerInputOption>().Intersect(visibleOptions); foreach (var group in visibleCategorizedOptions.Cast <StrykerInputOption>().GroupBy(c => c.Category).OrderBy(g => g.Key)) { if (group.Key != InputCategory.Generic) { output.WriteLine(); output.WriteLine($"{group.Key} options:"); } foreach (var opt in group) { var description = opt.Description; var wrappedDescription = IndentWriter?.Write(description); var message = string.Format(outputFormat, Format(opt), wrappedDescription); output.Write(message); output.WriteLine(); output.WriteLine(); } } } }
protected internal override void Print(IndentWriter writer) { writer.WriteLine("LookupInstructionQueryPlanNode" + " rootStream=" + _rootStream + " requiredPerStream=" + _requiredPerStream.Render()); writer.IncrIndent(); for (int i = 0; i < _lookupInstructions.Count; i++) { writer.WriteLine("lookup step " + i); writer.IncrIndent(); _lookupInstructions[i].Print(writer); writer.DecrIndent(); } writer.DecrIndent(); writer.IncrIndent(); for (int i = 0; i < _assemblyInstructionFactories.Count; i++) { writer.WriteLine("assembly step " + i); writer.IncrIndent(); _assemblyInstructionFactories[i].Print(writer); writer.DecrIndent(); } writer.DecrIndent(); }
public void Dump(IndentWriter writer, Dfa dfa) { foreach (var state in dfa.States) { Dump(writer, state); } }
public override void Print(IndentWriter writer) { writer.WriteLine("LookupInstructionExecNode" + " rootStream=" + _rootStream + " name=" + _rootStreamName + " requiredPerStream=" + _requiredPerStream.Render()); writer.IncrIndent(); for (int i = 0; i < _lookupInstructions.Length; i++) { writer.WriteLine("lookup inst node " + i); writer.IncrIndent(); _lookupInstructions[i].Print(writer); writer.DecrIndent(); } writer.DecrIndent(); writer.IncrIndent(); for (int i = 0; i < _assemblyInstructions.Length; i++) { writer.WriteLine("assembly inst node " + i); writer.IncrIndent(); _assemblyInstructions[i].Print(writer); writer.DecrIndent(); } writer.DecrIndent(); }
/// <summary>Print in readable format the execution plan spec. </summary> /// <param name="planNodeSpecs">plans to print</param> /// <returns>readable text with plans</returns> public static String Print(QueryPlanNode[] planNodeSpecs) { var buffer = new StringBuilder(); buffer.Append("QueryPlanNode[]\n"); for (int i = 0; i < planNodeSpecs.Length; i++) { buffer.Append(" node spec " + i + " :\n"); var writer = new StringWriter(); var indentWriter = new IndentWriter(writer, 4, 2); if (planNodeSpecs[i] != null) { planNodeSpecs[i].Print(indentWriter); } else { indentWriter.WriteLine("no plan (historical)"); } buffer.Append(writer.ToString()); } return(buffer.ToString()); }
public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template) //throws JadeCompilerException { String name = getValue(); if (name == null) { name = "5"; } String doctypeLine = Doctypes.get(name); if (doctypeLine == null) { doctypeLine = "<!DOCTYPE " + name + ">"; } if (doctypeLine.StartsWith("<?xml")) { template.setMode(Jade4Net.Mode.XML); } else if (doctypeLine.Equals("<!DOCTYPE html>")) { template.setMode(Jade4Net.Mode.HTML); } else { template.setMode(Jade4Net.Mode.XHTML); } writer.append(doctypeLine); }
private void Virtuals(IReadOnlyList <string> inlines, IndentWriter outlines) { var start = 0; for (; start < inlines.Count; ++start) { if (inlines[start] == "\t\tpublic class Visitor") { break; } } start = start + 2; for (; start < inlines.Count; ++start) { var line = inlines[start]; if (line == "\t\t}") { break; } Virtual(line, outlines); } }
public override void StreamDebug(TextWriter target) { var writer = new IndentWriter(target); writer.WriteLine(ToString()); writer.IncIndent(); writer.WriteLine($"Name: {DisplayName}"); writer.WriteLine($"Type: {Type}"); writer.WriteLine($"Weight: {Weight}"); writer.WriteLine($"Value: {Value}"); writer.WriteLine($"Enchant Capacity: {EnchantCapacity}"); writer.WriteLine($"Model: {Model}"); writer.WriteLine($"Icon: {Icon}"); writer.WriteLine($"Script: {Script}"); writer.WriteLine($"Enchantment: {Enchantment}"); if (BipedParts.Count > 0) { writer.WriteLine("Biped Data"); writer.IncIndent(); var table = new Table("Type", "Male", "Female"); foreach (var part in BipedParts) { table.AddRow(part.Type, part.MaleBodyPart, part.FemaleBodyPart); } table.Print(writer); writer.DecIndent(); } writer.DecIndent(); }
public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template) //throws JadeCompilerException { try { Object result = ExpressionHandler.evaluateStringExpression(getValue(), model); if (result == null || !buffer) { return; } String str = result.ToString(); if (escape) { str = Utils.escapeHTML(str); } writer.append(str); if (hasBlock()) { writer.increment(); block.execute(writer, model, template); writer.decrement(); writer.newline(); } } catch (ExpressionException e) { throw new JadeCompilerException(this, template.getTemplateLoader(), e); } }
private static void Dump(FileRef file, Action <IWriter> dump) { var writer = new IndentWriter(); dump(writer); writer.Persist(file); }
public void Dump(INonterminalToken token) { var iwriter = new IndentWriter(" "); Dump(iwriter, token); iwriter.Persist(File); }
protected internal override void Print(IndentWriter writer) { writer.WriteLine( "TableOuterLookupNode " + " tableLookupPlan=" + LookupStrategySpec); }
public void Print(IndentWriter writer) { writer.WriteLine( "TableLookupNode " + " tableLookupPlan=" + TableLookupPlan); }
public override void Dump(IndentWriter output) { output.Write("("); From.Dump(output); output.Write(" .. "); To.Dump(output); output.Write(")"); }
public override void execute(IndentWriter writer, JadeModel model, JadeTemplate template) //throws JadeCompilerException { foreach (Node node in getNodes()) { node.execute(writer, model, template); } }
public override void Dump(IndentWriter output) { output.Write("("); Expression1.Dump(output); output.Write(" - "); Expression2.Dump(output); output.Write(")"); }
public Visitor(IndentWriter writer, Config cfg, Grammar grammar) : base(grammar) { Writer = writer; CS = new CSharper(Writer, true); GL = new CSharper(new IndentWriter(), false); Cfg = cfg; }
/// <summary> /// Print in readable format the execution strategy. /// </summary> /// <param name="execNode">execution node to print</param> /// <returns>readable text with execution nodes constructed for actual streams</returns> public static string Print(ExecNode execNode) { StringWriter writer = new StringWriter(); IndentWriter indentWriter = new IndentWriter(writer, 4, 2); execNode.Print(indentWriter); return writer.ToString(); }
internal CSharpCodeVisitor( TextWriter writer, CodeEmiterConfig config, CSharpDefine define) { _writer = new IndentWriter(writer, 0); _config = config; _define = define; }
/// <summary>Print in readable format the execution strategy. </summary> /// <param name="execNode">execution node to print</param> /// <returns>readable text with execution nodes constructed for actual streams</returns> public static String Print(ExecNode execNode) { var stringWriter = new StringWriter(); var indentWriter = new IndentWriter(stringWriter, 4, 2); execNode.Print(indentWriter); return(stringWriter.ToString()); }
public override void StreamDebug(TextWriter target) { var writer = new IndentWriter(target); writer.WriteLine(ToString()); writer.IncIndent(); StreamSpecific(writer); writer.WriteLine($"Sleeping Illegal: {SleepingIllegal}"); if (ObjectReferences.Count > 0) { writer.WriteLine("Object References"); writer.IncIndent(); var table = new Table("Index", "Object Name", "Position", "Scale", "Blocked", "Exit Position", "Exit Cell", "Lock Level", "Key", "Trap", "Owner", "Owner Global/Rank", "Stack Count", "Soul", "Charge", "Health As Int", "Health As Float"); foreach (var reference in ObjectReferences) { var exitPosition = reference.ExitPosition; string exitCell; if (exitPosition != null) { exitCell = reference.ExitCell ?? $"({exitPosition.GridX}, {exitPosition.GridY})"; } else { exitCell = null; } var owner = reference.Owner; object ownerExtra = null; if (owner != null) { ownerExtra = reference.OwnerGlobal; } else { owner = reference.OwningFaction; if (owner != null) { ownerExtra = reference.RequiredRank; } } table.AddRow(reference.Index, reference.ObjectName, reference.Position, reference.Scale, reference.Blocked, exitPosition, exitCell, reference.LockLevel, reference.Key, reference.Trap, owner, ownerExtra, reference.ObjectCount, reference.Soul, reference.Charge, reference.IntHealth, reference.FloatHealth); } table.Print(writer); writer.DecIndent(); } writer.DecIndent(); }