From 077f9acbce245a2a641df867f84863d67e1fafdb Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Sat, 1 Jun 2019 09:22:49 +0200 Subject: [PATCH 01/12] Tweaked how we read blockstrings --- src/Core/Language/Utf8/Utf8GraphQLReader.cs | 206 +++++++++++--------- 1 file changed, 112 insertions(+), 94 deletions(-) diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index 53ef64d4962..629684489eb 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -13,23 +13,27 @@ public ref partial struct Utf8GraphQLReader { private static readonly byte _space = (byte)' '; private int _nextNewLines; + private ReadOnlySpan _graphQLData; private ReadOnlySpan _value; + private int _length; + private int _position; public Utf8GraphQLReader(ReadOnlySpan graphQLData) { - GraphQLData = graphQLData; Kind = TokenKind.StartOfFile; Start = 0; End = 0; LineStart = 0; - Position = 0; Line = 1; Column = 1; - _value = null; + _graphQLData = graphQLData; + _length = graphQLData.Length; _nextNewLines = 0; + _position = 0; + _value = null; } - public ReadOnlySpan GraphQLData { get; } + public ReadOnlySpan GraphQLData => _graphQLData; /// /// Gets the kind of . @@ -49,7 +53,7 @@ public Utf8GraphQLReader(ReadOnlySpan graphQLData) /// /// The current position of the lexer pointer. /// - public int Position { get; set; } + public int Position => _position; /// /// Gets the 1-indexed line number on which this @@ -175,7 +179,7 @@ public void UnescapeValue(ref Span unescapedValue) public bool Read() { - if (Position == 0) + if (_position == 0) { SkipBoml(); } @@ -185,14 +189,14 @@ public bool Read() if (IsEndOfStream()) { - Start = Position; - End = Position; + Start = _position; + End = _position; Kind = TokenKind.EndOfFile; _value = null; return false; } - ref readonly byte code = ref GraphQLData[Position]; + ref readonly byte code = ref _graphQLData[_position]; if (GraphQLConstants.IsLetterOrUnderscore(in code)) { @@ -220,11 +224,11 @@ public bool Read() if (code == GraphQLConstants.Quote) { - if (GraphQLData.Length > Position + 2 - && GraphQLData[Position + 1] == GraphQLConstants.Quote - && GraphQLData[Position + 2] == GraphQLConstants.Quote) + if (_graphQLData.Length > _position + 2 + && _graphQLData[_position + 1] == GraphQLConstants.Quote + && _graphQLData[_position + 2] == GraphQLConstants.Quote) { - Position += 2; + _position += 2; ReadBlockStringToken(); } else @@ -252,22 +256,22 @@ public bool Read() [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ReadNameToken() { - var start = Position; - var position = Position; + var start = _position; + var position = _position; do { position++; } - while (position < GraphQLData.Length + while (position < _graphQLData.Length && GraphQLConstants.IsLetterOrDigitOrUnderscore( - in GraphQLData[position])); + in _graphQLData[position])); Kind = TokenKind.Name; Start = start; End = position; - _value = GraphQLData.Slice(start, position - start); - Position = position; + _value = _graphQLData.Slice(start, position - start); + _position = position; } /// @@ -291,8 +295,8 @@ private void ReadNameToken() [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ReadPunctuatorToken(in byte code) { - Start = Position; - End = ++Position; + Start = _position; + End = ++_position; _value = null; switch (code) @@ -350,16 +354,16 @@ private void ReadPunctuatorToken(in byte code) break; case GraphQLConstants.Dot: - if (GraphQLData[Position] == GraphQLConstants.Dot - && GraphQLData[Position + 1] == GraphQLConstants.Dot) + if (_graphQLData[_position] == GraphQLConstants.Dot + && _graphQLData[_position + 1] == GraphQLConstants.Dot) { - Position += 2; - End = Position; + _position += 2; + End = _position; Kind = TokenKind.Spread; } else { - Position--; + _position--; throw new SyntaxException(this, string.Format(CultureInfo.InvariantCulture, LangResources.Reader_InvalidToken, @@ -368,7 +372,7 @@ private void ReadPunctuatorToken(in byte code) break; default: - Position--; + _position--; throw new SyntaxException(this, string.Format(CultureInfo.InvariantCulture, LangResources.Reader_UnexpectedPunctuatorToken, @@ -395,18 +399,18 @@ private void ReadPunctuatorToken(in byte code) private void ReadNumberToken( in byte firstCode) { - int start = Position; + int start = _position; ref readonly byte code = ref firstCode; var isFloat = false; if (code == GraphQLConstants.Minus) { - code = ref GraphQLData[++Position]; + code = ref _graphQLData[++_position]; } if (code == GraphQLConstants.Zero) { - code = ref GraphQLData[++Position]; + code = ref _graphQLData[++_position]; if (GraphQLConstants.IsDigit(in code)) { throw new SyntaxException(this, @@ -417,9 +421,9 @@ private void ReadNumberToken( else { ReadDigits(in code); - if (Position < GraphQLData.Length) + if (_position < _graphQLData.Length) { - code = ref GraphQLData[Position]; + code = ref _graphQLData[_position]; } else { @@ -430,11 +434,11 @@ private void ReadNumberToken( if (code == GraphQLConstants.Dot) { isFloat = true; - code = ref GraphQLData[++Position]; + code = ref _graphQLData[++_position]; ReadDigits(in code); - if (Position < GraphQLData.Length) + if (_position < _graphQLData.Length) { - code = ref GraphQLData[Position]; + code = ref _graphQLData[_position]; } else { @@ -445,19 +449,19 @@ private void ReadNumberToken( if ((code | (char)0x20) == GraphQLConstants.E) { isFloat = true; - code = ref GraphQLData[++Position]; + code = ref _graphQLData[++_position]; if (code == GraphQLConstants.Plus || code == GraphQLConstants.Minus) { - code = ref GraphQLData[++Position]; + code = ref _graphQLData[++_position]; } ReadDigits(in code); } Kind = isFloat ? TokenKind.Float : TokenKind.Integer; Start = start; - End = Position; - _value = GraphQLData.Slice(start, Position - start); + End = _position; + _value = _graphQLData.Slice(start, _position - start); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -470,8 +474,8 @@ private void ReadDigits(in byte firstCode) $"`{(char)firstCode}` ({firstCode})."); } - while (++Position < GraphQLData.Length - && GraphQLConstants.IsDigit(GraphQLData[Position])) + while (++_position < _graphQLData.Length + && GraphQLConstants.IsDigit(_graphQLData[_position])) { } } @@ -489,22 +493,22 @@ private void ReadDigits(in byte firstCode) [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ReadCommentToken() { - var start = Position; - var trimStart = Position + 1; + var start = _position; + var trimStart = _position + 1; bool trim = true; - while (++Position < GraphQLData.Length + while (++_position < _graphQLData.Length && !GraphQLConstants.IsControlCharacter( - in GraphQLData[Position])) + in _graphQLData[_position])) { if (trim) { - switch (GraphQLData[Position]) + switch (_graphQLData[_position]) { case GraphQLConstants.Hash: case GraphQLConstants.Space: case GraphQLConstants.Tab: - trimStart = Position; + trimStart = _position; break; default: @@ -516,8 +520,8 @@ private void ReadCommentToken() Kind = TokenKind.Comment; Start = start; - End = Position; - _value = GraphQLData.Slice(trimStart, Position - trimStart); + End = _position; + _value = _graphQLData.Slice(trimStart, _position - trimStart); } /// @@ -534,9 +538,9 @@ private void ReadCommentToken() [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ReadStringValueToken() { - var start = Position; + var start = _position; - ref readonly byte code = ref GraphQLData[++Position]; + ref readonly byte code = ref _graphQLData[++_position]; while (code != GraphQLConstants.NewLine && code != GraphQLConstants.Return) @@ -546,9 +550,9 @@ private void ReadStringValueToken() { Kind = TokenKind.String; Start = start; - End = Position; - _value = GraphQLData.Slice(start + 1, Position - start - 1); - Position++; + End = _position; + _value = _graphQLData.Slice(start + 1, _position - start - 1); + _position++; return; } @@ -561,7 +565,7 @@ private void ReadStringValueToken() if (code == GraphQLConstants.Backslash) { - code = ref GraphQLData[++Position]; + code = ref _graphQLData[++_position]; if (!GraphQLConstants.IsValidEscapeCharacter(in code)) { throw new SyntaxException(this, @@ -569,7 +573,7 @@ private void ReadStringValueToken() } } - code = ref GraphQLData[++Position]; + code = ref _graphQLData[++_position]; } throw new SyntaxException(this, "Unterminated string."); @@ -587,29 +591,23 @@ private void ReadStringValueToken() /// private void ReadBlockStringToken() { - var start = Position - 2; + var start = _position - 2; + _nextNewLines = 0; - ref readonly byte code = ref GraphQLData[++Position]; + ref readonly byte code = ref _graphQLData[++_position]; while (!IsEndOfStream()) { // Closing Triple-Quote (""") if (code == GraphQLConstants.Quote - && GraphQLData[Position + 1] == GraphQLConstants.Quote - && GraphQLData[Position + 2] == GraphQLConstants.Quote) + && _graphQLData[_position + 1] == GraphQLConstants.Quote + && _graphQLData[_position + 2] == GraphQLConstants.Quote) { Kind = TokenKind.BlockString; Start = start; - End = Position + 2; - _value = GraphQLData.Slice(start + 3, Position - start - 3); - - int newLines = StringHelper.CountLines(in _value) - 1; - if (newLines > 0) - { - _nextNewLines = newLines; - } - - Position = End + 1; + End = _position + 2; + _value = _graphQLData.Slice(start + 3, _position - start - 3); + _position = End + 1; return; } @@ -623,14 +621,34 @@ private void ReadBlockStringToken() } if (code == GraphQLConstants.Backslash - && GraphQLData[Position + 1] == GraphQLConstants.Quote - && GraphQLData[Position + 2] == GraphQLConstants.Quote - && GraphQLData[Position + 3] == GraphQLConstants.Quote) + && _graphQLData[_position + 1] == GraphQLConstants.Quote + && _graphQLData[_position + 2] == GraphQLConstants.Quote + && _graphQLData[_position + 3] == GraphQLConstants.Quote) + { + _position += 3; + } + else if (code == GraphQLConstants.NewLine) + { + int next = _position + 1; + if (next < _length + && _graphQLData[next] == GraphQLConstants.Return) + { + _position = next; + } + _nextNewLines++; + } + else if (code == GraphQLConstants.Return) { - Position += 3; + int next = _position + 1; + if (next < _length + && _graphQLData[next] == GraphQLConstants.NewLine) + { + _position = next; + } + _nextNewLines++; } - code = ref GraphQLData[++Position]; + code = ref _graphQLData[++_position]; } throw new SyntaxException(this, "Unterminated string."); @@ -650,54 +668,54 @@ private void SkipWhitespaces() _nextNewLines = 0; } - ref readonly byte code = ref GraphQLData[Position]; + ref readonly byte code = ref _graphQLData[_position]; while (GraphQLConstants.IsWhitespace(in code)) { if (code == GraphQLConstants.NewLine) { - int next = Position + 1; - if (next < GraphQLData.Length - && GraphQLData[next] == GraphQLConstants.Return) + int next = _position + 1; + if (next < _graphQLData.Length + && _graphQLData[next] == GraphQLConstants.Return) { - Position = next; + _position = next; } NewLine(); } else if (code == GraphQLConstants.Return) { - int next = Position + 1; - if (next < GraphQLData.Length - && GraphQLData[next] == GraphQLConstants.NewLine) + int next = _position + 1; + if (next < _graphQLData.Length + && _graphQLData[next] == GraphQLConstants.NewLine) { - Position = next; + _position = next; } NewLine(); } - Position++; + _position++; if (IsEndOfStream()) { return; } - code = ref GraphQLData[Position]; + code = ref _graphQLData[_position]; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void SkipBoml() { - ref readonly byte code = ref GraphQLData[Position]; + ref readonly byte code = ref _graphQLData[_position]; if (code == 239) { - ref readonly byte second = ref GraphQLData[Position + 1]; - ref readonly byte third = ref GraphQLData[Position + 2]; + ref readonly byte second = ref _graphQLData[_position + 1]; + ref readonly byte third = ref _graphQLData[_position + 2]; if (second == 187 && third == 191) { - Position += 3; + _position += 3; } } } @@ -709,7 +727,7 @@ private void SkipBoml() public void NewLine() { Line++; - LineStart = Position; + LineStart = _position; UpdateColumn(); } @@ -728,7 +746,7 @@ public void NewLine(int lines) } Line += lines; - LineStart = Position; + LineStart = _position; UpdateColumn(); } @@ -738,7 +756,7 @@ public void NewLine(int lines) [MethodImpl(MethodImplOptions.AggressiveInlining)] public void UpdateColumn() { - Column = 1 + Position - LineStart; + Column = 1 + _position - LineStart; } /// @@ -749,7 +767,7 @@ public void UpdateColumn() [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool IsEndOfStream() { - return Position >= GraphQLData.Length; + return _position >= _length; } } } From 3e817efbaf98d56f766bc506e899890fa87ad7a4 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Sat, 1 Jun 2019 09:37:06 +0200 Subject: [PATCH 02/12] Fixed line count on blockstrings --- src/Core/Language/Utf8/Utf8GraphQLReader.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index 629684489eb..e5a70f3a028 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -603,6 +603,7 @@ private void ReadBlockStringToken() && _graphQLData[_position + 1] == GraphQLConstants.Quote && _graphQLData[_position + 2] == GraphQLConstants.Quote) { + _nextNewLines--; Kind = TokenKind.BlockString; Start = start; End = _position + 2; From 04206894f9e0ca21d00c834d6979cddf309ab764 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Sat, 1 Jun 2019 09:41:42 +0200 Subject: [PATCH 03/12] more performance improvements --- src/Core/Language/Utf8/Utf8GraphQLReader.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index e5a70f3a028..d41a9a962a1 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -224,7 +224,7 @@ public bool Read() if (code == GraphQLConstants.Quote) { - if (_graphQLData.Length > _position + 2 + if (_length > _position + 2 && _graphQLData[_position + 1] == GraphQLConstants.Quote && _graphQLData[_position + 2] == GraphQLConstants.Quote) { @@ -263,7 +263,7 @@ private void ReadNameToken() { position++; } - while (position < _graphQLData.Length + while (position < _length && GraphQLConstants.IsLetterOrDigitOrUnderscore( in _graphQLData[position])); @@ -421,7 +421,7 @@ private void ReadNumberToken( else { ReadDigits(in code); - if (_position < _graphQLData.Length) + if (_position < _length) { code = ref _graphQLData[_position]; } @@ -436,7 +436,7 @@ private void ReadNumberToken( isFloat = true; code = ref _graphQLData[++_position]; ReadDigits(in code); - if (_position < _graphQLData.Length) + if (_position < _length) { code = ref _graphQLData[_position]; } @@ -474,7 +474,7 @@ private void ReadDigits(in byte firstCode) $"`{(char)firstCode}` ({firstCode})."); } - while (++_position < _graphQLData.Length + while (++_position < _length && GraphQLConstants.IsDigit(_graphQLData[_position])) { } } @@ -497,7 +497,7 @@ private void ReadCommentToken() var trimStart = _position + 1; bool trim = true; - while (++_position < _graphQLData.Length + while (++_position < _length && !GraphQLConstants.IsControlCharacter( in _graphQLData[_position])) { @@ -676,7 +676,7 @@ private void SkipWhitespaces() if (code == GraphQLConstants.NewLine) { int next = _position + 1; - if (next < _graphQLData.Length + if (next < _length && _graphQLData[next] == GraphQLConstants.Return) { _position = next; @@ -686,7 +686,7 @@ private void SkipWhitespaces() else if (code == GraphQLConstants.Return) { int next = _position + 1; - if (next < _graphQLData.Length + if (next < -_length && _graphQLData[next] == GraphQLConstants.NewLine) { _position = next; From ae13092c9ebf961a9632209fd665132932cb75d4 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Sat, 1 Jun 2019 09:56:10 +0200 Subject: [PATCH 04/12] optimized skip --- .../Utf8/Utf8GraphQLParser.Utilities.cs | 17 +---- src/Core/Language/Utf8/Utf8GraphQLReader.cs | 65 ++++++++++++------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs index a942d4d7b77..aaf0d422e6b 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs @@ -23,11 +23,8 @@ private NameNode ParseName() ); } - private bool MoveNext() - { - while (_reader.Read() && _reader.Kind == TokenKind.Comment) ; - return !_reader.IsEndOfStream(); - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private bool MoveNext() => _reader.MoveNext(); [MethodImpl(MethodImplOptions.AggressiveInlining)] private TokenInfo Start() => @@ -168,15 +165,7 @@ private void ExpectKeyword(ReadOnlySpan keyword) private bool SkipAmpersand() => Skip(TokenKind.Ampersand); [MethodImpl(MethodImplOptions.AggressiveInlining)] - private bool Skip(TokenKind kind) - { - if (_reader.Kind == kind) - { - MoveNext(); - return true; - } - return false; - } + private bool Skip(TokenKind kind) => _reader.Skip(kind); private bool SkipRepeatableKeyword() => SkipKeyword(GraphQLKeywords.Repeatable); diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index d41a9a962a1..6433b530d4d 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -17,10 +17,11 @@ public ref partial struct Utf8GraphQLReader private ReadOnlySpan _value; private int _length; private int _position; + private TokenKind _kind; public Utf8GraphQLReader(ReadOnlySpan graphQLData) { - Kind = TokenKind.StartOfFile; + _kind = TokenKind.StartOfFile; Start = 0; End = 0; LineStart = 0; @@ -38,7 +39,7 @@ public Utf8GraphQLReader(ReadOnlySpan graphQLData) /// /// Gets the kind of . /// - public TokenKind Kind { get; private set; } + public TokenKind Kind => _kind; /// /// Gets the character offset at which this node begins. @@ -85,7 +86,7 @@ public unsafe string GetString() return string.Empty; } - bool isBlockString = Kind == TokenKind.BlockString; + bool isBlockString = _kind == TokenKind.BlockString; int length = checked((int)_value.Length); bool useStackalloc = @@ -173,10 +174,26 @@ public void UnescapeValue(ref Span unescapedValue) UnescapeValue( in _value, ref unescapedValue, - Kind == TokenKind.BlockString); + _kind == TokenKind.BlockString); } } + public bool MoveNext() + { + while (Read() && _kind == TokenKind.Comment) { } + return !IsEndOfStream(); + } + + public bool Skip(TokenKind kind) + { + if (_kind == kind) + { + MoveNext(); + return true; + } + return false; + } + public bool Read() { if (_position == 0) @@ -191,7 +208,7 @@ public bool Read() { Start = _position; End = _position; - Kind = TokenKind.EndOfFile; + _kind = TokenKind.EndOfFile; _value = null; return false; } @@ -267,7 +284,7 @@ private void ReadNameToken() && GraphQLConstants.IsLetterOrDigitOrUnderscore( in _graphQLData[position])); - Kind = TokenKind.Name; + _kind = TokenKind.Name; Start = start; End = position; _value = _graphQLData.Slice(start, position - start); @@ -302,55 +319,55 @@ private void ReadPunctuatorToken(in byte code) switch (code) { case GraphQLConstants.Bang: - Kind = TokenKind.Bang; + _kind = TokenKind.Bang; break; case GraphQLConstants.Dollar: - Kind = TokenKind.Dollar; + _kind = TokenKind.Dollar; break; case GraphQLConstants.Ampersand: - Kind = TokenKind.Ampersand; + _kind = TokenKind.Ampersand; break; case GraphQLConstants.LeftParenthesis: - Kind = TokenKind.LeftParenthesis; + _kind = TokenKind.LeftParenthesis; break; case GraphQLConstants.RightParenthesis: - Kind = TokenKind.RightParenthesis; + _kind = TokenKind.RightParenthesis; break; case GraphQLConstants.Colon: - Kind = TokenKind.Colon; + _kind = TokenKind.Colon; break; case GraphQLConstants.Equal: - Kind = TokenKind.Equal; + _kind = TokenKind.Equal; break; case GraphQLConstants.At: - Kind = TokenKind.At; + _kind = TokenKind.At; break; case GraphQLConstants.LeftBracket: - Kind = TokenKind.LeftBracket; + _kind = TokenKind.LeftBracket; break; case GraphQLConstants.RightBracket: - Kind = TokenKind.RightBracket; + _kind = TokenKind.RightBracket; break; case GraphQLConstants.LeftBrace: - Kind = TokenKind.LeftBrace; + _kind = TokenKind.LeftBrace; break; case GraphQLConstants.RightBrace: - Kind = TokenKind.RightBrace; + _kind = TokenKind.RightBrace; break; case GraphQLConstants.Pipe: - Kind = TokenKind.Pipe; + _kind = TokenKind.Pipe; break; case GraphQLConstants.Dot: @@ -359,7 +376,7 @@ private void ReadPunctuatorToken(in byte code) { _position += 2; End = _position; - Kind = TokenKind.Spread; + _kind = TokenKind.Spread; } else { @@ -458,7 +475,7 @@ private void ReadNumberToken( ReadDigits(in code); } - Kind = isFloat ? TokenKind.Float : TokenKind.Integer; + _kind = isFloat ? TokenKind.Float : TokenKind.Integer; Start = start; End = _position; _value = _graphQLData.Slice(start, _position - start); @@ -518,7 +535,7 @@ private void ReadCommentToken() } } - Kind = TokenKind.Comment; + _kind = TokenKind.Comment; Start = start; End = _position; _value = _graphQLData.Slice(trimStart, _position - trimStart); @@ -548,7 +565,7 @@ private void ReadStringValueToken() // closing Quote (") if (code == GraphQLConstants.Quote) { - Kind = TokenKind.String; + _kind = TokenKind.String; Start = start; End = _position; _value = _graphQLData.Slice(start + 1, _position - start - 1); @@ -604,7 +621,7 @@ private void ReadBlockStringToken() && _graphQLData[_position + 2] == GraphQLConstants.Quote) { _nextNewLines--; - Kind = TokenKind.BlockString; + _kind = TokenKind.BlockString; Start = start; End = _position + 2; _value = _graphQLData.Slice(start + 3, _position - start - 3); From 28163c79fe803ed6b14d55a5e0a6ce147b8c61ce Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Mon, 3 Jun 2019 18:10:01 +0200 Subject: [PATCH 05/12] refinements --- src/Core/Language/SyntaxException.cs | 4 +- src/Core/Language/Utf8/GraphQLConstants.cs | 24 +-- .../Utf8/Utf8GraphQLParser.Utilities.cs | 10 +- src/Core/Language/Utf8/Utf8GraphQLReader.cs | 147 +++++++++--------- src/Core/Language/Utf8/Utf8Helper.cs | 16 +- 5 files changed, 100 insertions(+), 101 deletions(-) diff --git a/src/Core/Language/SyntaxException.cs b/src/Core/Language/SyntaxException.cs index 496198f9f0d..934a9cc9bdc 100644 --- a/src/Core/Language/SyntaxException.cs +++ b/src/Core/Language/SyntaxException.cs @@ -13,8 +13,8 @@ internal SyntaxException(Utf8GraphQLReader reader, string message) : base(message) { Position = reader.Position; - Line = reader.Line; - Column = reader.Column; + Line = reader._line; + Column = reader._column; SourceText = Encoding.UTF8.GetString(reader.GraphQLData.ToArray()); } diff --git a/src/Core/Language/Utf8/GraphQLConstants.cs b/src/Core/Language/Utf8/GraphQLConstants.cs index 6769d3696fe..6354f2ba36b 100644 --- a/src/Core/Language/Utf8/GraphQLConstants.cs +++ b/src/Core/Language/Utf8/GraphQLConstants.cs @@ -1,4 +1,4 @@ -namespace HotChocolate.Language +namespace HotChocolate.Language { /// /// This class provides internal char utilities @@ -61,48 +61,48 @@ internal static partial class GraphQLConstants public const byte Return = (byte)'\r'; public const byte Quote = (byte)'"'; - public static bool IsLetterOrDigitOrUnderscore(in this byte c) + public static bool IsLetterOrDigitOrUnderscore(this byte c) { - return IsLetterOrUnderscore(in c) || IsDigit(in c); + return IsLetterOrUnderscore(c) || IsDigit(c); } - public static bool IsLetter(in this byte c) + public static bool IsLetter(this byte c) { byte normalized = (byte)(c | 0x20); return (normalized >= A && normalized <= Z); } - public static bool IsLetterOrUnderscore(in this byte c) + public static bool IsLetterOrUnderscore(this byte c) { return _isLetterOrUnderscore[c]; } - public static bool IsDigit(in this byte c) + public static bool IsDigit(this byte c) { return c >= 48 && c <= 57; } - public static bool IsDigitOrMinus(in this byte c) + public static bool IsDigitOrMinus(this byte c) { return _isDigitOrMinus[c]; } - public static bool IsPunctuator(in this byte c) + public static bool IsPunctuator(this byte c) { return _isPunctuator[c]; } - public static bool IsWhitespace(in this byte c) + public static bool IsWhitespace(this byte c) { return _isWhitespace[c]; } - public static bool IsValidEscapeCharacter(in this byte c) + public static bool IsValidEscapeCharacter(this byte c) { return _isEscapeCharacter[c]; } - public static byte EscapeCharacter(in this byte c) + public static byte EscapeCharacter(this byte c) { switch (c) { @@ -121,7 +121,7 @@ public static byte EscapeCharacter(in this byte c) } } - public static bool IsControlCharacter(in this byte c) + public static bool IsControlCharacter(this byte c) { return _isControlCharacter[c]; } diff --git a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs index aaf0d422e6b..340a2190719 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs @@ -30,10 +30,10 @@ private NameNode ParseName() private TokenInfo Start() => _createLocation ? new TokenInfo( - _reader.Start, - _reader.End, - _reader.Line, - _reader.Column) + _reader._start, + _reader._end, + _reader._line, + _reader._column) : default; [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -41,7 +41,7 @@ private Location CreateLocation(in TokenInfo start) => _createLocation ? new Location( start.Start, - _reader.End, + _reader._end, start.Line, start.Column) : null; diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index 6433b530d4d..adb88a11e93 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -1,9 +1,6 @@ -using System.Collections.Generic; -using System.Xml.Schema; using System.Buffers; using System; using System.Runtime.CompilerServices; -using System.Text; using System.Globalization; using HotChocolate.Language.Properties; @@ -18,15 +15,20 @@ public ref partial struct Utf8GraphQLReader private int _length; private int _position; private TokenKind _kind; + public int _start; + public int _end; + public int _line; + public int _lineStart; + public int _column; public Utf8GraphQLReader(ReadOnlySpan graphQLData) { _kind = TokenKind.StartOfFile; - Start = 0; - End = 0; - LineStart = 0; - Line = 1; - Column = 1; + _start = 0; + _end = 0; + _lineStart = 0; + _line = 1; + _column = 1; _graphQLData = graphQLData; _length = graphQLData.Length; _nextNewLines = 0; @@ -44,12 +46,12 @@ public Utf8GraphQLReader(ReadOnlySpan graphQLData) /// /// Gets the character offset at which this node begins. /// - public int Start { get; private set; } + public int Start => _start; /// /// Gets the character offset at which this node ends. /// - public int End { get; private set; } + public int End => _end; /// /// The current position of the lexer pointer. @@ -60,18 +62,18 @@ public Utf8GraphQLReader(ReadOnlySpan graphQLData) /// Gets the 1-indexed line number on which this /// appears. /// - public int Line { get; private set; } + public int Line => _line; /// /// The source index of where the current line starts. /// - public int LineStart { get; private set; } + public int LineStart => _lineStart; /// /// Gets the 1-indexed column number at which this /// begins. /// - public int Column { get; private set; } + public int Column => _column; /// /// For non-punctuation tokens, represents the interpreted @@ -206,30 +208,30 @@ public bool Read() if (IsEndOfStream()) { - Start = _position; - End = _position; + _start = _position; + _end = _position; _kind = TokenKind.EndOfFile; _value = null; return false; } - ref readonly byte code = ref _graphQLData[_position]; + byte code = _graphQLData[_position]; - if (GraphQLConstants.IsLetterOrUnderscore(in code)) + if (GraphQLConstants.IsLetterOrUnderscore(code)) { ReadNameToken(); return true; } - if (GraphQLConstants.IsPunctuator(in code)) + if (GraphQLConstants.IsPunctuator(code)) { - ReadPunctuatorToken(in code); + ReadPunctuatorToken(code); return true; } - if (GraphQLConstants.IsDigitOrMinus(in code)) + if (GraphQLConstants.IsDigitOrMinus(code)) { - ReadNumberToken(in code); + ReadNumberToken(code); return true; } @@ -282,11 +284,11 @@ private void ReadNameToken() } while (position < _length && GraphQLConstants.IsLetterOrDigitOrUnderscore( - in _graphQLData[position])); + _graphQLData[position])); _kind = TokenKind.Name; - Start = start; - End = position; + _start = start; + _end = position; _value = _graphQLData.Slice(start, position - start); _position = position; } @@ -312,8 +314,8 @@ private void ReadNameToken() [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ReadPunctuatorToken(in byte code) { - Start = _position; - End = ++_position; + _start = _position; + _end = ++_position; _value = null; switch (code) @@ -375,7 +377,7 @@ private void ReadPunctuatorToken(in byte code) && _graphQLData[_position + 1] == GraphQLConstants.Dot) { _position += 2; - End = _position; + _end = _position; _kind = TokenKind.Spread; } else @@ -413,22 +415,21 @@ private void ReadPunctuatorToken(in byte code) /// Returns the int or float tokens read from the current lexer state. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void ReadNumberToken( - in byte firstCode) + private void ReadNumberToken(byte firstCode) { int start = _position; - ref readonly byte code = ref firstCode; + byte code = firstCode; var isFloat = false; if (code == GraphQLConstants.Minus) { - code = ref _graphQLData[++_position]; + code = _graphQLData[++_position]; } if (code == GraphQLConstants.Zero) { - code = ref _graphQLData[++_position]; - if (GraphQLConstants.IsDigit(in code)) + code = _graphQLData[++_position]; + if (GraphQLConstants.IsDigit(code)) { throw new SyntaxException(this, "Invalid number, unexpected digit after 0: " + @@ -437,52 +438,52 @@ private void ReadNumberToken( } else { - ReadDigits(in code); + ReadDigits(code); if (_position < _length) { - code = ref _graphQLData[_position]; + code = _graphQLData[_position]; } else { - code = ref _space; + code = _space; } } if (code == GraphQLConstants.Dot) { isFloat = true; - code = ref _graphQLData[++_position]; - ReadDigits(in code); + code = _graphQLData[++_position]; + ReadDigits(code); if (_position < _length) { - code = ref _graphQLData[_position]; + code = _graphQLData[_position]; } else { - code = ref _space; + code = GraphQLConstants.Space; } } if ((code | (char)0x20) == GraphQLConstants.E) { isFloat = true; - code = ref _graphQLData[++_position]; + code = _graphQLData[++_position]; if (code == GraphQLConstants.Plus || code == GraphQLConstants.Minus) { - code = ref _graphQLData[++_position]; + code = _graphQLData[++_position]; } - ReadDigits(in code); + ReadDigits(code); } _kind = isFloat ? TokenKind.Float : TokenKind.Integer; - Start = start; - End = _position; + _start = start; + _end = _position; _value = _graphQLData.Slice(start, _position - start); } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void ReadDigits(in byte firstCode) + private void ReadDigits(byte firstCode) { if (!firstCode.IsDigit()) { @@ -516,7 +517,7 @@ private void ReadCommentToken() while (++_position < _length && !GraphQLConstants.IsControlCharacter( - in _graphQLData[_position])) + _graphQLData[_position])) { if (trim) { @@ -536,8 +537,8 @@ private void ReadCommentToken() } _kind = TokenKind.Comment; - Start = start; - End = _position; + _start = start; + _end = _position; _value = _graphQLData.Slice(trimStart, _position - trimStart); } @@ -556,8 +557,7 @@ private void ReadCommentToken() private void ReadStringValueToken() { var start = _position; - - ref readonly byte code = ref _graphQLData[++_position]; + byte code = _graphQLData[++_position]; while (code != GraphQLConstants.NewLine && code != GraphQLConstants.Return) @@ -566,15 +566,15 @@ private void ReadStringValueToken() if (code == GraphQLConstants.Quote) { _kind = TokenKind.String; - Start = start; - End = _position; + _start = start; + _end = _position; _value = _graphQLData.Slice(start + 1, _position - start - 1); _position++; return; } // SourceCharacter - if (GraphQLConstants.IsControlCharacter(in code)) + if (GraphQLConstants.IsControlCharacter(code)) { throw new SyntaxException(this, $"Invalid character within String: {code}."); @@ -582,15 +582,15 @@ private void ReadStringValueToken() if (code == GraphQLConstants.Backslash) { - code = ref _graphQLData[++_position]; - if (!GraphQLConstants.IsValidEscapeCharacter(in code)) + code = _graphQLData[++_position]; + if (!GraphQLConstants.IsValidEscapeCharacter(code)) { throw new SyntaxException(this, $"Invalid character escape sequence: \\{code}."); } } - code = ref _graphQLData[++_position]; + code = _graphQLData[++_position]; } throw new SyntaxException(this, "Unterminated string."); @@ -611,7 +611,7 @@ private void ReadBlockStringToken() var start = _position - 2; _nextNewLines = 0; - ref readonly byte code = ref _graphQLData[++_position]; + byte code = _graphQLData[++_position]; while (!IsEndOfStream()) { @@ -622,10 +622,10 @@ private void ReadBlockStringToken() { _nextNewLines--; _kind = TokenKind.BlockString; - Start = start; - End = _position + 2; + _start = start; + _end = _position + 2; _value = _graphQLData.Slice(start + 3, _position - start - 3); - _position = End + 1; + _position = _end + 1; return; } @@ -666,7 +666,7 @@ private void ReadBlockStringToken() _nextNewLines++; } - code = ref _graphQLData[++_position]; + code = _graphQLData[++_position]; } throw new SyntaxException(this, "Unterminated string."); @@ -686,9 +686,9 @@ private void SkipWhitespaces() _nextNewLines = 0; } - ref readonly byte code = ref _graphQLData[_position]; + byte code = _graphQLData[_position]; - while (GraphQLConstants.IsWhitespace(in code)) + while (GraphQLConstants.IsWhitespace(code)) { if (code == GraphQLConstants.NewLine) { @@ -718,20 +718,19 @@ private void SkipWhitespaces() return; } - code = ref _graphQLData[_position]; + code = _graphQLData[_position]; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] private void SkipBoml() { - ref readonly byte code = ref _graphQLData[_position]; + byte code = _graphQLData[_position]; if (code == 239) { - ref readonly byte second = ref _graphQLData[_position + 1]; - ref readonly byte third = ref _graphQLData[_position + 2]; - if (second == 187 && third == 191) + if (_graphQLData[_position + 1] == 187 + && _graphQLData[_position + 2] == 191) { _position += 3; } @@ -744,8 +743,8 @@ private void SkipBoml() [MethodImpl(MethodImplOptions.AggressiveInlining)] public void NewLine() { - Line++; - LineStart = _position; + _line++; + _lineStart = _position; UpdateColumn(); } @@ -763,8 +762,8 @@ public void NewLine(int lines) "Must be greater or equal to 1."); } - Line += lines; - LineStart = _position; + _line += lines; + _lineStart = _position; UpdateColumn(); } @@ -774,7 +773,7 @@ public void NewLine(int lines) [MethodImpl(MethodImplOptions.AggressiveInlining)] public void UpdateColumn() { - Column = 1 + _position - LineStart; + _column = 1 + _position - _lineStart; } /// diff --git a/src/Core/Language/Utf8/Utf8Helper.cs b/src/Core/Language/Utf8/Utf8Helper.cs index 3c7ca15c94c..3bf8f600c12 100644 --- a/src/Core/Language/Utf8/Utf8Helper.cs +++ b/src/Core/Language/Utf8/Utf8Helper.cs @@ -20,11 +20,11 @@ public static void Unescape( do { - ref readonly byte code = ref escapedString[++readPosition]; + byte code = escapedString[++readPosition]; if (code == GraphQLConstants.Backslash) { - code = ref escapedString[++readPosition]; + code = escapedString[++readPosition]; if (isBlockString && code == GraphQLConstants.Quote) @@ -46,15 +46,15 @@ public static void Unescape( else if (GraphQLConstants.IsValidEscapeCharacter(code)) { unescapedString[writePosition++] = - GraphQLConstants.EscapeCharacter(in code); + GraphQLConstants.EscapeCharacter(code); } else if (code == GraphQLConstants.U) { UnescapeUtf8Hex( - in escapedString[++readPosition], - in escapedString[++readPosition], - in escapedString[++readPosition], - in escapedString[++readPosition], + escapedString[++readPosition], + escapedString[++readPosition], + escapedString[++readPosition], + escapedString[++readPosition], ref writePosition, ref unescapedString); } @@ -79,7 +79,7 @@ public static void Unescape( [MethodImpl(MethodImplOptions.AggressiveInlining)] private static void UnescapeUtf8Hex( - in byte a, in byte b, in byte c, in byte d, + byte a, byte b, byte c, byte d, ref int writePosition, ref Span unescapedString) { From 775290f548dcc95a5c3ee0835cacef3197a3bed7 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Mon, 3 Jun 2019 18:20:31 +0200 Subject: [PATCH 06/12] refinements --- .../Utf8/GraphQLConstants.Initialization.cs | 29 ++++++++++++++++++- src/Core/Language/Utf8/GraphQLConstants.cs | 4 ++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs b/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs index e553e1c730b..8b9f87a7822 100644 --- a/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs +++ b/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs @@ -1,4 +1,4 @@ -namespace HotChocolate.Language +namespace HotChocolate.Language { internal static partial class GraphQLConstants { @@ -9,6 +9,7 @@ static GraphQLConstants() InitializeIsWhitespaceCache(); InitializeIsPunctuatorCache(); InitializeIsLetterOrUnderscoreCache(); + InitializeIsLetterOrDigitOUnderscoreCache(); InitializeIsDigitOrMinusCache(); } @@ -80,6 +81,32 @@ private static void InitializeIsLetterOrUnderscoreCache() _isLetterOrUnderscore['_'] = true; } + private static void InitializeIsLetterOrDigitOUnderscoreCache() + { + for (char c = 'a'; c <= 'z'; c++) + { + _isLetterOrDigitOrUnderscore[c] = true; + } + + for (char c = 'A'; c <= 'Z'; c++) + { + _isLetterOrDigitOrUnderscore[c] = true; + } + + _isLetterOrDigitOrUnderscore['0'] = true; + _isLetterOrDigitOrUnderscore['1'] = true; + _isLetterOrDigitOrUnderscore['2'] = true; + _isLetterOrDigitOrUnderscore['3'] = true; + _isLetterOrDigitOrUnderscore['4'] = true; + _isLetterOrDigitOrUnderscore['5'] = true; + _isLetterOrDigitOrUnderscore['6'] = true; + _isLetterOrDigitOrUnderscore['7'] = true; + _isLetterOrDigitOrUnderscore['8'] = true; + _isLetterOrDigitOrUnderscore['9'] = true; + + _isLetterOrDigitOrUnderscore['_'] = true; + } + private static void InitializeIsDigitOrMinusCache() { _isDigitOrMinus['-'] = true; diff --git a/src/Core/Language/Utf8/GraphQLConstants.cs b/src/Core/Language/Utf8/GraphQLConstants.cs index 6354f2ba36b..9bc9e9ec24e 100644 --- a/src/Core/Language/Utf8/GraphQLConstants.cs +++ b/src/Core/Language/Utf8/GraphQLConstants.cs @@ -9,6 +9,8 @@ internal static partial class GraphQLConstants { private static readonly bool[] _isLetterOrUnderscore = new bool[char.MaxValue + 1]; + private static readonly bool[] _isLetterOrDigitOrUnderscore = + new bool[char.MaxValue + 1]; private static readonly bool[] _isControlCharacter = new bool[char.MaxValue + 1]; private static readonly bool[] _isEscapeCharacter = @@ -63,7 +65,7 @@ internal static partial class GraphQLConstants public static bool IsLetterOrDigitOrUnderscore(this byte c) { - return IsLetterOrUnderscore(c) || IsDigit(c); + return _isLetterOrDigitOrUnderscore[c]; } public static bool IsLetter(this byte c) From 2c6152c42bc8f5a4d1c86ec3d6d0cd8f1d33db0b Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Mon, 10 Jun 2019 22:25:14 +0200 Subject: [PATCH 07/12] Optimized parser skip --- .../Language/Utf8/Utf8GraphQLParser.Utilities.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs index 340a2190719..c9c9a7a6ca1 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs @@ -120,7 +120,7 @@ private void ExpectRightBrace() => [MethodImpl(MethodImplOptions.AggressiveInlining)] private void Expect(TokenKind kind) { - if (!Skip(kind)) + if (!_reader.Skip(kind)) { throw new SyntaxException(_reader, string.Format(CultureInfo.InvariantCulture, @@ -156,16 +156,13 @@ private void ExpectKeyword(ReadOnlySpan keyword) } } - private bool SkipPipe() => Skip(TokenKind.Pipe); + private bool SkipPipe() => _reader.Skip(TokenKind.Pipe); - private bool SkipEqual() => Skip(TokenKind.Equal); + private bool SkipEqual() => _reader.Skip(TokenKind.Equal); - private bool SkipColon() => Skip(TokenKind.Colon); + private bool SkipColon() => _reader.Skip(TokenKind.Colon); - private bool SkipAmpersand() => Skip(TokenKind.Ampersand); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private bool Skip(TokenKind kind) => _reader.Skip(kind); + private bool SkipAmpersand() => _reader.Skip(TokenKind.Ampersand); private bool SkipRepeatableKeyword() => SkipKeyword(GraphQLKeywords.Repeatable); From 080aa37205691d4aa7c013f546cf8c30ca1f4d2f Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Tue, 11 Jun 2019 13:26:36 +0200 Subject: [PATCH 08/12] Added more improvements --- .../Language.Tests/Utf8/Utf8HelperTests.cs | 2 +- ...rTests.ParseFacebookKitchenSinkSchema.snap | 632 +++++++++--------- ...Utf8ReaderTests.Read_BlockStringValue.snap | 4 +- .../Utf8/GraphQLConstants.Initialization.cs | 33 +- src/Core/Language/Utf8/GraphQLConstants.cs | 56 +- .../Utf8/Utf8GraphQLReader.Utilities.cs | 126 ++++ src/Core/Language/Utf8/Utf8GraphQLReader.cs | 133 +--- 7 files changed, 523 insertions(+), 463 deletions(-) create mode 100644 src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs diff --git a/src/Core/Language.Tests/Utf8/Utf8HelperTests.cs b/src/Core/Language.Tests/Utf8/Utf8HelperTests.cs index 33e95710f31..d2ebd7b08ed 100644 --- a/src/Core/Language.Tests/Utf8/Utf8HelperTests.cs +++ b/src/Core/Language.Tests/Utf8/Utf8HelperTests.cs @@ -56,7 +56,7 @@ public void Unescape_StandardEscapeChars_OutputIsUnescaped( [InlineData("\\\"\"\"", "\"\"\"")] [Theory] public void Unescape_BlockStringEscapeChars_OutputIsUnescaped( - string escaped, string unescaped) + string escaped, string unescaped) { // arrange byte[] inputData = Encoding.UTF8.GetBytes("hello_123_" + escaped); diff --git a/src/Core/Language.Tests/Utf8/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema.snap b/src/Core/Language.Tests/Utf8/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema.snap index 7622f37815e..1c20ea36897 100644 --- a/src/Core/Language.Tests/Utf8/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema.snap +++ b/src/Core/Language.Tests/Utf8/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema.snap @@ -97,7 +97,7 @@ "Location": { "Start": 297, "End": 302, - "Line": 14, + "Line": 15, "Column": 22 }, "Name": { @@ -105,7 +105,7 @@ "Location": { "Start": 297, "End": 302, - "Line": 14, + "Line": 15, "Column": 22 }, "Value": "Bar" @@ -116,7 +116,7 @@ "Location": { "Start": 303, "End": 308, - "Line": 14, + "Line": 15, "Column": 28 }, "Name": { @@ -124,7 +124,7 @@ "Location": { "Start": 303, "End": 308, - "Line": 14, + "Line": 15, "Column": 28 }, "Value": "Baz" @@ -141,7 +141,7 @@ "Location": { "Start": 316, "End": 375, - "Line": 15, + "Line": 16, "Column": 9 }, "Name": { @@ -149,7 +149,7 @@ "Location": { "Start": 316, "End": 375, - "Line": 15, + "Line": 16, "Column": 9 }, "Value": "Type" @@ -158,7 +158,7 @@ "Location": { "Start": 311, "End": 375, - "Line": 15, + "Line": 16, "Column": 4 }, "Name": { @@ -166,7 +166,7 @@ "Location": { "Start": 311, "End": 315, - "Line": 15, + "Line": 16, "Column": 4 }, "Value": "one" @@ -180,7 +180,7 @@ "Location": { "Start": 323, "End": 382, - "Line": 16, + "Line": 17, "Column": 4 }, "Value": "This is a description of the `two` field.", @@ -194,7 +194,7 @@ "Location": { "Start": 388, "End": 466, - "Line": 20, + "Line": 21, "Column": 6 }, "Value": "This is a description of the `argument` argument.", @@ -205,7 +205,7 @@ "Location": { "Start": 477, "End": 482, - "Line": 23, + "Line": 24, "Column": 25 }, "Type": { @@ -213,7 +213,7 @@ "Location": { "Start": 468, "End": 478, - "Line": 23, + "Line": 24, "Column": 16 }, "Name": { @@ -221,7 +221,7 @@ "Location": { "Start": 468, "End": 478, - "Line": 23, + "Line": 24, "Column": 16 }, "Value": "InputType" @@ -232,7 +232,7 @@ "Location": { "Start": 388, "End": 482, - "Line": 20, + "Line": 21, "Column": 6 }, "Name": { @@ -240,7 +240,7 @@ "Location": { "Start": 458, "End": 467, - "Line": 23, + "Line": 24, "Column": 6 }, "Value": "argument" @@ -253,7 +253,7 @@ "Location": { "Start": 484, "End": 496, - "Line": 24, + "Line": 25, "Column": 7 }, "Name": { @@ -261,7 +261,7 @@ "Location": { "Start": 484, "End": 496, - "Line": 24, + "Line": 25, "Column": 7 }, "Value": "Type" @@ -270,7 +270,7 @@ "Location": { "Start": 323, "End": 496, - "Line": 16, + "Line": 17, "Column": 4 }, "Name": { @@ -278,7 +278,7 @@ "Location": { "Start": 379, "End": 383, - "Line": 19, + "Line": 20, "Column": 4 }, "Value": "two" @@ -297,7 +297,7 @@ "Location": { "Start": 507, "End": 523, - "Line": 25, + "Line": 26, "Column": 20 }, "Name": { @@ -305,7 +305,7 @@ "Location": { "Start": 507, "End": 523, - "Line": 25, + "Line": 26, "Column": 20 }, "Value": "InputType" @@ -315,7 +315,7 @@ "Location": { "Start": 497, "End": 523, - "Line": 25, + "Line": 26, "Column": 10 }, "Name": { @@ -323,7 +323,7 @@ "Location": { "Start": 497, "End": 506, - "Line": 25, + "Line": 26, "Column": 10 }, "Value": "argument" @@ -338,7 +338,7 @@ "Location": { "Start": 525, "End": 532, - "Line": 25, + "Line": 26, "Column": 38 }, "Name": { @@ -346,7 +346,7 @@ "Location": { "Start": 525, "End": 532, - "Line": 25, + "Line": 26, "Column": 38 }, "Value": "String" @@ -356,7 +356,7 @@ "Location": { "Start": 518, "End": 532, - "Line": 25, + "Line": 26, "Column": 31 }, "Name": { @@ -364,7 +364,7 @@ "Location": { "Start": 518, "End": 524, - "Line": 25, + "Line": 26, "Column": 31 }, "Value": "other" @@ -377,7 +377,7 @@ "Location": { "Start": 534, "End": 544, - "Line": 25, + "Line": 26, "Column": 47 }, "Name": { @@ -385,7 +385,7 @@ "Location": { "Start": 534, "End": 544, - "Line": 25, + "Line": 26, "Column": 47 }, "Value": "Int" @@ -394,7 +394,7 @@ "Location": { "Start": 491, "End": 544, - "Line": 25, + "Line": 26, "Column": 4 }, "Name": { @@ -402,7 +402,7 @@ "Location": { "Start": 491, "End": 497, - "Line": 25, + "Line": 26, "Column": 4 }, "Value": "three" @@ -421,7 +421,7 @@ "Location": { "Start": 555, "End": 563, - "Line": 26, + "Line": 27, "Column": 19 }, "Name": { @@ -429,7 +429,7 @@ "Location": { "Start": 555, "End": 563, - "Line": 26, + "Line": 27, "Column": 19 }, "Value": "String" @@ -440,7 +440,7 @@ "Location": { "Start": 564, "End": 573, - "Line": 26, + "Line": 27, "Column": 28 }, "Value": "string", @@ -449,7 +449,7 @@ "Location": { "Start": 545, "End": 573, - "Line": 26, + "Line": 27, "Column": 9 }, "Name": { @@ -457,7 +457,7 @@ "Location": { "Start": 545, "End": 554, - "Line": 26, + "Line": 27, "Column": 9 }, "Value": "argument" @@ -470,7 +470,7 @@ "Location": { "Start": 575, "End": 588, - "Line": 26, + "Line": 27, "Column": 39 }, "Name": { @@ -478,7 +478,7 @@ "Location": { "Start": 575, "End": 588, - "Line": 26, + "Line": 27, "Column": 39 }, "Value": "String" @@ -487,7 +487,7 @@ "Location": { "Start": 540, "End": 588, - "Line": 26, + "Line": 27, "Column": 4 }, "Name": { @@ -495,7 +495,7 @@ "Location": { "Start": 540, "End": 545, - "Line": 26, + "Line": 27, "Column": 4 }, "Value": "four" @@ -514,7 +514,7 @@ "Location": { "Start": 599, "End": 609, - "Line": 27, + "Line": 28, "Column": 19 }, "Type": { @@ -522,7 +522,7 @@ "Location": { "Start": 600, "End": 607, - "Line": 27, + "Line": 28, "Column": 20 }, "Name": { @@ -530,7 +530,7 @@ "Location": { "Start": 600, "End": 607, - "Line": 27, + "Line": 28, "Column": 20 }, "Value": "String" @@ -542,7 +542,7 @@ "Location": { "Start": 610, "End": 631, - "Line": 27, + "Line": 28, "Column": 30 }, "Items": [ @@ -551,7 +551,7 @@ "Location": { "Start": 611, "End": 628, - "Line": 27, + "Line": 28, "Column": 31 }, "Value": "string", @@ -562,7 +562,7 @@ "Location": { "Start": 621, "End": 630, - "Line": 27, + "Line": 28, "Column": 41 }, "Value": "string", @@ -573,7 +573,7 @@ "Location": { "Start": 589, "End": 631, - "Line": 27, + "Line": 28, "Column": 9 }, "Name": { @@ -581,7 +581,7 @@ "Location": { "Start": 589, "End": 598, - "Line": 27, + "Line": 28, "Column": 9 }, "Value": "argument" @@ -594,7 +594,7 @@ "Location": { "Start": 633, "End": 645, - "Line": 27, + "Line": 28, "Column": 53 }, "Name": { @@ -602,7 +602,7 @@ "Location": { "Start": 633, "End": 645, - "Line": 27, + "Line": 28, "Column": 53 }, "Value": "String" @@ -611,7 +611,7 @@ "Location": { "Start": 584, "End": 645, - "Line": 27, + "Line": 28, "Column": 4 }, "Name": { @@ -619,7 +619,7 @@ "Location": { "Start": 584, "End": 589, - "Line": 27, + "Line": 28, "Column": 4 }, "Value": "five" @@ -638,7 +638,7 @@ "Location": { "Start": 656, "End": 667, - "Line": 28, + "Line": 29, "Column": 18 }, "Name": { @@ -646,7 +646,7 @@ "Location": { "Start": 656, "End": 667, - "Line": 28, + "Line": 29, "Column": 18 }, "Value": "InputType" @@ -657,7 +657,7 @@ "Location": { "Start": 668, "End": 683, - "Line": 28, + "Line": 29, "Column": 30 }, "Fields": [ @@ -666,7 +666,7 @@ "Location": { "Start": 669, "End": 682, - "Line": 28, + "Line": 29, "Column": 31 }, "Name": { @@ -674,7 +674,7 @@ "Location": { "Start": 669, "End": 673, - "Line": 28, + "Line": 29, "Column": 31 }, "Value": "key" @@ -684,7 +684,7 @@ "Location": { "Start": 674, "End": 682, - "Line": 28, + "Line": 29, "Column": 36 }, "Value": "value", @@ -696,7 +696,7 @@ "Location": { "Start": 646, "End": 683, - "Line": 28, + "Line": 29, "Column": 8 }, "Name": { @@ -704,7 +704,7 @@ "Location": { "Start": 646, "End": 655, - "Line": 28, + "Line": 29, "Column": 8 }, "Value": "argument" @@ -717,7 +717,7 @@ "Location": { "Start": 685, "End": 697, - "Line": 28, + "Line": 29, "Column": 47 }, "Name": { @@ -725,7 +725,7 @@ "Location": { "Start": 685, "End": 697, - "Line": 28, + "Line": 29, "Column": 47 }, "Value": "Type" @@ -734,7 +734,7 @@ "Location": { "Start": 642, "End": 697, - "Line": 28, + "Line": 29, "Column": 4 }, "Name": { @@ -742,7 +742,7 @@ "Location": { "Start": 642, "End": 646, - "Line": 28, + "Line": 29, "Column": 4 }, "Value": "six" @@ -761,7 +761,7 @@ "Location": { "Start": 708, "End": 713, - "Line": 29, + "Line": 30, "Column": 20 }, "Name": { @@ -769,7 +769,7 @@ "Location": { "Start": 708, "End": 713, - "Line": 29, + "Line": 30, "Column": 20 }, "Value": "Int" @@ -780,7 +780,7 @@ "Location": { "Start": 714, "End": 719, - "Line": 29, + "Line": 30, "Column": 26 }, "Value": null @@ -788,7 +788,7 @@ "Location": { "Start": 698, "End": 719, - "Line": 29, + "Line": 30, "Column": 10 }, "Name": { @@ -796,7 +796,7 @@ "Location": { "Start": 698, "End": 707, - "Line": 29, + "Line": 30, "Column": 10 }, "Value": "argument" @@ -809,7 +809,7 @@ "Location": { "Start": 721, "End": 727, - "Line": 29, + "Line": 30, "Column": 33 }, "Name": { @@ -817,7 +817,7 @@ "Location": { "Start": 721, "End": 727, - "Line": 29, + "Line": 30, "Column": 33 }, "Value": "Type" @@ -826,7 +826,7 @@ "Location": { "Start": 692, "End": 727, - "Line": 29, + "Line": 30, "Column": 4 }, "Name": { @@ -834,7 +834,7 @@ "Location": { "Start": 692, "End": 698, - "Line": 29, + "Line": 30, "Column": 4 }, "Value": "seven" @@ -845,7 +845,7 @@ "Location": { "Start": 277, "End": 733, - "Line": 14, + "Line": 15, "Column": 2 }, "Name": { @@ -853,7 +853,7 @@ "Location": { "Start": 282, "End": 296, - "Line": 14, + "Line": 15, "Column": 7 }, "Value": "Foo" @@ -877,7 +877,7 @@ "Location": { "Start": 798, "End": 804, - "Line": 33, + "Line": 34, "Column": 24 }, "Name": { @@ -885,7 +885,7 @@ "Location": { "Start": 798, "End": 804, - "Line": 33, + "Line": 34, "Column": 24 }, "Value": "Type" @@ -896,7 +896,7 @@ "Location": { "Start": 805, "End": 816, - "Line": 33, + "Line": 34, "Column": 31 }, "Value": "default", @@ -905,7 +905,7 @@ "Location": { "Start": 793, "End": 822, - "Line": 33, + "Line": 34, "Column": 19 }, "Name": { @@ -913,7 +913,7 @@ "Location": { "Start": 793, "End": 797, - "Line": 33, + "Line": 34, "Column": 19 }, "Value": "arg" @@ -924,7 +924,7 @@ "Location": { "Start": 815, "End": 822, - "Line": 33, + "Line": 34, "Column": 41 }, "Name": { @@ -932,7 +932,7 @@ "Location": { "Start": 816, "End": 822, - "Line": 33, + "Line": 34, "Column": 42 }, "Value": "onArg" @@ -947,7 +947,7 @@ "Location": { "Start": 824, "End": 830, - "Line": 33, + "Line": 34, "Column": 50 }, "Name": { @@ -955,7 +955,7 @@ "Location": { "Start": 824, "End": 830, - "Line": 33, + "Line": 34, "Column": 50 }, "Value": "Type" @@ -964,7 +964,7 @@ "Location": { "Start": 778, "End": 839, - "Line": 33, + "Line": 34, "Column": 4 }, "Name": { @@ -972,7 +972,7 @@ "Location": { "Start": 778, "End": 793, - "Line": 33, + "Line": 34, "Column": 4 }, "Value": "annotatedField" @@ -983,7 +983,7 @@ "Location": { "Start": 829, "End": 839, - "Line": 33, + "Line": 34, "Column": 55 }, "Name": { @@ -991,7 +991,7 @@ "Location": { "Start": 830, "End": 839, - "Line": 33, + "Line": 34, "Column": 56 }, "Value": "onField" @@ -1004,7 +1004,7 @@ "Location": { "Start": 729, "End": 845, - "Line": 32, + "Line": 33, "Column": 2 }, "Name": { @@ -1012,7 +1012,7 @@ "Location": { "Start": 734, "End": 751, - "Line": 32, + "Line": 33, "Column": 7 }, "Value": "AnnotatedObject" @@ -1023,7 +1023,7 @@ "Location": { "Start": 750, "End": 775, - "Line": 32, + "Line": 33, "Column": 23 }, "Name": { @@ -1031,7 +1031,7 @@ "Location": { "Start": 751, "End": 760, - "Line": 32, + "Line": 33, "Column": 24 }, "Value": "onObject" @@ -1042,7 +1042,7 @@ "Location": { "Start": 760, "End": 773, - "Line": 32, + "Line": 33, "Column": 33 }, "Name": { @@ -1050,7 +1050,7 @@ "Location": { "Start": 760, "End": 764, - "Line": 32, + "Line": 33, "Column": 33 }, "Value": "arg" @@ -1060,7 +1060,7 @@ "Location": { "Start": 765, "End": 773, - "Line": 32, + "Line": 33, "Column": 38 }, "Value": "value", @@ -1079,7 +1079,7 @@ "Location": { "Start": 841, "End": 867, - "Line": 36, + "Line": 37, "Column": 2 }, "Name": { @@ -1087,7 +1087,7 @@ "Location": { "Start": 846, "End": 867, - "Line": 36, + "Line": 37, "Column": 7 }, "Value": "UndefinedType" @@ -1110,7 +1110,7 @@ "Location": { "Start": 897, "End": 906, - "Line": 39, + "Line": 40, "Column": 20 }, "Type": { @@ -1118,7 +1118,7 @@ "Location": { "Start": 898, "End": 905, - "Line": 39, + "Line": 40, "Column": 21 }, "Name": { @@ -1126,7 +1126,7 @@ "Location": { "Start": 898, "End": 905, - "Line": 39, + "Line": 40, "Column": 21 }, "Value": "String" @@ -1137,7 +1137,7 @@ "Location": { "Start": 887, "End": 906, - "Line": 39, + "Line": 40, "Column": 10 }, "Name": { @@ -1145,7 +1145,7 @@ "Location": { "Start": 887, "End": 896, - "Line": 39, + "Line": 40, "Column": 10 }, "Value": "argument" @@ -1158,7 +1158,7 @@ "Location": { "Start": 908, "End": 914, - "Line": 39, + "Line": 40, "Column": 31 }, "Name": { @@ -1166,7 +1166,7 @@ "Location": { "Start": 908, "End": 914, - "Line": 39, + "Line": 40, "Column": 31 }, "Value": "Type" @@ -1175,7 +1175,7 @@ "Location": { "Start": 881, "End": 914, - "Line": 39, + "Line": 40, "Column": 4 }, "Name": { @@ -1183,7 +1183,7 @@ "Location": { "Start": 881, "End": 887, - "Line": 39, + "Line": 40, "Column": 4 }, "Value": "seven" @@ -1194,7 +1194,7 @@ "Location": { "Start": 861, "End": 922, - "Line": 38, + "Line": 39, "Column": 2 }, "Name": { @@ -1202,7 +1202,7 @@ "Location": { "Start": 873, "End": 878, - "Line": 38, + "Line": 39, "Column": 14 }, "Value": "Foo" @@ -1216,7 +1216,7 @@ "Location": { "Start": 916, "End": 950, - "Line": 42, + "Line": 43, "Column": 2 }, "Name": { @@ -1224,7 +1224,7 @@ "Location": { "Start": 928, "End": 933, - "Line": 42, + "Line": 43, "Column": 14 }, "Value": "Foo" @@ -1235,7 +1235,7 @@ "Location": { "Start": 932, "End": 950, - "Line": 42, + "Line": 43, "Column": 18 }, "Name": { @@ -1243,7 +1243,7 @@ "Location": { "Start": 933, "End": 950, - "Line": 42, + "Line": 43, "Column": 19 }, "Value": "onType" @@ -1265,7 +1265,7 @@ "Location": { "Start": 964, "End": 975, - "Line": 45, + "Line": 46, "Column": 9 }, "Name": { @@ -1273,7 +1273,7 @@ "Location": { "Start": 964, "End": 975, - "Line": 45, + "Line": 46, "Column": 9 }, "Value": "Type" @@ -1282,7 +1282,7 @@ "Location": { "Start": 959, "End": 975, - "Line": 45, + "Line": 46, "Column": 4 }, "Name": { @@ -1290,7 +1290,7 @@ "Location": { "Start": 959, "End": 963, - "Line": 45, + "Line": 46, "Column": 4 }, "Value": "one" @@ -1309,7 +1309,7 @@ "Location": { "Start": 986, "End": 994, - "Line": 46, + "Line": 47, "Column": 19 }, "Name": { @@ -1317,7 +1317,7 @@ "Location": { "Start": 986, "End": 994, - "Line": 46, + "Line": 47, "Column": 19 }, "Value": "String" @@ -1328,7 +1328,7 @@ "Location": { "Start": 995, "End": 1004, - "Line": 46, + "Line": 47, "Column": 28 }, "Value": "string", @@ -1337,7 +1337,7 @@ "Location": { "Start": 976, "End": 1004, - "Line": 46, + "Line": 47, "Column": 9 }, "Name": { @@ -1345,7 +1345,7 @@ "Location": { "Start": 976, "End": 985, - "Line": 46, + "Line": 47, "Column": 9 }, "Value": "argument" @@ -1358,7 +1358,7 @@ "Location": { "Start": 1006, "End": 1014, - "Line": 46, + "Line": 47, "Column": 39 }, "Name": { @@ -1366,7 +1366,7 @@ "Location": { "Start": 1006, "End": 1014, - "Line": 46, + "Line": 47, "Column": 39 }, "Value": "String" @@ -1375,7 +1375,7 @@ "Location": { "Start": 971, "End": 1014, - "Line": 46, + "Line": 47, "Column": 4 }, "Name": { @@ -1383,7 +1383,7 @@ "Location": { "Start": 971, "End": 976, - "Line": 46, + "Line": 47, "Column": 4 }, "Value": "four" @@ -1394,7 +1394,7 @@ "Location": { "Start": 941, "End": 1025, - "Line": 44, + "Line": 45, "Column": 2 }, "Name": { @@ -1402,7 +1402,7 @@ "Location": { "Start": 951, "End": 956, - "Line": 44, + "Line": 45, "Column": 12 }, "Value": "Bar" @@ -1425,7 +1425,7 @@ "Location": { "Start": 1082, "End": 1088, - "Line": 50, + "Line": 51, "Column": 24 }, "Name": { @@ -1433,7 +1433,7 @@ "Location": { "Start": 1082, "End": 1088, - "Line": 50, + "Line": 51, "Column": 24 }, "Value": "Type" @@ -1443,7 +1443,7 @@ "Location": { "Start": 1077, "End": 1094, - "Line": 50, + "Line": 51, "Column": 19 }, "Name": { @@ -1451,7 +1451,7 @@ "Location": { "Start": 1077, "End": 1081, - "Line": 50, + "Line": 51, "Column": 19 }, "Value": "arg" @@ -1462,7 +1462,7 @@ "Location": { "Start": 1087, "End": 1094, - "Line": 50, + "Line": 51, "Column": 29 }, "Name": { @@ -1470,7 +1470,7 @@ "Location": { "Start": 1088, "End": 1094, - "Line": 50, + "Line": 51, "Column": 30 }, "Value": "onArg" @@ -1485,7 +1485,7 @@ "Location": { "Start": 1096, "End": 1102, - "Line": 50, + "Line": 51, "Column": 38 }, "Name": { @@ -1493,7 +1493,7 @@ "Location": { "Start": 1096, "End": 1102, - "Line": 50, + "Line": 51, "Column": 38 }, "Value": "Type" @@ -1502,7 +1502,7 @@ "Location": { "Start": 1062, "End": 1111, - "Line": 50, + "Line": 51, "Column": 4 }, "Name": { @@ -1510,7 +1510,7 @@ "Location": { "Start": 1062, "End": 1077, - "Line": 50, + "Line": 51, "Column": 4 }, "Value": "annotatedField" @@ -1521,7 +1521,7 @@ "Location": { "Start": 1101, "End": 1111, - "Line": 50, + "Line": 51, "Column": 43 }, "Name": { @@ -1529,7 +1529,7 @@ "Location": { "Start": 1102, "End": 1111, - "Line": 50, + "Line": 51, "Column": 44 }, "Value": "onField" @@ -1542,7 +1542,7 @@ "Location": { "Start": 1016, "End": 1122, - "Line": 49, + "Line": 50, "Column": 2 }, "Name": { @@ -1550,7 +1550,7 @@ "Location": { "Start": 1026, "End": 1046, - "Line": 49, + "Line": 50, "Column": 12 }, "Value": "AnnotatedInterface" @@ -1561,7 +1561,7 @@ "Location": { "Start": 1045, "End": 1059, - "Line": 49, + "Line": 50, "Column": 31 }, "Name": { @@ -1569,7 +1569,7 @@ "Location": { "Start": 1046, "End": 1059, - "Line": 49, + "Line": 50, "Column": 32 }, "Value": "onInterface" @@ -1585,7 +1585,7 @@ "Location": { "Start": 1113, "End": 1149, - "Line": 53, + "Line": 54, "Column": 2 }, "Name": { @@ -1593,7 +1593,7 @@ "Location": { "Start": 1123, "End": 1149, - "Line": 53, + "Line": 54, "Column": 12 }, "Value": "UndefinedInterface" @@ -1615,7 +1615,7 @@ "Location": { "Start": 1191, "End": 1193, - "Line": 56, + "Line": 57, "Column": 27 }, "Type": { @@ -1623,7 +1623,7 @@ "Location": { "Start": 1182, "End": 1192, - "Line": 56, + "Line": 57, "Column": 18 }, "Name": { @@ -1631,7 +1631,7 @@ "Location": { "Start": 1182, "End": 1192, - "Line": 56, + "Line": 57, "Column": 18 }, "Value": "InputType" @@ -1642,7 +1642,7 @@ "Location": { "Start": 1172, "End": 1193, - "Line": 56, + "Line": 57, "Column": 8 }, "Name": { @@ -1650,7 +1650,7 @@ "Location": { "Start": 1172, "End": 1181, - "Line": 56, + "Line": 57, "Column": 8 }, "Value": "argument" @@ -1663,7 +1663,7 @@ "Location": { "Start": 1195, "End": 1201, - "Line": 56, + "Line": 57, "Column": 31 }, "Name": { @@ -1671,7 +1671,7 @@ "Location": { "Start": 1195, "End": 1201, - "Line": 56, + "Line": 57, "Column": 31 }, "Value": "Type" @@ -1680,7 +1680,7 @@ "Location": { "Start": 1168, "End": 1201, - "Line": 56, + "Line": 57, "Column": 4 }, "Name": { @@ -1688,7 +1688,7 @@ "Location": { "Start": 1168, "End": 1172, - "Line": 56, + "Line": 57, "Column": 4 }, "Value": "two" @@ -1699,7 +1699,7 @@ "Location": { "Start": 1143, "End": 1209, - "Line": 55, + "Line": 56, "Column": 2 }, "Name": { @@ -1707,7 +1707,7 @@ "Location": { "Start": 1160, "End": 1165, - "Line": 55, + "Line": 56, "Column": 19 }, "Value": "Bar" @@ -1720,7 +1720,7 @@ "Location": { "Start": 1203, "End": 1243, - "Line": 59, + "Line": 60, "Column": 2 }, "Name": { @@ -1728,7 +1728,7 @@ "Location": { "Start": 1220, "End": 1225, - "Line": 59, + "Line": 60, "Column": 19 }, "Value": "Bar" @@ -1739,7 +1739,7 @@ "Location": { "Start": 1224, "End": 1243, - "Line": 59, + "Line": 60, "Column": 23 }, "Name": { @@ -1747,7 +1747,7 @@ "Location": { "Start": 1225, "End": 1243, - "Line": 59, + "Line": 60, "Column": 24 }, "Value": "onInterface" @@ -1765,7 +1765,7 @@ "Location": { "Start": 1251, "End": 1258, - "Line": 61, + "Line": 62, "Column": 15 }, "Name": { @@ -1773,7 +1773,7 @@ "Location": { "Start": 1251, "End": 1258, - "Line": 61, + "Line": 62, "Column": 15 }, "Value": "Story" @@ -1784,7 +1784,7 @@ "Location": { "Start": 1259, "End": 1268, - "Line": 61, + "Line": 62, "Column": 23 }, "Name": { @@ -1792,7 +1792,7 @@ "Location": { "Start": 1259, "End": 1268, - "Line": 61, + "Line": 62, "Column": 23 }, "Value": "Article" @@ -1803,7 +1803,7 @@ "Location": { "Start": 1269, "End": 1282, - "Line": 61, + "Line": 62, "Column": 33 }, "Name": { @@ -1811,7 +1811,7 @@ "Location": { "Start": 1269, "End": 1282, - "Line": 61, + "Line": 62, "Column": 33 }, "Value": "Advert" @@ -1821,7 +1821,7 @@ "Location": { "Start": 1238, "End": 1282, - "Line": 61, + "Line": 62, "Column": 2 }, "Name": { @@ -1829,7 +1829,7 @@ "Location": { "Start": 1244, "End": 1250, - "Line": 61, + "Line": 62, "Column": 8 }, "Value": "Feed" @@ -1845,7 +1845,7 @@ "Location": { "Start": 1309, "End": 1312, - "Line": 63, + "Line": 64, "Column": 34 }, "Name": { @@ -1853,7 +1853,7 @@ "Location": { "Start": 1309, "End": 1312, - "Line": 63, + "Line": 64, "Column": 34 }, "Value": "A" @@ -1864,7 +1864,7 @@ "Location": { "Start": 1313, "End": 1321, - "Line": 63, + "Line": 64, "Column": 38 }, "Name": { @@ -1872,7 +1872,7 @@ "Location": { "Start": 1313, "End": 1321, - "Line": 63, + "Line": 64, "Column": 38 }, "Value": "B" @@ -1882,7 +1882,7 @@ "Location": { "Start": 1277, "End": 1321, - "Line": 63, + "Line": 64, "Column": 2 }, "Name": { @@ -1890,7 +1890,7 @@ "Location": { "Start": 1283, "End": 1299, - "Line": 63, + "Line": 64, "Column": 8 }, "Value": "AnnotatedUnion" @@ -1901,7 +1901,7 @@ "Location": { "Start": 1298, "End": 1308, - "Line": 63, + "Line": 64, "Column": 23 }, "Name": { @@ -1909,7 +1909,7 @@ "Location": { "Start": 1299, "End": 1308, - "Line": 63, + "Line": 64, "Column": 24 }, "Value": "onUnion" @@ -1927,7 +1927,7 @@ "Location": { "Start": 1353, "End": 1356, - "Line": 65, + "Line": 66, "Column": 39 }, "Name": { @@ -1935,7 +1935,7 @@ "Location": { "Start": 1353, "End": 1356, - "Line": 65, + "Line": 66, "Column": 39 }, "Value": "A" @@ -1946,7 +1946,7 @@ "Location": { "Start": 1357, "End": 1365, - "Line": 65, + "Line": 66, "Column": 43 }, "Name": { @@ -1954,7 +1954,7 @@ "Location": { "Start": 1357, "End": 1365, - "Line": 65, + "Line": 66, "Column": 43 }, "Value": "B" @@ -1964,7 +1964,7 @@ "Location": { "Start": 1316, "End": 1365, - "Line": 65, + "Line": 66, "Column": 2 }, "Name": { @@ -1972,7 +1972,7 @@ "Location": { "Start": 1322, "End": 1341, - "Line": 65, + "Line": 66, "Column": 8 }, "Value": "AnnotatedUnionTwo" @@ -1983,7 +1983,7 @@ "Location": { "Start": 1340, "End": 1350, - "Line": 65, + "Line": 66, "Column": 26 }, "Name": { @@ -1991,7 +1991,7 @@ "Location": { "Start": 1341, "End": 1350, - "Line": 65, + "Line": 66, "Column": 27 }, "Value": "onUnion" @@ -2007,7 +2007,7 @@ "Location": { "Start": 1360, "End": 1388, - "Line": 67, + "Line": 68, "Column": 2 }, "Name": { @@ -2015,7 +2015,7 @@ "Location": { "Start": 1366, "End": 1388, - "Line": 67, + "Line": 68, "Column": 8 }, "Value": "UndefinedUnion" @@ -2030,7 +2030,7 @@ "Location": { "Start": 1402, "End": 1409, - "Line": 69, + "Line": 70, "Column": 22 }, "Name": { @@ -2038,7 +2038,7 @@ "Location": { "Start": 1402, "End": 1409, - "Line": 69, + "Line": 70, "Column": 22 }, "Value": "Photo" @@ -2049,7 +2049,7 @@ "Location": { "Start": 1410, "End": 1423, - "Line": 69, + "Line": 70, "Column": 30 }, "Name": { @@ -2057,7 +2057,7 @@ "Location": { "Start": 1410, "End": 1423, - "Line": 69, + "Line": 70, "Column": 30 }, "Value": "Video" @@ -2067,7 +2067,7 @@ "Location": { "Start": 1382, "End": 1423, - "Line": 69, + "Line": 70, "Column": 2 }, "Name": { @@ -2075,7 +2075,7 @@ "Location": { "Start": 1395, "End": 1401, - "Line": 69, + "Line": 70, "Column": 15 }, "Value": "Feed" @@ -2088,7 +2088,7 @@ "Location": { "Start": 1417, "End": 1451, - "Line": 71, + "Line": 72, "Column": 2 }, "Name": { @@ -2096,7 +2096,7 @@ "Location": { "Start": 1430, "End": 1436, - "Line": 71, + "Line": 72, "Column": 15 }, "Value": "Feed" @@ -2107,7 +2107,7 @@ "Location": { "Start": 1435, "End": 1451, - "Line": 71, + "Line": 72, "Column": 20 }, "Name": { @@ -2115,7 +2115,7 @@ "Location": { "Start": 1436, "End": 1451, - "Line": 71, + "Line": 72, "Column": 21 }, "Value": "onUnion" @@ -2130,7 +2130,7 @@ "Location": { "Start": 1445, "End": 1472, - "Line": 73, + "Line": 74, "Column": 2 }, "Name": { @@ -2138,7 +2138,7 @@ "Location": { "Start": 1452, "End": 1472, - "Line": 73, + "Line": 74, "Column": 9 }, "Value": "CustomScalar" @@ -2151,7 +2151,7 @@ "Location": { "Start": 1466, "End": 1506, - "Line": 75, + "Line": 76, "Column": 2 }, "Name": { @@ -2159,7 +2159,7 @@ "Location": { "Start": 1473, "End": 1490, - "Line": 75, + "Line": 76, "Column": 9 }, "Value": "AnnotatedScalar" @@ -2170,7 +2170,7 @@ "Location": { "Start": 1489, "End": 1506, - "Line": 75, + "Line": 76, "Column": 25 }, "Name": { @@ -2178,7 +2178,7 @@ "Location": { "Start": 1490, "End": 1506, - "Line": 75, + "Line": 76, "Column": 26 }, "Value": "onScalar" @@ -2192,7 +2192,7 @@ "Location": { "Start": 1500, "End": 1542, - "Line": 77, + "Line": 78, "Column": 2 }, "Name": { @@ -2200,7 +2200,7 @@ "Location": { "Start": 1514, "End": 1528, - "Line": 77, + "Line": 78, "Column": 16 }, "Value": "CustomScalar" @@ -2211,7 +2211,7 @@ "Location": { "Start": 1527, "End": 1542, - "Line": 77, + "Line": 78, "Column": 29 }, "Name": { @@ -2219,7 +2219,7 @@ "Location": { "Start": 1528, "End": 1542, - "Line": 77, + "Line": 78, "Column": 30 }, "Value": "onScalar" @@ -2238,7 +2238,7 @@ "Location": { "Start": 1552, "End": 1568, - "Line": 80, + "Line": 81, "Column": 4 }, "Name": { @@ -2246,7 +2246,7 @@ "Location": { "Start": 1552, "End": 1568, - "Line": 80, + "Line": 81, "Column": 4 }, "Value": "DESKTOP" @@ -2259,7 +2259,7 @@ "Location": { "Start": 1562, "End": 1570, - "Line": 81, + "Line": 82, "Column": 4 }, "Name": { @@ -2267,7 +2267,7 @@ "Location": { "Start": 1562, "End": 1570, - "Line": 81, + "Line": 82, "Column": 4 }, "Value": "MOBILE" @@ -2278,7 +2278,7 @@ "Location": { "Start": 1538, "End": 1576, - "Line": 79, + "Line": 80, "Column": 2 }, "Name": { @@ -2286,7 +2286,7 @@ "Location": { "Start": 1543, "End": 1549, - "Line": 79, + "Line": 80, "Column": 7 }, "Value": "Site" @@ -2303,7 +2303,7 @@ "Location": { "Start": 1603, "End": 1645, - "Line": 85, + "Line": 86, "Column": 4 }, "Name": { @@ -2311,7 +2311,7 @@ "Location": { "Start": 1603, "End": 1620, - "Line": 85, + "Line": 86, "Column": 4 }, "Value": "ANNOTATED_VALUE" @@ -2322,7 +2322,7 @@ "Location": { "Start": 1619, "End": 1645, - "Line": 85, + "Line": 86, "Column": 20 }, "Name": { @@ -2330,7 +2330,7 @@ "Location": { "Start": 1620, "End": 1645, - "Line": 85, + "Line": 86, "Column": 21 }, "Value": "onEnumValue" @@ -2345,7 +2345,7 @@ "Location": { "Start": 1634, "End": 1647, - "Line": 86, + "Line": 87, "Column": 4 }, "Name": { @@ -2353,7 +2353,7 @@ "Location": { "Start": 1634, "End": 1647, - "Line": 86, + "Line": 87, "Column": 4 }, "Value": "OTHER_VALUE" @@ -2364,7 +2364,7 @@ "Location": { "Start": 1572, "End": 1653, - "Line": 84, + "Line": 85, "Column": 2 }, "Name": { @@ -2372,7 +2372,7 @@ "Location": { "Start": 1577, "End": 1592, - "Line": 84, + "Line": 85, "Column": 7 }, "Value": "AnnotatedEnum" @@ -2383,7 +2383,7 @@ "Location": { "Start": 1591, "End": 1600, - "Line": 84, + "Line": 85, "Column": 21 }, "Name": { @@ -2391,7 +2391,7 @@ "Location": { "Start": 1592, "End": 1600, - "Line": 84, + "Line": 85, "Column": 22 }, "Value": "onEnum" @@ -2407,7 +2407,7 @@ "Location": { "Start": 1649, "End": 1675, - "Line": 89, + "Line": 90, "Column": 2 }, "Name": { @@ -2415,7 +2415,7 @@ "Location": { "Start": 1654, "End": 1675, - "Line": 89, + "Line": 90, "Column": 7 }, "Value": "UndefinedEnum" @@ -2431,7 +2431,7 @@ "Location": { "Start": 1690, "End": 1694, - "Line": 92, + "Line": 93, "Column": 4 }, "Name": { @@ -2439,7 +2439,7 @@ "Location": { "Start": 1690, "End": 1694, - "Line": 92, + "Line": 93, "Column": 4 }, "Value": "VR" @@ -2450,7 +2450,7 @@ "Location": { "Start": 1669, "End": 1702, - "Line": 91, + "Line": 92, "Column": 2 }, "Name": { @@ -2458,7 +2458,7 @@ "Location": { "Start": 1681, "End": 1687, - "Line": 91, + "Line": 92, "Column": 14 }, "Value": "Site" @@ -2471,7 +2471,7 @@ "Location": { "Start": 1696, "End": 1727, - "Line": 95, + "Line": 96, "Column": 2 }, "Name": { @@ -2479,7 +2479,7 @@ "Location": { "Start": 1708, "End": 1714, - "Line": 95, + "Line": 96, "Column": 14 }, "Value": "Site" @@ -2490,7 +2490,7 @@ "Location": { "Start": 1713, "End": 1727, - "Line": 95, + "Line": 96, "Column": 19 }, "Name": { @@ -2498,7 +2498,7 @@ "Location": { "Start": 1714, "End": 1727, - "Line": 95, + "Line": 96, "Column": 20 }, "Value": "onEnum" @@ -2519,7 +2519,7 @@ "Location": { "Start": 1753, "End": 1763, - "Line": 98, + "Line": 99, "Column": 15 }, "Type": { @@ -2527,7 +2527,7 @@ "Location": { "Start": 1747, "End": 1754, - "Line": 98, + "Line": 99, "Column": 9 }, "Name": { @@ -2535,7 +2535,7 @@ "Location": { "Start": 1747, "End": 1754, - "Line": 98, + "Line": 99, "Column": 9 }, "Value": "String" @@ -2546,7 +2546,7 @@ "Location": { "Start": 1742, "End": 1763, - "Line": 98, + "Line": 99, "Column": 4 }, "Name": { @@ -2554,7 +2554,7 @@ "Location": { "Start": 1742, "End": 1746, - "Line": 98, + "Line": 99, "Column": 4 }, "Value": "key" @@ -2569,7 +2569,7 @@ "Location": { "Start": 1765, "End": 1770, - "Line": 99, + "Line": 100, "Column": 12 }, "Name": { @@ -2577,7 +2577,7 @@ "Location": { "Start": 1765, "End": 1770, - "Line": 99, + "Line": 100, "Column": 12 }, "Value": "Int" @@ -2588,7 +2588,7 @@ "Location": { "Start": 1771, "End": 1775, - "Line": 99, + "Line": 100, "Column": 18 }, "Value": "42" @@ -2596,7 +2596,7 @@ "Location": { "Start": 1757, "End": 1775, - "Line": 99, + "Line": 100, "Column": 4 }, "Name": { @@ -2604,7 +2604,7 @@ "Location": { "Start": 1757, "End": 1764, - "Line": 99, + "Line": 100, "Column": 4 }, "Value": "answer" @@ -2615,7 +2615,7 @@ "Location": { "Start": 1722, "End": 1782, - "Line": 97, + "Line": 98, "Column": 2 }, "Name": { @@ -2623,7 +2623,7 @@ "Location": { "Start": 1728, "End": 1739, - "Line": 97, + "Line": 98, "Column": 8 }, "Value": "InputType" @@ -2642,7 +2642,7 @@ "Location": { "Start": 1833, "End": 1839, - "Line": 103, + "Line": 104, "Column": 20 }, "Name": { @@ -2650,7 +2650,7 @@ "Location": { "Start": 1833, "End": 1839, - "Line": 103, + "Line": 104, "Column": 20 }, "Value": "Type" @@ -2660,7 +2660,7 @@ "Location": { "Start": 1817, "End": 1848, - "Line": 103, + "Line": 104, "Column": 4 }, "Name": { @@ -2668,7 +2668,7 @@ "Location": { "Start": 1817, "End": 1832, - "Line": 103, + "Line": 104, "Column": 4 }, "Value": "annotatedField" @@ -2679,7 +2679,7 @@ "Location": { "Start": 1838, "End": 1848, - "Line": 103, + "Line": 104, "Column": 25 }, "Name": { @@ -2687,7 +2687,7 @@ "Location": { "Start": 1839, "End": 1848, - "Line": 103, + "Line": 104, "Column": 26 }, "Value": "onField" @@ -2700,7 +2700,7 @@ "Location": { "Start": 1777, "End": 1855, - "Line": 102, + "Line": 103, "Column": 2 }, "Name": { @@ -2708,7 +2708,7 @@ "Location": { "Start": 1783, "End": 1799, - "Line": 102, + "Line": 103, "Column": 8 }, "Value": "AnnotatedInput" @@ -2719,7 +2719,7 @@ "Location": { "Start": 1798, "End": 1814, - "Line": 102, + "Line": 103, "Column": 23 }, "Name": { @@ -2727,7 +2727,7 @@ "Location": { "Start": 1799, "End": 1814, - "Line": 102, + "Line": 103, "Column": 24 }, "Value": "onInputObject" @@ -2743,7 +2743,7 @@ "Location": { "Start": 1850, "End": 1878, - "Line": 106, + "Line": 107, "Column": 2 }, "Name": { @@ -2751,7 +2751,7 @@ "Location": { "Start": 1856, "End": 1878, - "Line": 106, + "Line": 107, "Column": 8 }, "Value": "UndefinedInput" @@ -2769,7 +2769,7 @@ "Location": { "Start": 1906, "End": 1913, - "Line": 109, + "Line": 110, "Column": 11 }, "Name": { @@ -2777,7 +2777,7 @@ "Location": { "Start": 1906, "End": 1913, - "Line": 109, + "Line": 110, "Column": 11 }, "Value": "Float" @@ -2788,7 +2788,7 @@ "Location": { "Start": 1914, "End": 1922, - "Line": 109, + "Line": 110, "Column": 19 }, "Value": "1.23e4" @@ -2796,7 +2796,7 @@ "Location": { "Start": 1899, "End": 1922, - "Line": 109, + "Line": 110, "Column": 4 }, "Name": { @@ -2804,7 +2804,7 @@ "Location": { "Start": 1899, "End": 1905, - "Line": 109, + "Line": 110, "Column": 4 }, "Value": "other" @@ -2815,7 +2815,7 @@ "Location": { "Start": 1872, "End": 1930, - "Line": 108, + "Line": 109, "Column": 2 }, "Name": { @@ -2823,7 +2823,7 @@ "Location": { "Start": 1885, "End": 1896, - "Line": 108, + "Line": 109, "Column": 15 }, "Value": "InputType" @@ -2836,7 +2836,7 @@ "Location": { "Start": 1924, "End": 1972, - "Line": 112, + "Line": 113, "Column": 2 }, "Name": { @@ -2844,7 +2844,7 @@ "Location": { "Start": 1937, "End": 1948, - "Line": 112, + "Line": 113, "Column": 15 }, "Value": "InputType" @@ -2855,7 +2855,7 @@ "Location": { "Start": 1947, "End": 1972, - "Line": 112, + "Line": 113, "Column": 25 }, "Name": { @@ -2863,7 +2863,7 @@ "Location": { "Start": 1948, "End": 1972, - "Line": 112, + "Line": 113, "Column": 26 }, "Value": "onInputObject" @@ -2877,7 +2877,7 @@ "Location": { "Start": 1963, "End": 2048, - "Line": 114, + "Line": 115, "Column": 2 }, "Name": { @@ -2885,7 +2885,7 @@ "Location": { "Start": 1974, "End": 1979, - "Line": 114, + "Line": 115, "Column": 13 }, "Value": "skip" @@ -2902,7 +2902,7 @@ "Location": { "Start": 1990, "End": 1992, - "Line": 114, + "Line": 115, "Column": 29 }, "Type": { @@ -2910,7 +2910,7 @@ "Location": { "Start": 1983, "End": 1991, - "Line": 114, + "Line": 115, "Column": 22 }, "Name": { @@ -2918,7 +2918,7 @@ "Location": { "Start": 1983, "End": 1991, - "Line": 114, + "Line": 115, "Column": 22 }, "Value": "Boolean" @@ -2929,7 +2929,7 @@ "Location": { "Start": 1979, "End": 1992, - "Line": 114, + "Line": 115, "Column": 18 }, "Name": { @@ -2937,7 +2937,7 @@ "Location": { "Start": 1979, "End": 1982, - "Line": 114, + "Line": 115, "Column": 18 }, "Value": "if" @@ -2951,7 +2951,7 @@ "Location": { "Start": 1996, "End": 2003, - "Line": 114, + "Line": 115, "Column": 35 }, "Value": "FIELD" @@ -2961,7 +2961,7 @@ "Location": { "Start": 2004, "End": 2021, - "Line": 114, + "Line": 115, "Column": 43 }, "Value": "FRAGMENT_SPREAD" @@ -2971,7 +2971,7 @@ "Location": { "Start": 2022, "End": 2048, - "Line": 114, + "Line": 115, "Column": 61 }, "Value": "INLINE_FRAGMENT" @@ -2983,7 +2983,7 @@ "Location": { "Start": 2039, "End": 2136, - "Line": 116, + "Line": 117, "Column": 2 }, "Name": { @@ -2991,7 +2991,7 @@ "Location": { "Start": 2050, "End": 2056, - "Line": 116, + "Line": 117, "Column": 13 }, "Value": "skip2" @@ -3008,7 +3008,7 @@ "Location": { "Start": 2067, "End": 2069, - "Line": 116, + "Line": 117, "Column": 30 }, "Type": { @@ -3016,7 +3016,7 @@ "Location": { "Start": 2060, "End": 2068, - "Line": 116, + "Line": 117, "Column": 23 }, "Name": { @@ -3024,7 +3024,7 @@ "Location": { "Start": 2060, "End": 2068, - "Line": 116, + "Line": 117, "Column": 23 }, "Value": "Boolean" @@ -3035,7 +3035,7 @@ "Location": { "Start": 2056, "End": 2069, - "Line": 116, + "Line": 117, "Column": 19 }, "Name": { @@ -3043,7 +3043,7 @@ "Location": { "Start": 2056, "End": 2059, - "Line": 116, + "Line": 117, "Column": 19 }, "Value": "if" @@ -3057,7 +3057,7 @@ "Location": { "Start": 2084, "End": 2091, - "Line": 116, + "Line": 117, "Column": 47 }, "Value": "FIELD" @@ -3067,7 +3067,7 @@ "Location": { "Start": 2092, "End": 2109, - "Line": 116, + "Line": 117, "Column": 55 }, "Value": "FRAGMENT_SPREAD" @@ -3077,7 +3077,7 @@ "Location": { "Start": 2110, "End": 2136, - "Line": 116, + "Line": 117, "Column": 73 }, "Value": "INLINE_FRAGMENT" @@ -3089,7 +3089,7 @@ "Location": { "Start": 2127, "End": 2223, - "Line": 118, + "Line": 119, "Column": 2 }, "Name": { @@ -3097,7 +3097,7 @@ "Location": { "Start": 2138, "End": 2146, - "Line": 118, + "Line": 119, "Column": 13 }, "Value": "include" @@ -3114,7 +3114,7 @@ "Location": { "Start": 2157, "End": 2159, - "Line": 118, + "Line": 119, "Column": 32 }, "Type": { @@ -3122,7 +3122,7 @@ "Location": { "Start": 2150, "End": 2158, - "Line": 118, + "Line": 119, "Column": 25 }, "Name": { @@ -3130,7 +3130,7 @@ "Location": { "Start": 2150, "End": 2158, - "Line": 118, + "Line": 119, "Column": 25 }, "Value": "Boolean" @@ -3141,7 +3141,7 @@ "Location": { "Start": 2146, "End": 2159, - "Line": 118, + "Line": 119, "Column": 21 }, "Name": { @@ -3149,7 +3149,7 @@ "Location": { "Start": 2146, "End": 2149, - "Line": 118, + "Line": 119, "Column": 21 }, "Value": "if" @@ -3163,7 +3163,7 @@ "Location": { "Start": 2165, "End": 2175, - "Line": 119, + "Line": 120, "Column": 7 }, "Value": "FIELD" @@ -3173,7 +3173,7 @@ "Location": { "Start": 2176, "End": 2196, - "Line": 120, + "Line": 121, "Column": 7 }, "Value": "FRAGMENT_SPREAD" @@ -3183,7 +3183,7 @@ "Location": { "Start": 2197, "End": 2223, - "Line": 121, + "Line": 122, "Column": 7 }, "Value": "INLINE_FRAGMENT" @@ -3195,7 +3195,7 @@ "Location": { "Start": 2214, "End": 2308, - "Line": 123, + "Line": 124, "Column": 2 }, "Name": { @@ -3203,7 +3203,7 @@ "Location": { "Start": 2225, "End": 2234, - "Line": 123, + "Line": 124, "Column": 13 }, "Value": "include2" @@ -3220,7 +3220,7 @@ "Location": { "Start": 2245, "End": 2247, - "Line": 123, + "Line": 124, "Column": 33 }, "Type": { @@ -3228,7 +3228,7 @@ "Location": { "Start": 2238, "End": 2246, - "Line": 123, + "Line": 124, "Column": 26 }, "Name": { @@ -3236,7 +3236,7 @@ "Location": { "Start": 2238, "End": 2246, - "Line": 123, + "Line": 124, "Column": 26 }, "Value": "Boolean" @@ -3247,7 +3247,7 @@ "Location": { "Start": 2234, "End": 2247, - "Line": 123, + "Line": 124, "Column": 22 }, "Name": { @@ -3255,7 +3255,7 @@ "Location": { "Start": 2234, "End": 2237, - "Line": 123, + "Line": 124, "Column": 22 }, "Value": "if" @@ -3269,7 +3269,7 @@ "Location": { "Start": 2255, "End": 2264, - "Line": 124, + "Line": 125, "Column": 6 }, "Value": "FIELD" @@ -3279,7 +3279,7 @@ "Location": { "Start": 2265, "End": 2284, - "Line": 125, + "Line": 126, "Column": 6 }, "Value": "FRAGMENT_SPREAD" @@ -3289,7 +3289,7 @@ "Location": { "Start": 2285, "End": 2308, - "Line": 126, + "Line": 127, "Column": 6 }, "Value": "INLINE_FRAGMENT" @@ -3301,7 +3301,7 @@ "Location": { "Start": 2302, "End": 2333, - "Line": 128, + "Line": 129, "Column": 2 }, "Directives": [ @@ -3310,7 +3310,7 @@ "Location": { "Start": 2316, "End": 2333, - "Line": 128, + "Line": 129, "Column": 16 }, "Name": { @@ -3318,7 +3318,7 @@ "Location": { "Start": 2317, "End": 2333, - "Line": 128, + "Line": 129, "Column": 17 }, "Value": "onSchema" @@ -3333,7 +3333,7 @@ "Location": { "Start": 2327, "End": 2388, - "Line": 130, + "Line": 131, "Column": 2 }, "Directives": [ @@ -3342,7 +3342,7 @@ "Location": { "Start": 2341, "End": 2352, - "Line": 130, + "Line": 131, "Column": 16 }, "Name": { @@ -3350,7 +3350,7 @@ "Location": { "Start": 2342, "End": 2352, - "Line": 130, + "Line": 131, "Column": 17 }, "Value": "onSchema" @@ -3364,7 +3364,7 @@ "Location": { "Start": 2355, "End": 2387, - "Line": 131, + "Line": 132, "Column": 4 }, "Operation": "Subscription", @@ -3373,7 +3373,7 @@ "Location": { "Start": 2369, "End": 2387, - "Line": 131, + "Line": 132, "Column": 18 }, "Name": { @@ -3381,7 +3381,7 @@ "Location": { "Start": 2369, "End": 2387, - "Line": 131, + "Line": 132, "Column": 18 }, "Value": "SubscriptionType" diff --git a/src/Core/Language.Tests/Utf8/__snapshots__/Utf8ReaderTests.Read_BlockStringValue.snap b/src/Core/Language.Tests/Utf8/__snapshots__/Utf8ReaderTests.Read_BlockStringValue.snap index 5fd288cbd62..d94b072013f 100644 --- a/src/Core/Language.Tests/Utf8/__snapshots__/Utf8ReaderTests.Read_BlockStringValue.snap +++ b/src/Core/Language.Tests/Utf8/__snapshots__/Utf8ReaderTests.Read_BlockStringValue.snap @@ -45,14 +45,14 @@ "Kind": "RightParenthesis", "Start": 27, "End": 28, - "Line": 2, + "Line": 3, "Column": 1 }, { "Kind": "RightBrace", "Start": 29, "End": 30, - "Line": 2, + "Line": 3, "Column": 3 } ] diff --git a/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs b/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs index 8b9f87a7822..6419e8bc248 100644 --- a/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs +++ b/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs @@ -6,8 +6,10 @@ static GraphQLConstants() { InitializeIsControlCharacterCache(); InitializeIsEscapeCharacterCache(); + InitializeEscapeCharacterCache(); InitializeIsWhitespaceCache(); InitializeIsPunctuatorCache(); + InitializeIsLetterCache(); InitializeIsLetterOrUnderscoreCache(); InitializeIsLetterOrDigitOUnderscoreCache(); InitializeIsDigitOrMinusCache(); @@ -19,10 +21,12 @@ private static void InitializeIsControlCharacterCache() { _isControlCharacter[i] = true; } + for (int i = 10; i <= 31; i++) { _isControlCharacter[i] = true; } + _isControlCharacter[127] = true; } @@ -38,6 +42,21 @@ private static void InitializeIsEscapeCharacterCache() _isEscapeCharacter['t'] = true; } + private static void InitializeEscapeCharacterCache() + { + for (int i = 0; i < 256; i++) + { + char c = (char)i; + _escapeCharacters[c] = (byte)c; + } + + _escapeCharacters[B] = Backspace; + _escapeCharacters[F] = Formfeed; + _escapeCharacters[N] = NewLine; + _escapeCharacters[R] = Return; + _escapeCharacters[T] = Tab; + } + private static void InitializeIsWhitespaceCache() { _isWhitespace['\t'] = true; @@ -45,7 +64,6 @@ private static void InitializeIsWhitespaceCache() _isWhitespace['\n'] = true; _isWhitespace[' '] = true; _isWhitespace[','] = true; - _isWhitespace[0xfeff] = true; } private static void InitializeIsPunctuatorCache() @@ -66,6 +84,19 @@ private static void InitializeIsPunctuatorCache() _isPunctuator['.'] = true; } + private static void InitializeIsLetterCache() + { + for (char c = 'a'; c <= 'z'; c++) + { + _isLetter[c] = true; + } + + for (char c = 'A'; c <= 'Z'; c++) + { + _isLetter[c] = true; + } + } + private static void InitializeIsLetterOrUnderscoreCache() { for (char c = 'a'; c <= 'z'; c++) diff --git a/src/Core/Language/Utf8/GraphQLConstants.cs b/src/Core/Language/Utf8/GraphQLConstants.cs index 9bc9e9ec24e..032cb391b8e 100644 --- a/src/Core/Language/Utf8/GraphQLConstants.cs +++ b/src/Core/Language/Utf8/GraphQLConstants.cs @@ -1,3 +1,5 @@ +using System.Runtime.CompilerServices; + namespace HotChocolate.Language { /// @@ -7,20 +9,24 @@ namespace HotChocolate.Language /// internal static partial class GraphQLConstants { + private static readonly bool[] _isLetter = + new bool[256]; private static readonly bool[] _isLetterOrUnderscore = - new bool[char.MaxValue + 1]; + new bool[256]; private static readonly bool[] _isLetterOrDigitOrUnderscore = - new bool[char.MaxValue + 1]; + new bool[256]; private static readonly bool[] _isControlCharacter = - new bool[char.MaxValue + 1]; + new bool[256]; private static readonly bool[] _isEscapeCharacter = - new bool[char.MaxValue + 1]; + new bool[256]; private static readonly bool[] _isWhitespace = - new bool[char.MaxValue + 1]; + new bool[256]; private static readonly bool[] _isPunctuator = - new bool[char.MaxValue + 1]; + new bool[256]; private static readonly bool[] _isDigitOrMinus = - new bool[char.MaxValue + 1]; + new bool[256]; + private static readonly byte[] _escapeCharacters = + new byte[256]; public const int StackallocThreshold = 256; @@ -31,6 +37,7 @@ internal static partial class GraphQLConstants public const byte Plus = (byte)'+'; public const byte Minus = (byte)'-'; public const byte Backslash = (byte)'\\'; + public const byte Forwardslash = (byte)'/'; public const byte B = (byte)'b'; public const byte Backspace = (byte)'\b'; public const byte F = (byte)'f'; @@ -63,66 +70,61 @@ internal static partial class GraphQLConstants public const byte Return = (byte)'\r'; public const byte Quote = (byte)'"'; - public static bool IsLetterOrDigitOrUnderscore(this byte c) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool IsLetter(this byte c) { - return _isLetterOrDigitOrUnderscore[c]; + return _isLetter[c]; } - public static bool IsLetter(this byte c) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool IsLetterOrDigitOrUnderscore(this byte c) { - byte normalized = (byte)(c | 0x20); - return (normalized >= A && normalized <= Z); + return _isLetterOrDigitOrUnderscore[c]; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsLetterOrUnderscore(this byte c) { return _isLetterOrUnderscore[c]; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsDigit(this byte c) { return c >= 48 && c <= 57; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsDigitOrMinus(this byte c) { return _isDigitOrMinus[c]; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsPunctuator(this byte c) { return _isPunctuator[c]; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsWhitespace(this byte c) { return _isWhitespace[c]; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsValidEscapeCharacter(this byte c) { return _isEscapeCharacter[c]; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte EscapeCharacter(this byte c) { - switch (c) - { - case B: - return Backspace; - case F: - return Formfeed; - case N: - return NewLine; - case R: - return Return; - case T: - return Tab; - default: - return c; - } + return _escapeCharacters[c]; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsControlCharacter(this byte c) { return _isControlCharacter[c]; diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs new file mode 100644 index 00000000000..389ec661dfd --- /dev/null +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs @@ -0,0 +1,126 @@ +using System.Buffers; +using System; +using System.Runtime.CompilerServices; +using System.Globalization; +using HotChocolate.Language.Properties; + +namespace HotChocolate.Language +{ + public ref partial struct Utf8GraphQLReader + { + public unsafe string GetString() + { + if (_value.Length == 0) + { + return string.Empty; + } + + bool isBlockString = _kind == TokenKind.BlockString; + + int length = checked((int)_value.Length); + bool useStackalloc = + length <= GraphQLConstants.StackallocThreshold; + + byte[] unescapedArray = null; + + Span unescapedSpan = useStackalloc + ? stackalloc byte[length] + : (unescapedArray = ArrayPool.Shared.Rent(length)); + + try + { + UnescapeValue(_value, ref unescapedSpan, isBlockString); + + fixed (byte* bytePtr = unescapedSpan) + { + return StringHelper.UTF8Encoding.GetString( + bytePtr, + unescapedSpan.Length); + } + } + finally + { + if (unescapedArray != null) + { + unescapedSpan.Clear(); + ArrayPool.Shared.Return(unescapedArray); + } + } + } + + public unsafe string GetString(ReadOnlySpan unescapedValue) + { + if (unescapedValue.Length == 0) + { + return string.Empty; + } + + fixed (byte* bytePtr = unescapedValue) + { + return StringHelper.UTF8Encoding + .GetString(bytePtr, unescapedValue.Length); + } + } + + public string GetComment() + { + if (_value.Length > 0) + { + StringHelper.TrimStringToken(ref _value); + } + + return GetString(_value); + } + + public string GetName() => GetString(_value); + public string GetScalarValue() => GetString(_value); + + private static void UnescapeValue( + in ReadOnlySpan escaped, + ref Span unescapedValue, + bool isBlockString) + { + Utf8Helper.Unescape( + in escaped, + ref unescapedValue, + isBlockString); + + if (isBlockString) + { + StringHelper.TrimBlockStringToken( + unescapedValue, ref unescapedValue); + } + } + + public void UnescapeValue(ref Span unescapedValue) + { + if (_value.Length == 0) + { + unescapedValue = unescapedValue.Slice(0, 0); + } + else + { + UnescapeValue( + in _value, + ref unescapedValue, + _kind == TokenKind.BlockString); + } + } + + public bool MoveNext() + { + while (Read() && _kind == TokenKind.Comment) { } + return !IsEndOfStream(); + } + + public bool Skip(TokenKind kind) + { + if (_kind == kind) + { + MoveNext(); + return true; + } + return false; + } + } +} diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index adb88a11e93..7a699660567 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -81,126 +81,16 @@ public Utf8GraphQLReader(ReadOnlySpan graphQLData) /// public ReadOnlySpan Value => _value; - public unsafe string GetString() - { - if (_value.Length == 0) - { - return string.Empty; - } - - bool isBlockString = _kind == TokenKind.BlockString; - - int length = checked((int)_value.Length); - bool useStackalloc = - length <= GraphQLConstants.StackallocThreshold; - - byte[] unescapedArray = null; - - Span unescapedSpan = useStackalloc - ? stackalloc byte[length] - : (unescapedArray = ArrayPool.Shared.Rent(length)); - - try - { - UnescapeValue(_value, ref unescapedSpan, isBlockString); - - fixed (byte* bytePtr = unescapedSpan) - { - return StringHelper.UTF8Encoding.GetString( - bytePtr, - unescapedSpan.Length); - } - } - finally - { - if (unescapedArray != null) - { - unescapedSpan.Clear(); - ArrayPool.Shared.Return(unescapedArray); - } - } - } - - public unsafe string GetString(ReadOnlySpan unescapedValue) - { - if (unescapedValue.Length == 0) - { - return string.Empty; - } - - fixed (byte* bytePtr = unescapedValue) - { - return StringHelper.UTF8Encoding - .GetString(bytePtr, unescapedValue.Length); - } - } - - public string GetComment() - { - if (_value.Length > 0) - { - StringHelper.TrimStringToken(ref _value); - } - - return GetString(_value); - } - - public string GetName() => GetString(_value); - public string GetScalarValue() => GetString(_value); - - private static void UnescapeValue( - in ReadOnlySpan escaped, - ref Span unescapedValue, - bool isBlockString) + public bool Read() { - Utf8Helper.Unescape( - in escaped, - ref unescapedValue, - isBlockString); - - if (isBlockString) + if (_position == 0) { - StringHelper.TrimBlockStringToken( - unescapedValue, ref unescapedValue); + SkipBoml(); } - } - public void UnescapeValue(ref Span unescapedValue) - { - if (_value.Length == 0) - { - unescapedValue = unescapedValue.Slice(0, 0); - } - else + if (_position > 940) { - UnescapeValue( - in _value, - ref unescapedValue, - _kind == TokenKind.BlockString); - } - } - - public bool MoveNext() - { - while (Read() && _kind == TokenKind.Comment) { } - return !IsEndOfStream(); - } - public bool Skip(TokenKind kind) - { - if (_kind == kind) - { - MoveNext(); - return true; - } - return false; - } - - public bool Read() - { - if (_position == 0) - { - SkipBoml(); } SkipWhitespaces(); @@ -606,6 +496,7 @@ private void ReadStringValueToken() /// /// Returns the block string token read from the current lexer state. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ReadBlockStringToken() { var start = _position - 2; @@ -620,11 +511,12 @@ private void ReadBlockStringToken() && _graphQLData[_position + 1] == GraphQLConstants.Quote && _graphQLData[_position + 2] == GraphQLConstants.Quote) { - _nextNewLines--; _kind = TokenKind.BlockString; _start = start; _end = _position + 2; - _value = _graphQLData.Slice(start + 3, _position - start - 3); + _value = _graphQLData.Slice( + start + 3, + _position - start - 3); _position = _end + 1; return; } @@ -735,6 +627,14 @@ private void SkipBoml() _position += 3; } } + + if (code == 254) + { + if (_graphQLData[_position + 1] == 255) + { + _position += 2; + } + } } /// @@ -754,6 +654,7 @@ public void NewLine() /// /// The number of lines to skip. /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void NewLine(int lines) { if (lines < 1) From 9b02651405856c48f08136e5ae2081120da8379a Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Tue, 11 Jun 2019 13:31:52 +0200 Subject: [PATCH 09/12] removed debug code --- src/Core/Language/Utf8/Utf8GraphQLReader.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index 7a699660567..c5d51889d26 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -88,11 +88,6 @@ public bool Read() SkipBoml(); } - if (_position > 940) - { - - } - SkipWhitespaces(); UpdateColumn(); From 99f03ffcf6f9a8c5c5f824fabf5442891551b78d Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Tue, 11 Jun 2019 14:05:30 +0200 Subject: [PATCH 10/12] reworked punctuator mapping --- .../Utf8/GraphQLConstants.Initialization.cs | 26 ++++ src/Core/Language/Utf8/GraphQLConstants.cs | 16 +++ .../Utf8/Utf8GraphQLReader.Utilities.cs | 6 +- src/Core/Language/Utf8/Utf8GraphQLReader.cs | 122 +++++------------- 4 files changed, 79 insertions(+), 91 deletions(-) diff --git a/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs b/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs index 6419e8bc248..8861a050959 100644 --- a/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs +++ b/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs @@ -13,6 +13,8 @@ static GraphQLConstants() InitializeIsLetterOrUnderscoreCache(); InitializeIsLetterOrDigitOUnderscoreCache(); InitializeIsDigitOrMinusCache(); + InitializeTrimComment(); + InitializePunctuator(); } private static void InitializeIsControlCharacterCache() @@ -152,5 +154,29 @@ private static void InitializeIsDigitOrMinusCache() _isDigitOrMinus['8'] = true; _isDigitOrMinus['9'] = true; } + + private static void InitializeTrimComment() + { + _trimComment[GraphQLConstants.Hash] = true; + _trimComment[GraphQLConstants.Space] = true; + _trimComment[GraphQLConstants.Tab] = true; + } + + private static void InitializePunctuator() + { + _punctuatorKind[GraphQLConstants.Bang] = TokenKind.Bang; + _punctuatorKind[GraphQLConstants.Dollar] = TokenKind.Dollar; + _punctuatorKind[GraphQLConstants.Ampersand] = TokenKind.Ampersand; + _punctuatorKind[GraphQLConstants.LeftParenthesis] = TokenKind.LeftParenthesis; + _punctuatorKind[GraphQLConstants.RightParenthesis] = TokenKind.RightParenthesis; + _punctuatorKind[GraphQLConstants.Colon] = TokenKind.Colon; + _punctuatorKind[GraphQLConstants.Equal] = TokenKind.Equal; + _punctuatorKind[GraphQLConstants.At] = TokenKind.At; + _punctuatorKind[GraphQLConstants.LeftBracket] = TokenKind.LeftBracket; + _punctuatorKind[GraphQLConstants.RightBracket] = TokenKind.RightBracket; + _punctuatorKind[GraphQLConstants.LeftBrace] = TokenKind.LeftBrace; + _punctuatorKind[GraphQLConstants.RightBrace] = TokenKind.RightBrace; + _punctuatorKind[GraphQLConstants.Pipe] = TokenKind.Pipe; + } } } diff --git a/src/Core/Language/Utf8/GraphQLConstants.cs b/src/Core/Language/Utf8/GraphQLConstants.cs index 032cb391b8e..404f2d81384 100644 --- a/src/Core/Language/Utf8/GraphQLConstants.cs +++ b/src/Core/Language/Utf8/GraphQLConstants.cs @@ -27,6 +27,10 @@ internal static partial class GraphQLConstants new bool[256]; private static readonly byte[] _escapeCharacters = new byte[256]; + private static readonly bool[] _trimComment = + new bool[256]; + private static readonly TokenKind[] _punctuatorKind = + new TokenKind[256]; public const int StackallocThreshold = 256; @@ -129,5 +133,17 @@ public static bool IsControlCharacter(this byte c) { return _isControlCharacter[c]; } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static bool TrimComment(this byte c) + { + return _trimComment[c]; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static TokenKind PunctuatorKind(this byte c) + { + return _punctuatorKind[c]; + } } } diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs index 389ec661dfd..6fc1c42687f 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs @@ -107,13 +107,15 @@ public void UnescapeValue(ref Span unescapedValue) } } - public bool MoveNext() + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal bool MoveNext() { while (Read() && _kind == TokenKind.Comment) { } return !IsEndOfStream(); } - public bool Skip(TokenKind kind) + [MethodImpl(MethodImplOptions.AggressiveInlining)] + internal bool Skip(TokenKind kind) { if (_kind == kind) { diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index c5d51889d26..25e8663a760 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -203,84 +203,27 @@ private void ReadPunctuatorToken(in byte code) _end = ++_position; _value = null; - switch (code) + if (code == GraphQLConstants.Dot) { - case GraphQLConstants.Bang: - _kind = TokenKind.Bang; - break; - - case GraphQLConstants.Dollar: - _kind = TokenKind.Dollar; - break; - - case GraphQLConstants.Ampersand: - _kind = TokenKind.Ampersand; - break; - - case GraphQLConstants.LeftParenthesis: - _kind = TokenKind.LeftParenthesis; - break; - - case GraphQLConstants.RightParenthesis: - _kind = TokenKind.RightParenthesis; - break; - - case GraphQLConstants.Colon: - _kind = TokenKind.Colon; - break; - - case GraphQLConstants.Equal: - _kind = TokenKind.Equal; - break; - - case GraphQLConstants.At: - _kind = TokenKind.At; - break; - - case GraphQLConstants.LeftBracket: - _kind = TokenKind.LeftBracket; - break; - - case GraphQLConstants.RightBracket: - _kind = TokenKind.RightBracket; - break; - - case GraphQLConstants.LeftBrace: - _kind = TokenKind.LeftBrace; - break; - - case GraphQLConstants.RightBrace: - _kind = TokenKind.RightBrace; - break; - - case GraphQLConstants.Pipe: - _kind = TokenKind.Pipe; - break; - - case GraphQLConstants.Dot: - if (_graphQLData[_position] == GraphQLConstants.Dot - && _graphQLData[_position + 1] == GraphQLConstants.Dot) - { - _position += 2; - _end = _position; - _kind = TokenKind.Spread; - } - else - { - _position--; - throw new SyntaxException(this, - string.Format(CultureInfo.InvariantCulture, - LangResources.Reader_InvalidToken, - TokenKind.Spread)); - } - break; - - default: + if (_graphQLData[_position] == GraphQLConstants.Dot + && _graphQLData[_position + 1] == GraphQLConstants.Dot) + { + _position += 2; + _end = _position; + _kind = TokenKind.Spread; + } + else + { _position--; throw new SyntaxException(this, string.Format(CultureInfo.InvariantCulture, - LangResources.Reader_UnexpectedPunctuatorToken, - code)); + LangResources.Reader_InvalidToken, + TokenKind.Spread)); + } + } + else + { + _kind = GraphQLConstants.PunctuatorKind(code); } } @@ -349,7 +292,7 @@ private void ReadNumberToken(byte firstCode) } } - if ((code | (char)0x20) == GraphQLConstants.E) + if ((code | 0x20) == GraphQLConstants.E) { isFloat = true; code = _graphQLData[++_position]; @@ -370,7 +313,7 @@ private void ReadNumberToken(byte firstCode) [MethodImpl(MethodImplOptions.AggressiveInlining)] private void ReadDigits(byte firstCode) { - if (!firstCode.IsDigit()) + if (!GraphQLConstants.IsDigit(firstCode)) { throw new SyntaxException(this, "Invalid number, expected digit but got: " + @@ -400,23 +343,24 @@ private void ReadCommentToken() var trimStart = _position + 1; bool trim = true; - while (++_position < _length - && !GraphQLConstants.IsControlCharacter( - _graphQLData[_position])) + while (++_position < _length) { + byte code = _graphQLData[_position]; + + if (GraphQLConstants.IsControlCharacter(code)) + { + break; + } + if (trim) { - switch (_graphQLData[_position]) + if (GraphQLConstants.TrimComment(code)) + { + trimStart = _position; + } + else { - case GraphQLConstants.Hash: - case GraphQLConstants.Space: - case GraphQLConstants.Tab: - trimStart = _position; - break; - - default: - trim = false; - break; + trim = false; } } } From 34cb4522409976a9fed91878250f1b4100d94ad6 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Tue, 11 Jun 2019 15:28:27 +0200 Subject: [PATCH 11/12] Reworked read digit --- src/Core/Language/SyntaxException.cs | 4 +- .../Utf8/Utf8GraphQLParser.Utilities.cs | 10 ++-- src/Core/Language/Utf8/Utf8GraphQLReader.cs | 54 +++++++++---------- 3 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/Core/Language/SyntaxException.cs b/src/Core/Language/SyntaxException.cs index 934a9cc9bdc..496198f9f0d 100644 --- a/src/Core/Language/SyntaxException.cs +++ b/src/Core/Language/SyntaxException.cs @@ -13,8 +13,8 @@ internal SyntaxException(Utf8GraphQLReader reader, string message) : base(message) { Position = reader.Position; - Line = reader._line; - Column = reader._column; + Line = reader.Line; + Column = reader.Column; SourceText = Encoding.UTF8.GetString(reader.GraphQLData.ToArray()); } diff --git a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs index c9c9a7a6ca1..6868648294c 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs @@ -30,10 +30,10 @@ private NameNode ParseName() private TokenInfo Start() => _createLocation ? new TokenInfo( - _reader._start, - _reader._end, - _reader._line, - _reader._column) + _reader.Start, + _reader.End, + _reader.Line, + _reader.Column) : default; [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -41,7 +41,7 @@ private Location CreateLocation(in TokenInfo start) => _createLocation ? new Location( start.Start, - _reader._end, + _reader.End, start.Line, start.Column) : null; diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index 25e8663a760..1fd6a97bd1f 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -8,18 +8,17 @@ namespace HotChocolate.Language { public ref partial struct Utf8GraphQLReader { - private static readonly byte _space = (byte)' '; private int _nextNewLines; private ReadOnlySpan _graphQLData; private ReadOnlySpan _value; private int _length; private int _position; private TokenKind _kind; - public int _start; - public int _end; - public int _line; - public int _lineStart; - public int _column; + private int _start; + private int _end; + private int _line; + private int _lineStart; + private int _column; public Utf8GraphQLReader(ReadOnlySpan graphQLData) { @@ -266,30 +265,14 @@ private void ReadNumberToken(byte firstCode) } else { - ReadDigits(code); - if (_position < _length) - { - code = _graphQLData[_position]; - } - else - { - code = _space; - } + code = ReadDigits(code); } if (code == GraphQLConstants.Dot) { isFloat = true; code = _graphQLData[++_position]; - ReadDigits(code); - if (_position < _length) - { - code = _graphQLData[_position]; - } - else - { - code = GraphQLConstants.Space; - } + code = ReadDigits(code); } if ((code | 0x20) == GraphQLConstants.E) @@ -311,7 +294,7 @@ private void ReadNumberToken(byte firstCode) } [MethodImpl(MethodImplOptions.AggressiveInlining)] - private void ReadDigits(byte firstCode) + private byte ReadDigits(byte firstCode) { if (!GraphQLConstants.IsDigit(firstCode)) { @@ -320,9 +303,24 @@ private void ReadDigits(byte firstCode) $"`{(char)firstCode}` ({firstCode})."); } - while (++_position < _length - && GraphQLConstants.IsDigit(_graphQLData[_position])) - { } + byte code = firstCode; + + while (true) + { + if (++_position >= _length) + { + code = GraphQLConstants.Space; + break; + } + + code = _graphQLData[_position]; + if (!GraphQLConstants.IsDigit(code)) + { + break; + } + } + + return code; } /// From 6f13f13b95d2a210ba2e70c39a620a8e17ff6681 Mon Sep 17 00:00:00 2001 From: Michael Staib Date: Tue, 11 Jun 2019 16:02:22 +0200 Subject: [PATCH 12/12] Fixed sonar issues --- .../Utf8/Utf8BlockStringTokenReaderTests.cs | 4 ++-- .../Utf8/GraphQLConstants.Initialization.cs | 14 +++++++++----- .../Language/Utf8/Utf8GraphQLParser.Utilities.cs | 2 +- .../Language/Utf8/Utf8GraphQLReader.Utilities.cs | 4 ++-- src/Core/Language/Utf8/Utf8GraphQLReader.cs | 4 +++- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/Core/Language.Tests/Utf8/Utf8BlockStringTokenReaderTests.cs b/src/Core/Language.Tests/Utf8/Utf8BlockStringTokenReaderTests.cs index c5a66061335..4e29c37e6b1 100644 --- a/src/Core/Language.Tests/Utf8/Utf8BlockStringTokenReaderTests.cs +++ b/src/Core/Language.Tests/Utf8/Utf8BlockStringTokenReaderTests.cs @@ -22,7 +22,7 @@ private void ReadToken() // assert Assert.Equal( "helloWorld_123\r\n\t\tfoo\r\n\tbar", - reader.GetString(reader.Value)); + Utf8GraphQLReader.GetString(reader.Value)); Assert.Equal( "helloWorld_123\n\tfoo\nbar", @@ -181,7 +181,7 @@ private void UnescapeString() // assert Assert.Equal(3, span.Length); - Assert.Equal("abc", reader.GetString(span)); + Assert.Equal("abc", Utf8GraphQLReader.GetString(span)); } [Fact] diff --git a/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs b/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs index 8861a050959..7c65195632d 100644 --- a/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs +++ b/src/Core/Language/Utf8/GraphQLConstants.Initialization.cs @@ -46,7 +46,7 @@ private static void InitializeIsEscapeCharacterCache() private static void InitializeEscapeCharacterCache() { - for (int i = 0; i < 256; i++) + for (int i = byte.MinValue; i <= byte.MaxValue; i++) { char c = (char)i; _escapeCharacters[c] = (byte)c; @@ -167,13 +167,17 @@ private static void InitializePunctuator() _punctuatorKind[GraphQLConstants.Bang] = TokenKind.Bang; _punctuatorKind[GraphQLConstants.Dollar] = TokenKind.Dollar; _punctuatorKind[GraphQLConstants.Ampersand] = TokenKind.Ampersand; - _punctuatorKind[GraphQLConstants.LeftParenthesis] = TokenKind.LeftParenthesis; - _punctuatorKind[GraphQLConstants.RightParenthesis] = TokenKind.RightParenthesis; + _punctuatorKind[GraphQLConstants.LeftParenthesis] = + TokenKind.LeftParenthesis; + _punctuatorKind[GraphQLConstants.RightParenthesis] = + TokenKind.RightParenthesis; _punctuatorKind[GraphQLConstants.Colon] = TokenKind.Colon; _punctuatorKind[GraphQLConstants.Equal] = TokenKind.Equal; _punctuatorKind[GraphQLConstants.At] = TokenKind.At; - _punctuatorKind[GraphQLConstants.LeftBracket] = TokenKind.LeftBracket; - _punctuatorKind[GraphQLConstants.RightBracket] = TokenKind.RightBracket; + _punctuatorKind[GraphQLConstants.LeftBracket] = + TokenKind.LeftBracket; + _punctuatorKind[GraphQLConstants.RightBracket] = + TokenKind.RightBracket; _punctuatorKind[GraphQLConstants.LeftBrace] = TokenKind.LeftBrace; _punctuatorKind[GraphQLConstants.RightBrace] = TokenKind.RightBrace; _punctuatorKind[GraphQLConstants.Pipe] = TokenKind.Pipe; diff --git a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs index 6868648294c..8b3b9032caa 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLParser.Utilities.cs @@ -151,7 +151,7 @@ private void ExpectKeyword(ReadOnlySpan keyword) throw new SyntaxException(_reader, string.Format(CultureInfo.InvariantCulture, LangResources.Parser_InvalidToken, - _reader.GetString(keyword), + Utf8GraphQLReader.GetString(keyword), found)); } } diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs index 6fc1c42687f..2d1419455b0 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.Utilities.cs @@ -17,7 +17,7 @@ public unsafe string GetString() bool isBlockString = _kind == TokenKind.BlockString; - int length = checked((int)_value.Length); + int length = checked(_value.Length); bool useStackalloc = length <= GraphQLConstants.StackallocThreshold; @@ -48,7 +48,7 @@ public unsafe string GetString() } } - public unsafe string GetString(ReadOnlySpan unescapedValue) + public unsafe static string GetString(ReadOnlySpan unescapedValue) { if (unescapedValue.Length == 0) { diff --git a/src/Core/Language/Utf8/Utf8GraphQLReader.cs b/src/Core/Language/Utf8/Utf8GraphQLReader.cs index 1fd6a97bd1f..e9e369e9ec0 100644 --- a/src/Core/Language/Utf8/Utf8GraphQLReader.cs +++ b/src/Core/Language/Utf8/Utf8GraphQLReader.cs @@ -395,7 +395,9 @@ private void ReadStringValueToken() _kind = TokenKind.String; _start = start; _end = _position; - _value = _graphQLData.Slice(start + 1, _position - start - 1); + _value = _graphQLData.Slice( + start + 1, + _position - start - 1); _position++; return; }