public static void WriteStringValue(this ISyntaxWriter writer, StringValueNode node) { if (node.Block) { writer.Write("\"\"\""); var lines = node.Value .Replace("\"\"\"", "\\\"\"\"") .Replace("\r", string.Empty) .Split('\n'); foreach (var line in lines) { writer.WriteLine(); writer.WriteIndent(); writer.Write(line); } writer.WriteLine(); writer.WriteIndent(); writer.Write("\"\"\""); } else { writer.Write('"'); WriteEscapeCharacters(writer, node.Value); writer.Write('"'); } }
public override void Visit(INamespaceDefinition ns) { if (ns != null && string.IsNullOrEmpty(ns.Name.Value)) { base.Visit(ns); } else { _declarationWriter.WriteDeclaration(ns); using (_syntaxWriter.StartBraceBlock(PutBraceOnNewLine)) { var types = ns.GetTypes(this.IncludeForwardedTypes); if (ConditionalTypeLists != null) { // in the first pass we want all types *except* the ones in ConditionalTypeLists filters // in the second pass we want *only* the types in ConditionalTypeLists filters var firstPass = _currentTypeListFilter == null; types = types.Where(t => ConditionalTypeLists.Any(c => c.Filter.Include(t) == !firstPass)); } Visit(types); } } _syntaxWriter.WriteLine(); }
public static void WriteLine(this ISyntaxWriter writer, bool force) { if (force) // Need to make sure the stream isn't empty so that it doesn't ignore the WriteLine { writer.Write(" "); } writer.WriteLine(); }
public static IDisposable StartBraceBlock(this ISyntaxWriter writer, bool onNewLine) { if (onNewLine) { writer.WriteLine(); } else { writer.WriteSpace(); } writer.WriteSymbol("{"); writer.WriteLine(); writer.IndentLevel++; return(new Block(() => { writer.IndentLevel--; writer.WriteSymbol("}"); writer.WriteLine(); })); }
private void VisitDocument(DocumentNode node, ISyntaxWriter writer) { if (node.Definitions.Count > 0) { VisitDefinition(node.Definitions[0], writer); for (int i = 1; i < node.Definitions.Count; i++) { if (_indented) { writer.WriteLine(); writer.WriteLine(); } else { writer.WriteSpace(); } VisitDefinition(node.Definitions[i], writer); } } }
public override void Visit(INamespaceDefinition ns) { _declarationWriter.WriteDeclaration(ns); using (_syntaxWriter.StartBraceBlock(PutBraceOnNewLine)) { base.Visit(ns); } _syntaxWriter.WriteLine(); }
public override void Visit(INamespaceDefinition ns) { if (ns != null && string.IsNullOrEmpty(ns.Name.Value)) { base.Visit(ns); } else { _declarationWriter.WriteDeclaration(ns); using (_syntaxWriter.StartBraceBlock(PutBraceOnNewLine)) { base.Visit(ns); } } _syntaxWriter.WriteLine(); }
public override void Visit(ITypeDefinition type) { _declarationWriter.WriteDeclaration(type); _syntaxWriter.WriteLine(); }