Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/GraphQLParser/AST/GraphQLListType.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace GraphQLParser.AST
namespace GraphQLParser.AST
{
public class GraphQLListType : GraphQLType
{
public override ASTNodeKind Kind => ASTNodeKind.ListType;

public GraphQLType? Type { get; set; }

/// <inheritdoc/>
public override string ToString() => $"[{Type}]";
}
}
}
1 change: 1 addition & 0 deletions src/GraphQLParser/AST/GraphQLListValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public GraphQLListValue(ASTNodeKind kind)

public List<GraphQLValue>? Values { get; set; }

/// <inheritdoc/>
public override string ToString() => AstValue!;
}
}
32 changes: 24 additions & 8 deletions src/GraphQLParser/AST/GraphQLLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

namespace GraphQLParser.AST
{
/// <summary>
/// Provides information regarding the location of a node within a document's original query text.
/// </summary>
[DebuggerDisplay("(Start={Start}, End={End})")]
public readonly struct GraphQLLocation : IEquatable<GraphQLLocation>
{
/// <summary>
/// Initializes a new instance with the specified parameters.
/// </summary>
public GraphQLLocation(int start, int end)
{
Start = start;
Expand All @@ -14,28 +20,38 @@ public GraphQLLocation(int start, int end)

/// <summary>
/// The index for the start of the node in the source (i.e. it's inclusive).
///
/// For example,
/// { field { subfield } }
/// ^ field.Location.Start = 2
/// <br/>
/// For example:
/// <code>
/// { field { subfield } }
/// <br/>
/// --^ field.Location.Start = 2
/// </code>
/// </summary>
public int Start { get; }

/// <summary>
/// The index for the character immediately after the node in the source (i.e. it's exclusive).
///
/// For example,
/// { field { subfield } }
/// ^ field.Location.End = 20
/// <br/>
/// For example:
/// <code>
/// { field { subfield } }
/// <br/>
/// --------------------^ field.Location.End = 20
/// </code>
/// </summary>
public int End { get; }

/// <inheritdoc/>
public bool Equals(GraphQLLocation other) => Start == other.Start && End == other.End;

/// <inheritdoc/>
public override bool Equals(object obj) => obj is GraphQLLocation l && Equals(l);

/// <inheritdoc/>
public override int GetHashCode() => (Start, End).GetHashCode();

/// <inheritdoc/>
public override string ToString() => $"({Start},{End})";
}
}
5 changes: 3 additions & 2 deletions src/GraphQLParser/AST/GraphQLNamedType.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace GraphQLParser.AST
namespace GraphQLParser.AST
{
public class GraphQLNamedType : GraphQLType, INamedNode
{
public override ASTNodeKind Kind => ASTNodeKind.NamedType;

public GraphQLName? Name { get; set; }

/// <inheritdoc/>
public override string ToString() => Name?.Value!;
}
}
}
5 changes: 3 additions & 2 deletions src/GraphQLParser/AST/GraphQLNonNullType.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
namespace GraphQLParser.AST
namespace GraphQLParser.AST
{
public class GraphQLNonNullType : GraphQLType
{
public override ASTNodeKind Kind => ASTNodeKind.NonNullType;

public GraphQLType? Type { get; set; }

/// <inheritdoc/>
public override string ToString() => Type + "!";
}
}
}
5 changes: 3 additions & 2 deletions src/GraphQLParser/Token.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace GraphQLParser
namespace GraphQLParser
{
public readonly struct Token
{
Expand Down Expand Up @@ -42,11 +42,12 @@ public Token(TokenKind kind, string? value, int start, int end)
_ => string.Empty
};

/// <inheritdoc/>
public override string ToString()
{
return Value != null
? $"{GetTokenKindDescription(Kind)} \"{Value}\""
: GetTokenKindDescription(Kind);
}
}
}
}