diff --git a/pmd-kotlin/pom.xml b/pmd-kotlin/pom.xml index b1929c8c22..cc2edc2f2b 100644 --- a/pmd-kotlin/pom.xml +++ b/pmd-kotlin/pom.xml @@ -17,6 +17,27 @@ org.antlr antlr4-maven-plugin + + org.apache.maven.plugins + maven-antrun-plugin + + + antlr-cleanup + generate-sources + + run + + + + + + + + + + + + maven-resources-plugin diff --git a/pmd-kotlin/src/main/antlr4/net/sourceforge/pmd/lang/kotlin/antlr4/Kotlin.g4 b/pmd-kotlin/src/main/antlr4/net/sourceforge/pmd/lang/kotlin/ast/KotlinLexer.g4 similarity index 99% rename from pmd-kotlin/src/main/antlr4/net/sourceforge/pmd/lang/kotlin/antlr4/Kotlin.g4 rename to pmd-kotlin/src/main/antlr4/net/sourceforge/pmd/lang/kotlin/ast/KotlinLexer.g4 index dce0380786..c790e314f1 100644 --- a/pmd-kotlin/src/main/antlr4/net/sourceforge/pmd/lang/kotlin/antlr4/Kotlin.g4 +++ b/pmd-kotlin/src/main/antlr4/net/sourceforge/pmd/lang/kotlin/ast/KotlinLexer.g4 @@ -10,7 +10,7 @@ * https://github.com/JetBrains/kotlin/tree/master/compiler/testData/psi */ -lexer grammar Kotlin; +lexer grammar KotlinLexer; /** * Taken from http://www.antlr3.org/grammar/1345144569663/AntlrUnicode.txt diff --git a/pmd-kotlin/src/main/java/net/sourceforge/pmd/cpd/KotlinTokenizer.java b/pmd-kotlin/src/main/java/net/sourceforge/pmd/cpd/KotlinTokenizer.java index d44a5908fa..58a845701c 100644 --- a/pmd-kotlin/src/main/java/net/sourceforge/pmd/cpd/KotlinTokenizer.java +++ b/pmd-kotlin/src/main/java/net/sourceforge/pmd/cpd/KotlinTokenizer.java @@ -10,7 +10,7 @@ import net.sourceforge.pmd.cpd.internal.AntlrTokenizer; import net.sourceforge.pmd.cpd.token.AntlrTokenFilter; import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrToken; import net.sourceforge.pmd.lang.ast.impl.antlr4.AntlrTokenManager; -import net.sourceforge.pmd.lang.kotlin.antlr4.Kotlin; +import net.sourceforge.pmd.lang.kotlin.ast.KotlinLexer; /** * The Kotlin Tokenizer @@ -20,7 +20,7 @@ public class KotlinTokenizer extends AntlrTokenizer { @Override protected AntlrTokenManager getLexerForSource(SourceCode sourceCode) { CharStream charStream = AntlrTokenizer.getCharStreamFromSourceCode(sourceCode); - return new AntlrTokenManager(new Kotlin(charStream), sourceCode.getFileName()); + return new AntlrTokenManager(new KotlinLexer(charStream), sourceCode.getFileName()); } @Override @@ -52,15 +52,15 @@ public class KotlinTokenizer extends AntlrTokenizer { private void skipPackageAndImport(final AntlrToken currentToken) { final int type = currentToken.getKind(); - if (type == Kotlin.PACKAGE || type == Kotlin.IMPORT) { + if (type == KotlinLexer.PACKAGE || type == KotlinLexer.IMPORT) { discardingPackageAndImport = true; - } else if (discardingPackageAndImport && (type == Kotlin.SEMICOLON || type == Kotlin.NL)) { + } else if (discardingPackageAndImport && (type == KotlinLexer.SEMICOLON || type == KotlinLexer.NL)) { discardingPackageAndImport = false; } } private void skipNewLines(final AntlrToken currentToken) { - discardingNL = currentToken.getKind() == Kotlin.NL; + discardingNL = currentToken.getKind() == KotlinLexer.NL; } @Override