From 778b3177c2a6c12f5fb5f5ac534264b2be4082ac Mon Sep 17 00:00:00 2001 From: alexeyerm <63284266+alexeyerm@users.noreply.github.com> Date: Thu, 5 Sep 2024 19:32:32 +0300 Subject: [PATCH] Remove unused function createThin() Remove unused function createThin() from common_token_factory.go, CommonTokenFactory.py, CommonTokenFactory.js. The unexported function 'antlr.createThin' is never used but has a potential bug. Using nil constant at common_token_factory.go:52, it is passed as 1st parameter in call to function 'antlr.NewCommonToken' at common_token_factory.go:52, where it is dereferenced at token.go:140. --- runtime/Go/antlr/v4/common_token_factory.go | 7 ------- runtime/JavaScript/src/antlr4/CommonTokenFactory.js | 6 ------ runtime/Python3/src/antlr4/CommonTokenFactory.py | 5 ----- 3 files changed, 18 deletions(-) diff --git a/runtime/Go/antlr/v4/common_token_factory.go b/runtime/Go/antlr/v4/common_token_factory.go index 1bb0314ea0..6405c0dc08 100644 --- a/runtime/Go/antlr/v4/common_token_factory.go +++ b/runtime/Go/antlr/v4/common_token_factory.go @@ -47,10 +47,3 @@ func (c *CommonTokenFactory) Create(source *TokenSourceCharStreamPair, ttype int return t } - -func (c *CommonTokenFactory) createThin(ttype int, text string) Token { - t := NewCommonToken(nil, ttype, TokenDefaultChannel, -1, -1) - t.SetText(text) - - return t -} diff --git a/runtime/JavaScript/src/antlr4/CommonTokenFactory.js b/runtime/JavaScript/src/antlr4/CommonTokenFactory.js index 987999c525..b1cae3c379 100644 --- a/runtime/JavaScript/src/antlr4/CommonTokenFactory.js +++ b/runtime/JavaScript/src/antlr4/CommonTokenFactory.js @@ -43,12 +43,6 @@ export default class CommonTokenFactory extends TokenFactory { } return t; } - - createThin(type, text) { - const t = new CommonToken(null, type); - t.text = text; - return t; - } } /** diff --git a/runtime/Python3/src/antlr4/CommonTokenFactory.py b/runtime/Python3/src/antlr4/CommonTokenFactory.py index 0d09ad7859..f4f50edcb7 100644 --- a/runtime/Python3/src/antlr4/CommonTokenFactory.py +++ b/runtime/Python3/src/antlr4/CommonTokenFactory.py @@ -53,9 +53,4 @@ def create(self, source, type:int, text:str, channel:int, start:int, stop:int, l t.text = source[1].getText(start,stop) return t - def createThin(self, type:int, text:str): - t = CommonToken(type=type) - t.text = text - return t - CommonTokenFactory.DEFAULT = CommonTokenFactory()