From 69a92de52dddd720270f1a76ff27a9ccc5e8050c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Sotuyo=20Dodero?= Date: Mon, 28 Oct 2024 22:10:21 -0300 Subject: [PATCH] Have pmd-xml Lexer in line with other antlr grammars - The package is no longer antlr4, but ast, as is in all other modules - We keep a deprecated proxy for backwards compatibility - We annotate the generated classes as such to ignore them from coverage reports --- pmd-xml/pom.xml | 22 +++++++++++++++++++ .../pmd/lang/xml/{antlr4 => ast}/XMLLexer.g4 | 0 .../pmd/lang/xml/antlr4/XMLLexer.java | 17 ++++++++++++++ .../pmd/lang/xml/cpd/XmlCpdLexer.java | 2 +- 4 files changed, 40 insertions(+), 1 deletion(-) rename pmd-xml/src/main/antlr4/net/sourceforge/pmd/lang/xml/{antlr4 => ast}/XMLLexer.g4 (100%) create mode 100644 pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/antlr4/XMLLexer.java diff --git a/pmd-xml/pom.xml b/pmd-xml/pom.xml index 1d19200b86..676ba39759 100644 --- a/pmd-xml/pom.xml +++ b/pmd-xml/pom.xml @@ -45,6 +45,28 @@ + + + org.apache.maven.plugins + maven-antrun-plugin + + + antlr-cleanup + generate-sources + + run + + + + + + + + + + + + diff --git a/pmd-xml/src/main/antlr4/net/sourceforge/pmd/lang/xml/antlr4/XMLLexer.g4 b/pmd-xml/src/main/antlr4/net/sourceforge/pmd/lang/xml/ast/XMLLexer.g4 similarity index 100% rename from pmd-xml/src/main/antlr4/net/sourceforge/pmd/lang/xml/antlr4/XMLLexer.g4 rename to pmd-xml/src/main/antlr4/net/sourceforge/pmd/lang/xml/ast/XMLLexer.g4 diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/antlr4/XMLLexer.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/antlr4/XMLLexer.java new file mode 100644 index 0000000000..2425c51b9f --- /dev/null +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/antlr4/XMLLexer.java @@ -0,0 +1,17 @@ +package net.sourceforge.pmd.lang.xml.antlr4; + +import org.antlr.v4.runtime.CharStream; + +/** + * Backwards compatible bridge. The XMLLexer was moved to align it with other PMD modules. + * This class will be removed in PMD 8.0.0. + * Use {@link net.sourceforge.pmd.lang.xml.ast.XMLLexer} directly instead. + * + * @deprecated + */ +@Deprecated +public class XMLLexer extends net.sourceforge.pmd.lang.xml.ast.XMLLexer { + public XMLLexer(CharStream input) { + super(input); + } +} diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/cpd/XmlCpdLexer.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/cpd/XmlCpdLexer.java index 62b077ab4b..bf52b3d559 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/cpd/XmlCpdLexer.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/cpd/XmlCpdLexer.java @@ -8,7 +8,7 @@ import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.Lexer; import net.sourceforge.pmd.cpd.impl.AntlrCpdLexer; -import net.sourceforge.pmd.lang.xml.antlr4.XMLLexer; +import net.sourceforge.pmd.lang.xml.ast.XMLLexer; /** *

Note: This class has been called XmlTokenizer in PMD 6

.