Quellcode durchsuchen

Rename PeekOneOrThrow back to Peek.

Jeremy Koritzinsky vor 5 Jahren
Ursprung
Commit
33fdb4d4f9

+ 3 - 3
src/Avalonia.Base/Utilities/CharacterReader.cs

@@ -16,7 +16,7 @@ namespace Avalonia.Utilities
         }
 
         public bool End => _s.IsEmpty;
-        public char PeekOneOrThrow => _s[0];
+        public char Peek => _s[0];
         public int Position { get; private set; }
         public char Take()
         {
@@ -35,7 +35,7 @@ namespace Avalonia.Utilities
 
         public bool TakeIf(char c)
         {
-            if (PeekOneOrThrow == c)
+            if (Peek == c)
             {
                 Take();
                 return true;
@@ -48,7 +48,7 @@ namespace Avalonia.Utilities
 
         public bool TakeIf(Func<char, bool> condition)
         {
-            if (condition(PeekOneOrThrow))
+            if (condition(Peek))
             {
                 Take();
                 return true;

+ 1 - 1
src/Avalonia.Base/Utilities/IdentifierParser.cs

@@ -10,7 +10,7 @@ namespace Avalonia.Utilities
     {
         public static ReadOnlySpan<char> ParseIdentifier(this ref CharacterReader r)
         {
-            if (IsValidIdentifierStart(r.PeekOneOrThrow))
+            if (IsValidIdentifierStart(r.Peek))
             {
                 return r.TakeWhile(c => IsValidIdentifierChar(c));
             }

+ 1 - 1
src/Avalonia.Base/Utilities/StyleClassParser.cs

@@ -10,7 +10,7 @@ namespace Avalonia.Utilities
     {
         public static ReadOnlySpan<char> ParseStyleClass(this ref CharacterReader r)
         {
-            if (IsValidIdentifierStart(r.PeekOneOrThrow))
+            if (IsValidIdentifierStart(r.Peek))
             {
                 return r.TakeWhile(c => IsValidIdentifierChar(c));
             }

+ 1 - 1
src/Markup/Avalonia.Markup.Xaml/Parsers/PropertyParser.cs

@@ -41,7 +41,7 @@ namespace Avalonia.Markup.Xaml.Parsers
                             throw new ExpressionParseException(r.Position, $"Expected ')'.");
                         }
 
-                        throw new ExpressionParseException(r.Position, $"Unexpected '{r.PeekOneOrThrow}'.");
+                        throw new ExpressionParseException(r.Position, $"Unexpected '{r.Peek}'.");
                     }
                 }
                 else if (!r.End && r.TakeIf(':'))

+ 1 - 1
src/Markup/Avalonia.Markup/Markup/Parsers/ArgumentListParser.cs

@@ -11,7 +11,7 @@ namespace Avalonia.Markup.Parsers
     {
         public static IList<string> ParseArguments(this ref CharacterReader r, char open, char close, char delimiter = ',')
         {
-            if (r.PeekOneOrThrow == open)
+            if (r.Peek == open)
             {
                 var result = new List<string>();
 

+ 1 - 1
src/Markup/Avalonia.Markup/Markup/Parsers/BindingExpressionGrammar.cs

@@ -290,7 +290,7 @@ namespace Avalonia.Markup.Parsers
 
         private static bool PeekOpenBracket(ref CharacterReader r)
         {
-            return !r.End && r.PeekOneOrThrow == '[';
+            return !r.End && r.Peek == '[';
         }
 
         private static bool ParseStreamOperator(ref CharacterReader r)

+ 1 - 1
src/Markup/Avalonia.Markup/Markup/Parsers/PropertyPathGrammar.cs

@@ -160,7 +160,7 @@ namespace Avalonia.Markup.Parsers
             
 
             
-            throw new ExpressionParseException(r.Position, "Unexpected character " + r.PeekOneOrThrow + " after property name");
+            throw new ExpressionParseException(r.Position, "Unexpected character " + r.Peek + " after property name");
         }
 
         private static (State, ISyntax) ParseEnsureType(ref CharacterReader r)

+ 5 - 5
src/Markup/Avalonia.Markup/Markup/Parsers/SelectorGrammar.cs

@@ -120,7 +120,7 @@ namespace Avalonia.Markup.Parsers
             {
                 return (State.Class, null);
             }
-            else if (r.TakeIf(char.IsWhiteSpace) || r.PeekOneOrThrow == '>')
+            else if (r.TakeIf(char.IsWhiteSpace) || r.Peek == '>')
             {
                 return (State.Traversal, null);
             }
@@ -136,7 +136,7 @@ namespace Avalonia.Markup.Parsers
             {
                 return (State.Start, new CommaSyntax());
             }
-            else if (end.HasValue && !r.End && r.PeekOneOrThrow == end.Value)
+            else if (end.HasValue && !r.End && r.Peek == end.Value)
             {
                 return (State.End, null);
             }
@@ -259,7 +259,7 @@ namespace Avalonia.Markup.Parsers
 
             if (!r.TakeIf('='))
             {
-                throw new ExpressionParseException(r.Position, $"Expected '=', got '{r.PeekOneOrThrow}'");
+                throw new ExpressionParseException(r.Position, $"Expected '=', got '{r.Peek}'");
             }
 
             var value = r.TakeUntil(']');
@@ -278,7 +278,7 @@ namespace Avalonia.Markup.Parsers
 
             if (namespaceOrTypeName.IsEmpty)
             {
-                throw new ExpressionParseException(r.Position, $"Expected an identifier, got '{r.PeekOneOrThrow}");
+                throw new ExpressionParseException(r.Position, $"Expected an identifier, got '{r.Peek}");
             }
 
             if (!r.End && r.TakeIf('|'))
@@ -308,7 +308,7 @@ namespace Avalonia.Markup.Parsers
             }
             else if (!r.TakeIf(')'))
             {
-                throw new ExpressionParseException(r.Position, $"Expected '{c}', got '{r.PeekOneOrThrow}'.");
+                throw new ExpressionParseException(r.Position, $"Expected '{c}', got '{r.Peek}'.");
             }
         }