From cb027dfe58a1afab85031f82f665408d144dae1d Mon Sep 17 00:00:00 2001
From: dgelessus <dgelessus@users.noreply.github.com>
Date: Thu, 21 Apr 2022 13:49:47 +0200
Subject: [PATCH] Remove no longer needed null checks from checkResult template

---
 src/main/java/org/sablecc/sablecc/parser/Parser.java | 10 ----------
 src/main/resources/org/sablecc/sablecc/parser.txt    | 10 ----------
 2 files changed, 20 deletions(-)

diff --git a/src/main/java/org/sablecc/sablecc/parser/Parser.java b/src/main/java/org/sablecc/sablecc/parser/Parser.java
index d5b9818..7db8e67 100644
--- a/src/main/java/org/sablecc/sablecc/parser/Parser.java
+++ b/src/main/java/org/sablecc/sablecc/parser/Parser.java
@@ -42,11 +42,6 @@ public class Parser implements IParser
     public Map<PositionedNode, SourcecodeRange> getMapping() { return this.mapping; }
 
     private void checkResult(Object elementToCheck, List<Object> beginNode, List<Object> endNode) {
-        // nodes with no tokens or sub nodes at all may exist
-        if (endNode == null) {
-            return;
-        }
-
         if (elementToCheck instanceof List<?>) {
             /*
              * special case: this is a list of nodes, for example an identifier
@@ -66,11 +61,6 @@ public class Parser implements IParser
         final PositionedNode node = (PositionedNode) elementToCheck;
 
         if (!this.getMapping().containsKey(node)) {
-            // dealing with a one-token element
-            if (beginNode == null) {
-                beginNode = endNode;
-            }
-
             final int begin = findBeginPos(beginNode, node);
             int end = findEndPos(endNode);
             if (end == -1) end = begin;
diff --git a/src/main/resources/org/sablecc/sablecc/parser.txt b/src/main/resources/org/sablecc/sablecc/parser.txt
index 6719a67..5b6c9a0 100644
--- a/src/main/resources/org/sablecc/sablecc/parser.txt
+++ b/src/main/resources/org/sablecc/sablecc/parser.txt
@@ -50,11 +50,6 @@ public class Parser implements IParser
     public Map<PositionedNode, SourcecodeRange> getMapping() { return this.mapping; }
 
     private void checkResult(Object elementToCheck, List<Object> beginNode, List<Object> endNode) {
-        // nodes with no tokens or sub nodes at all may exist
-        if (endNode == null) {
-            return;
-        }
-
         if (elementToCheck instanceof List<?>) {
             /*
              * special case: this is a list of nodes, for example an identifier
@@ -74,11 +69,6 @@ public class Parser implements IParser
         final PositionedNode node = (PositionedNode) elementToCheck;
 
         if (!this.getMapping().containsKey(node)) {
-            // dealing with a one-token element
-            if (beginNode == null) {
-                beginNode = endNode;
-            }
-
             final int begin = findBeginPos(beginNode, node);
             int end = findEndPos(endNode);
             if (end == -1) end = begin;
-- 
GitLab