private void VisitInterfaceTypeDefinitionBase( InterfaceTypeDefinitionNodeBase node, ISyntaxWriter writer) { writer.Write(Keywords.Interface); writer.WriteSpace(); writer.WriteName(node.Name); if (node.Interfaces.Count > 0) { writer.WriteSpace(); writer.Write(Keywords.Implements); writer.WriteSpace(); writer.WriteMany(node.Interfaces, (n, w) => writer.WriteNamedType(n), " & "); } WriteDirectives(node.Directives, writer); WriteLeftBrace(writer); writer.Indent(); writer.WriteMany( node.Fields, VisitFieldDefinition, WriteLineOrSpace); writer.Unindent(); WriteRightBrace(writer); }
private void VisitFieldDefinition( FieldDefinitionNode node, ISyntaxWriter writer) { writer.WriteIndent(_indented); WriteDescription(node.Description, writer); writer.WriteName(node.Name); if (node.Arguments.Count > 0) { writer.Write("("); writer.WriteMany( node.Arguments, VisitArgumentValueDefinition, w => w.WriteSpace()); writer.Write(")"); } writer.Write(":"); writer.WriteSpace(); writer.WriteType(node.Type); WriteDirectives(node.Directives, writer); }
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 void WriteDeclaration(IDefinition definition) { if (definition == null) { return; } IAssembly assembly = definition as IAssembly; if (assembly != null) { WriteAssemblyDeclaration(assembly); return; } INamespaceDefinition ns = definition as INamespaceDefinition; if (ns != null) { WriteNamespaceDeclaration(ns); return; } ITypeDefinition type = definition as ITypeDefinition; if (type != null) { WriteTypeDeclaration(type); return; } ITypeDefinitionMember member = definition as ITypeDefinitionMember; if (member != null) { WriteMemberDeclaration(member); return; } DummyInternalConstructor ctor = definition as DummyInternalConstructor; if (ctor != null) { WritePrivateConstructor(ctor.ContainingType); return; } INamedEntity named = definition as INamedEntity; if (named != null) { WriteIdentifier(named.Name); return; } _writer.Write("Unknown definition type {0}", definition.ToString()); }
private void VisitOperationTypeDefinition( OperationTypeDefinitionNode node, ISyntaxWriter writer) { writer.WriteIndent(_indented); writer.Write(node.Operation.ToString().ToLowerInvariant()); writer.Write(": "); writer.WriteNamedType(node.Type); }
private void VisitInterfaceTypeExtension( InterfaceTypeExtensionNode node, ISyntaxWriter writer) { writer.Write(Keywords.Extend); writer.WriteSpace(); VisitInterfaceTypeDefinitionBase(node, writer); }
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(); }
private void VisitUnionTypeDefinitionBase( UnionTypeDefinitionNodeBase node, ISyntaxWriter writer) { writer.Write(Keywords.Union); writer.WriteSpace(); writer.WriteName(node.Name); WriteDirectives(node.Directives, writer); writer.WriteSpace(); writer.Write('='); writer.WriteSpace(); writer.WriteMany(node.Types, (n, w) => writer.WriteNamedType(n), " | "); }
public override void Visit(IAssembly assembly) { _syntaxWriter.Write("assembly " + assembly.Name.Value); using (_syntaxWriter.StartBraceBlock()) { base.Visit(assembly); } }
private void VisitScalarTypeDefinitionBase( ScalarTypeDefinitionNodeBase node, ISyntaxWriter writer) { writer.Write(Keywords.Scalar); writer.WriteSpace(); writer.WriteName(node.Name); WriteDirectives(node.Directives, writer); }
private void WriteMemberGroupHeader(ITypeDefinitionMember member) { if (IncludeMemberGroupHeadings || IncludeSpaceBetweenMemberGroups) { string header = CSharpWriter.MemberGroupHeading(member); if (header != null) { if (IncludeSpaceBetweenMemberGroups) { if (!_firstMemberGroup) { _syntaxWriter.WriteLine(true); } _firstMemberGroup = false; } if (IncludeMemberGroupHeadings) { IDisposable dispose = null; if (_styleWriter != null) { dispose = _styleWriter.StartStyle(SyntaxStyle.Comment); } _syntaxWriter.Write("// {0}", header); if (dispose != null) { dispose.Dispose(); } _syntaxWriter.WriteLine(); } } } }
private void VisitSchemaDefinitionBase(SchemaDefinitionNodeBase node, ISyntaxWriter writer) { writer.Write(Keywords.Schema); WriteDirectives(node.Directives, writer); WriteLeftBrace(writer); writer.Indent(); writer.WriteMany( node.OperationTypes, VisitOperationTypeDefinition, WriteLineOrSpace); writer.Unindent(); WriteRightBrace(writer); }
public static void WriteMany <T>( this ISyntaxWriter writer, IReadOnlyList <T> items, Action <T, ISyntaxWriter> action, string separator) { if (items.Count > 0) { action(items[0], writer); for (int i = 1; i < items.Count; i++) { writer.Write(separator); action(items[i], writer); } } }
public static void WriteSyntaxToken(this ISyntaxWriter writer, SyntaxToken token) { switch (token.Type) { default: case SyntaxTokenType.Literal: writer.Write(token.Token); break; case SyntaxTokenType.Symbol: writer.WriteSymbol(token.Token); break; case SyntaxTokenType.Identifier: writer.WriteIdentifier(token.Token); break; case SyntaxTokenType.Keyword: writer.WriteKeyword(token.Token); break; case SyntaxTokenType.TypeName: writer.WriteTypeName(token.Token); break; } }
private void VisitEnumTypeDefinitionBase( EnumTypeDefinitionNodeBase node, ISyntaxWriter writer) { writer.Write(Keywords.Enum); writer.WriteSpace(); writer.WriteName(node.Name); WriteDirectives(node.Directives, writer); WriteLeftBrace(writer); writer.Indent(); writer.WriteMany( node.Values, VisitEnumValueDefinition, WriteLineOrSpace); writer.Unindent(); WriteRightBrace(writer); }
private void VisitInputObjectTypeDefinitionBase( InputObjectTypeDefinitionNodeBase node, ISyntaxWriter writer) { writer.Write(Keywords.Input); writer.WriteSpace(); writer.WriteName(node.Name); WriteDirectives(node.Directives, writer); WriteLeftBrace(writer); writer.Indent(); writer.WriteMany( node.Fields, VisitInputValueDefinition, WriteLineOrSpace); writer.Unindent(); WriteRightBrace(writer); }
private void VisitDirectiveDefinition( DirectiveDefinitionNode node, ISyntaxWriter writer) { WriteDescription(node.Description, writer); writer.Write(Keywords.Directive); writer.WriteSpace(); writer.Write('@'); writer.WriteName(node.Name); if (node.Arguments.Count > 0) { writer.Write("("); writer.WriteMany( node.Arguments, VisitArgumentValueDefinition, w => w.WriteSpace()); writer.Write(")"); } writer.WriteSpace(); if (node.IsRepeatable) { writer.Write(Keywords.Repeatable); writer.WriteSpace(); } writer.Write(Keywords.On); writer.WriteSpace(); writer.WriteMany(node.Locations, (n, w) => writer.WriteName(n), " | "); }
public static void Write(this ISyntaxWriter writer, string str, params object[] args) { writer.Write(string.Format(str, args)); }
public static void WriteName(this ISyntaxWriter writer, NameNode nameNode) { writer.Write(nameNode.Value); }
public static void WriteSpace(this ISyntaxWriter writer) { writer.Write(" "); }
public static void WriteFloatValue(this ISyntaxWriter writer, FloatValueNode node) { writer.Write(node.Value); }
private void VisitSchemaExtension(SchemaExtensionNode node, ISyntaxWriter writer) { writer.Write(Keywords.Extend); writer.WriteSpace(); VisitSchemaDefinitionBase(node, writer); }