diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/InternalApiBridge.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/InternalApiBridge.java index bb63f354e4..c9c2a348b4 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/InternalApiBridge.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/InternalApiBridge.java @@ -6,6 +6,10 @@ package net.sourceforge.pmd.lang.plsql.ast; import net.sourceforge.pmd.annotation.InternalApi; +import net.sourceforge.pmd.lang.TokenManager; +import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream; +import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; +import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.lang.symboltable.NameDeclaration; import net.sourceforge.pmd.lang.symboltable.Scope; @@ -36,4 +40,8 @@ public final class InternalApiBridge { public static void setNameDeclaration(ASTVariableOrConstantDeclaratorId node, NameDeclaration decl) { node.setNameDeclaration(decl); } + + public static TokenManager newTokenManager(TextDocument doc) { + return PLSQLTokenKinds.newTokenManager(CharStream.create(doc, PLSQLParser.TOKEN_BEHAVIOR)); + } } diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParser.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParser.java index 169bfb7d1e..1c3a9c63eb 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParser.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/ast/PLSQLParser.java @@ -9,7 +9,6 @@ import java.util.Locale; import org.checkerframework.checker.nullness.qual.Nullable; import net.sourceforge.pmd.benchmark.TimeTracker; -import net.sourceforge.pmd.lang.TokenManager; import net.sourceforge.pmd.lang.ast.ParseException; import net.sourceforge.pmd.lang.ast.impl.javacc.CharStream; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; @@ -17,7 +16,6 @@ import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccTokenDocument.TokenDocumentBehavior; import net.sourceforge.pmd.lang.ast.impl.javacc.JjtreeParserAdapter; import net.sourceforge.pmd.lang.document.Chars; -import net.sourceforge.pmd.lang.document.TextDocument; import net.sourceforge.pmd.lang.plsql.symboltable.SymbolFacade; public class PLSQLParser extends JjtreeParserAdapter { @@ -44,7 +42,7 @@ public class PLSQLParser extends JjtreeParserAdapter { } } - private static final TokenDocumentBehavior TOKEN_BEHAVIOR = new TokenDocumentBehavior(PLSQLTokenKinds.TOKEN_NAMES) { + static final TokenDocumentBehavior TOKEN_BEHAVIOR = new TokenDocumentBehavior(PLSQLTokenKinds.TOKEN_NAMES) { @Override public JavaccToken createToken(JavaccTokenDocument self, int kind, CharStream cs, @Nullable String image) { if (image == null) { @@ -90,8 +88,4 @@ public class PLSQLParser extends JjtreeParserAdapter { return root; } - public static TokenManager newTokenManager(TextDocument doc) { - return PLSQLTokenKinds.newTokenManager(CharStream.create(doc, TOKEN_BEHAVIOR)); - } - } diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/cpd/PLSQLCpdLexer.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/cpd/PLSQLCpdLexer.java index dc3c1d0d5e..2faa693ec5 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/cpd/PLSQLCpdLexer.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/cpd/PLSQLCpdLexer.java @@ -10,7 +10,7 @@ import net.sourceforge.pmd.lang.LanguagePropertyBundle; import net.sourceforge.pmd.lang.TokenManager; import net.sourceforge.pmd.lang.ast.impl.javacc.JavaccToken; import net.sourceforge.pmd.lang.document.TextDocument; -import net.sourceforge.pmd.lang.plsql.ast.PLSQLParser; +import net.sourceforge.pmd.lang.plsql.ast.InternalApiBridge; import net.sourceforge.pmd.lang.plsql.ast.PLSQLTokenKinds; /** @@ -54,6 +54,6 @@ public class PLSQLCpdLexer extends JavaccCpdLexer { @Override protected TokenManager makeLexerImpl(TextDocument doc) { - return PLSQLParser.newTokenManager(doc); + return InternalApiBridge.newTokenManager(doc); } }