From 1796fb9403fb6d38c0228d8c56cb6b40e14a1165 Mon Sep 17 00:00:00 2001
From: dgelessus <dgelessus@users.noreply.github.com>
Date: Thu, 20 Jul 2023 17:29:09 +0200
Subject: [PATCH] Deprecate Lexer.nextList and related code

---
 src/main/java/org/sablecc/sablecc/lexer/Lexer.java | 12 ++++++++++++
 src/main/resources/org/sablecc/sablecc/lexer.txt   | 12 ++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/src/main/java/org/sablecc/sablecc/lexer/Lexer.java b/src/main/java/org/sablecc/sablecc/lexer/Lexer.java
index a687900..2cd749c 100644
--- a/src/main/java/org/sablecc/sablecc/lexer/Lexer.java
+++ b/src/main/java/org/sablecc/sablecc/lexer/Lexer.java
@@ -27,8 +27,14 @@ public class Lexer
     private boolean eof;
     private final StringBuilder text = new StringBuilder();
 
+    @Deprecated
     private final Queue<IToken> nextList = new LinkedList<IToken>();
 
+    /**
+     * @deprecated Use {@link #token} to get, modify, replace, and/or delete the current token.
+     *     Injecting new tokens into the token stream will not be supported in the future.
+     */
+    @Deprecated
     public Queue<IToken> getNextList() {
         return nextList;
     }
@@ -38,6 +44,10 @@ public class Lexer
         // Do nothing
     }
 
+    /**
+     * @deprecated Override {@link #filter()} instead.
+     */
+    @Deprecated
     protected void filterWrap() throws LexerException, IOException
     {
         filter();
@@ -52,6 +62,7 @@ public class Lexer
         this.in = in;
     }
 
+    @SuppressWarnings("deprecation") // because of filterWrap and nextList
     public Token peek() throws LexerException, IOException
     {
         while(this.token == null)
@@ -63,6 +74,7 @@ public class Lexer
         return (Token) nextList.peek();
     }
 
+    @SuppressWarnings("deprecation") // because of filterWrap and nextList
     public Token next() throws LexerException, IOException
     {
         while(this.token == null)
diff --git a/src/main/resources/org/sablecc/sablecc/lexer.txt b/src/main/resources/org/sablecc/sablecc/lexer.txt
index f9a786d..efa6598 100644
--- a/src/main/resources/org/sablecc/sablecc/lexer.txt
+++ b/src/main/resources/org/sablecc/sablecc/lexer.txt
@@ -51,8 +51,14 @@ public class Lexer
     private boolean eof;
     private final StringBuilder text = new StringBuilder();
 
+    @Deprecated
     private final Queue<IToken> nextList = new LinkedList<IToken>();
 
+    /**
+     * @deprecated Use {@link #token} to get, modify, replace, and/or delete the current token.
+     *     Injecting new tokens into the token stream will not be supported in the future.
+     */
+    @Deprecated
     public Queue<IToken> getNextList() {
         return nextList;
     }
@@ -62,6 +68,10 @@ public class Lexer
         // Do nothing
     }
 
+    /**
+     * @deprecated Override {@link #filter()} instead.
+     */
+    @Deprecated
     protected void filterWrap() throws LexerException, IOException
     {
         filter();
@@ -76,6 +86,7 @@ public class Lexer
         this.in = in;
     }
 
+    @SuppressWarnings("deprecation") // because of filterWrap and nextList
     public Token peek() throws LexerException, IOException
     {
         while(this.token == null)
@@ -87,6 +98,7 @@ public class Lexer
         return (Token) nextList.peek();
     }
 
+    @SuppressWarnings("deprecation") // because of filterWrap and nextList
     public Token next() throws LexerException, IOException
     {
         while(this.token == null)
-- 
GitLab