Skip to content

Commit

Permalink
Formatted Language (ChilliCream#4565)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Dec 15, 2021
1 parent 20ed41f commit 2274110
Show file tree
Hide file tree
Showing 239 changed files with 24,664 additions and 24,898 deletions.
11 changes: 11 additions & 0 deletions src/HotChocolate/Language/format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

BASEDIR=$(dirname "$0")
src=$BASEDIR/src
test=$BASEDIR/test

dotnet format $src/Language
dotnet format $src/Language.SyntaxTree
dotnet format $src/Language.Utf8
dotnet format $src/Language.Visitors
dotnet format $test/Language.Tests
221 changes: 110 additions & 111 deletions src/HotChocolate/Language/src/Language.SyntaxTree/ArgumentNode.cs
Original file line number Diff line number Diff line change
@@ -1,118 +1,117 @@
using System;
using System;
using System.Collections.Generic;
using HotChocolate.Language.Utilities;

namespace HotChocolate.Language
namespace HotChocolate.Language;

/// <summary>
/// This syntax node represents a argument value of a <see cref="FieldNode"/>.
/// </summary>
public sealed class ArgumentNode : ISyntaxNode
{
/// <summary>
/// This syntax node represents a argument value of a <see cref="FieldNode"/>.
/// </summary>
public sealed class ArgumentNode : ISyntaxNode
public ArgumentNode(string name, string value)
: this(null, new NameNode(name), new StringValueNode(value))
{
}

public ArgumentNode(string name, int value)
: this(null, new NameNode(name), new IntValueNode(value))
{
public ArgumentNode(string name, string value)
: this(null, new NameNode(name), new StringValueNode(value))
{
}

public ArgumentNode(string name, int value)
: this(null, new NameNode(name), new IntValueNode(value))
{
}

public ArgumentNode(string name, IValueNode value)
: this(null, new NameNode(name), value)
{
}

public ArgumentNode(NameNode name, IValueNode value)
: this(null, name, value)
{
}

public ArgumentNode(Location? location, NameNode name, IValueNode value)
{
Location = location;
Name = name ?? throw new ArgumentNullException(nameof(name));
Value = value ?? throw new ArgumentNullException(nameof(value));
}

/// <inheritdoc />
public SyntaxKind Kind { get; } = SyntaxKind.Argument;

/// <inheritdoc />
public Location? Location { get; }

/// <inheritdoc />
public NameNode Name { get; }

/// <inheritdoc />
public IValueNode Value { get; }

/// <inheritdoc />
public IEnumerable<ISyntaxNode> GetNodes()
{
yield return Name;
yield return Value;
}

/// <summary>
/// Returns the GraphQL syntax representation of this <see cref="ISyntaxNode"/>.
/// </summary>
/// <returns>
/// Returns the GraphQL syntax representation of this <see cref="ISyntaxNode"/>.
/// </returns>
public override string ToString() => SyntaxPrinter.Print(this, true);

/// <summary>
/// Returns the GraphQL syntax representation of this <see cref="ISyntaxNode"/>.
/// </summary>
/// <param name="indented">
/// A value that indicates whether the GraphQL output should be formatted,
/// which includes indenting nested GraphQL tokens, adding
/// new lines, and adding white space between property names and values.
/// </param>
/// <returns>
/// Returns the GraphQL syntax representation of this <see cref="ISyntaxNode"/>.
/// </returns>
public string ToString(bool indented) => SyntaxPrinter.Print(this, indented);

/// <summary>
/// Creates a new node from the current instance and replaces the
/// <see cref="Location" /> with <paramref name="location" />.
/// </summary>
/// <param name="location">
/// The location that shall be used to replace the current location.
/// </param>
/// <returns>
/// Returns the new node with the new <paramref name="location" />.
/// </returns>
public ArgumentNode WithLocation(Location? location)
=> new ArgumentNode(location, Name, Value);

/// <summary>
/// Creates a new node from the current instance and replaces the
/// <see cref="Name" /> with <paramref name="name" />.
/// </summary>
/// <param name="name">
/// The name that shall be used to replace the current name.
/// </param>
/// <returns>
/// Returns the new node with the new <paramref name="name" />.
/// </returns>
public ArgumentNode WithName(NameNode name)
=> new ArgumentNode(Location, name, Value);

/// <summary>
/// Creates a new node from the current instance and replaces the
/// <see cref="Value" /> with <paramref name="value" />.
/// </summary>
/// <param name="value">
/// The value that shall be used to replace the current value.
/// </param>
/// <returns>
/// Returns the new node with the new <paramref name="value" />.
/// </returns>
public ArgumentNode WithValue(IValueNode value)
=> new ArgumentNode(Location, Name, value);
}

public ArgumentNode(string name, IValueNode value)
: this(null, new NameNode(name), value)
{
}

public ArgumentNode(NameNode name, IValueNode value)
: this(null, name, value)
{
}

public ArgumentNode(Location? location, NameNode name, IValueNode value)
{
Location = location;
Name = name ?? throw new ArgumentNullException(nameof(name));
Value = value ?? throw new ArgumentNullException(nameof(value));
}

/// <inheritdoc />
public SyntaxKind Kind { get; } = SyntaxKind.Argument;

/// <inheritdoc />
public Location? Location { get; }

/// <inheritdoc />
public NameNode Name { get; }

/// <inheritdoc />
public IValueNode Value { get; }

/// <inheritdoc />
public IEnumerable<ISyntaxNode> GetNodes()
{
yield return Name;
yield return Value;
}

/// <summary>
/// Returns the GraphQL syntax representation of this <see cref="ISyntaxNode"/>.
/// </summary>
/// <returns>
/// Returns the GraphQL syntax representation of this <see cref="ISyntaxNode"/>.
/// </returns>
public override string ToString() => SyntaxPrinter.Print(this, true);

/// <summary>
/// Returns the GraphQL syntax representation of this <see cref="ISyntaxNode"/>.
/// </summary>
/// <param name="indented">
/// A value that indicates whether the GraphQL output should be formatted,
/// which includes indenting nested GraphQL tokens, adding
/// new lines, and adding white space between property names and values.
/// </param>
/// <returns>
/// Returns the GraphQL syntax representation of this <see cref="ISyntaxNode"/>.
/// </returns>
public string ToString(bool indented) => SyntaxPrinter.Print(this, indented);

/// <summary>
/// Creates a new node from the current instance and replaces the
/// <see cref="Location" /> with <paramref name="location" />.
/// </summary>
/// <param name="location">
/// The location that shall be used to replace the current location.
/// </param>
/// <returns>
/// Returns the new node with the new <paramref name="location" />.
/// </returns>
public ArgumentNode WithLocation(Location? location)
=> new ArgumentNode(location, Name, Value);

/// <summary>
/// Creates a new node from the current instance and replaces the
/// <see cref="Name" /> with <paramref name="name" />.
/// </summary>
/// <param name="name">
/// The name that shall be used to replace the current name.
/// </param>
/// <returns>
/// Returns the new node with the new <paramref name="name" />.
/// </returns>
public ArgumentNode WithName(NameNode name)
=> new ArgumentNode(Location, name, Value);

/// <summary>
/// Creates a new node from the current instance and replaces the
/// <see cref="Value" /> with <paramref name="value" />.
/// </summary>
/// <param name="value">
/// The value that shall be used to replace the current value.
/// </param>
/// <returns>
/// Returns the new node with the new <paramref name="value" />.
/// </returns>
public ArgumentNode WithValue(IValueNode value)
=> new ArgumentNode(Location, Name, value);
}
Loading

0 comments on commit 2274110

Please sign in to comment.