protected virtual FragmentDefinitionNode RewriteFragmentDefinition( FragmentDefinitionNode node, TContext context) { FragmentDefinitionNode current = node; current = Rewrite(current, current.Name, context, RewriteName, current.WithName); current = Rewrite(current, current.TypeCondition, context, RewriteNamedType, current.WithTypeCondition); current = Rewrite(current, current.VariableDefinitions, context, (p, c) => RewriteMany(p, c, RewriteVariableDefinition), current.WithVariableDefinitions); current = Rewrite(current, current.Directives, context, (p, c) => RewriteMany(p, c, RewriteDirective), current.WithDirectives); if (current.SelectionSet != null) { current = Rewrite(current, current.SelectionSet, context, RewriteSelectionSet, current.WithSelectionSet); } return(current); }
protected virtual void ResolveChildren( FragmentDefinitionNode node, IList <SyntaxNodeInfo> children) { ResolveChildren( nameof(node.Name), node.Name, children); if (node.VariableDefinitions.Count != 0) { ResolveChildren( nameof(node.VariableDefinitions), node.VariableDefinitions, children); } ResolveChildren( nameof(node.TypeCondition), node.TypeCondition, children); if (node.Directives.Count != 0) { ResolveChildren( nameof(node.Directives), node.Directives, children); } ResolveChildren( nameof(node.SelectionSet), node.SelectionSet, children); }
protected override void VisitFragmentDefinition( FragmentDefinitionNode node) { _writer.Write(Keywords.Fragment); _writer.WriteSpace(); VisitName(node.Name); _writer.WriteSpace(); if (node.VariableDefinitions.Any()) { _writer.Write('('); WriteMany(node.VariableDefinitions, VisitVariableDefinition); _writer.Write(')'); _writer.WriteSpace(); } _writer.Write(Keywords.On); _writer.WriteSpace(); VisitNamedType(node.TypeCondition); WriteMany(node.Directives, VisitDirective); if (node.SelectionSet != null) { _writer.WriteSpace(); VisitSelectionSet(node.SelectionSet); } }
protected override void VisitFragmentDefinition( FragmentDefinitionNode node, object context) { VisitedFragmentDefinition = true; base.VisitFragmentDefinition(node, context); }
public virtual VisitorAction Leave( FragmentDefinitionNode node, ISyntaxNode parent, IReadOnlyList <object> path, IReadOnlyList <ISyntaxNode> ancestors) { return(GetDefaultAction(node.Kind)); }
protected override void VisitFragmentDefinition( FragmentDefinitionNode node) { VisitName(node.Name); VisitMany(node.VariableDefinitions, VisitVariableDefinition); VisitNamedType(node.TypeCondition); VisitMany(node.Directives, VisitDirective); VisitSelectionSet(node.SelectionSet); }
public void CreateDocument() { // arrange var fragment = new FragmentDefinitionNode( null, new NameNode("foo"), Array.Empty <VariableDefinitionNode>(), new NamedTypeNode("foo"), Array.Empty <DirectiveNode>(), new SelectionSetNode(Array.Empty <ISelectionNode>())); // act var document = new DocumentNode(new IDefinitionNode[] { fragment }); // assert Assert.Equal(SyntaxKind.Document, document.Kind); Assert.Null(document.Location); Assert.Collection(document.Definitions, d => Assert.Equal(fragment, d)); }
public void Document_With_Definitions_Null() { // arrange var fragment = new FragmentDefinitionNode( null, new NameNode("foo"), Array.Empty <VariableDefinitionNode>(), new NamedTypeNode("foo"), Array.Empty <DirectiveNode>(), new SelectionSetNode(Array.Empty <ISelectionNode>())); var document = new DocumentNode(new IDefinitionNode[] { }); // act void Action() => document.WithDefinitions(null); // assert Assert.Throws <ArgumentNullException>(Action); }
public void Document_With_Definitions() { // arrange var location = new Location(0, 0, 0, 0); var fragment = new FragmentDefinitionNode( null, new NameNode("foo"), Array.Empty <VariableDefinitionNode>(), new NamedTypeNode("foo"), Array.Empty <DirectiveNode>(), new SelectionSetNode(Array.Empty <ISelectionNode>())); var document = new DocumentNode(location, new IDefinitionNode[] { }); // act document = document.WithDefinitions(new IDefinitionNode[] { fragment }); // assert Assert.Collection(document.Definitions, d => Assert.Equal(fragment, d)); }
public void Document_With_Location_Null() { // arrange var location = new Location(0, 0, 0, 0); var fragment = new FragmentDefinitionNode( null, new NameNode("foo"), Array.Empty <VariableDefinitionNode>(), new NamedTypeNode("foo"), Array.Empty <DirectiveNode>(), new SelectionSetNode(Array.Empty <ISelectionNode>())); var document = new DocumentNode(location, new IDefinitionNode[] { fragment }); // act document = document.WithLocation(null); // assert Assert.Null(document.Location); }
protected override void VisitFragmentDefinition( FragmentDefinitionNode node, DocumentWriter writer) { writer.Write(Keywords.Fragment); writer.WriteSpace(); writer.WriteName(node.Name); writer.WriteSpace(); if (node.VariableDefinitions.Any()) { writer.Write('('); writer.WriteMany( node.VariableDefinitions, VisitVariableDefinition); writer.Write(')'); writer.WriteSpace(); } writer.Write(Keywords.On); writer.WriteSpace(); writer.WriteNamedType(node.TypeCondition); writer.WriteMany(node.Directives, (n, w) => w.WriteDirective(n)); if (node.SelectionSet != null) { writer.WriteSpace(); VisitSelectionSet(node.SelectionSet, writer); } }
protected override void VisitFragmentDefinition( FragmentDefinitionNode node) { VisitedFragmentDefinition = true; base.VisitFragmentDefinition(node); }
protected virtual void VisitFragmentDefinition( FragmentDefinitionNode node) { }
protected virtual void VisitFragmentDefinition( FragmentDefinitionNode node, TContext context) { }