diff --git a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/CpdCliTest.java b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/CpdCliTest.java index efb3a93594..cdb4a32aa3 100644 --- a/pmd-cli/src/test/java/net/sourceforge/pmd/cli/CpdCliTest.java +++ b/pmd-cli/src/test/java/net/sourceforge/pmd/cli/CpdCliTest.java @@ -206,7 +206,7 @@ class CpdCliTest extends BaseCliTest { @Test void jsShouldFindDuplicatesWithDifferentFileExtensions() throws Exception { - runCli(VIOLATIONS_FOUND, "--minimum-tokens", "5", "--language", "ecmascript", + runCli(VIOLATIONS_FOUND, "--minimum-tokens", "5", "--language", "ts", "-d", BASE_RES_PATH + "tsFiles/File1.ts", BASE_RES_PATH + "tsFiles/File2.ts") .checkStdOut(containsString("Found a 9 line (32 tokens) duplication in the following files")); } diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/TsLanguageModule.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/TsLanguageModule.java new file mode 100644 index 0000000000..ff06b2c241 --- /dev/null +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/TsLanguageModule.java @@ -0,0 +1,25 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ + +package net.sourceforge.pmd.lang.ecmascript; + +import net.sourceforge.pmd.cpd.Tokenizer; +import net.sourceforge.pmd.lang.LanguagePropertyBundle; +import net.sourceforge.pmd.lang.ecmascript.cpd.EcmascriptTokenizer; +import net.sourceforge.pmd.lang.impl.CpdOnlyLanguageModuleBase; + +/** + * CPD only language to recognize TypeScript files. + */ +public class TsLanguageModule extends CpdOnlyLanguageModuleBase { + + public TsLanguageModule() { + super(LanguageMetadata.withId("ts").name("TypeScript").extensions("ts")); + } + + @Override + public Tokenizer createCpdTokenizer(LanguagePropertyBundle bundle) { + return new EcmascriptTokenizer(); + } +} diff --git a/pmd-javascript/src/main/resources/META-INF/services/net.sourceforge.pmd.lang.Language b/pmd-javascript/src/main/resources/META-INF/services/net.sourceforge.pmd.lang.Language index 671c306c41..6e09a06884 100644 --- a/pmd-javascript/src/main/resources/META-INF/services/net.sourceforge.pmd.lang.Language +++ b/pmd-javascript/src/main/resources/META-INF/services/net.sourceforge.pmd.lang.Language @@ -1 +1,2 @@ net.sourceforge.pmd.lang.ecmascript.EcmascriptLanguageModule +net.sourceforge.pmd.lang.ecmascript.TsLanguageModule