diff --git a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageModule.java b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageModule.java index 7b57934bd7..a5fca0cce0 100644 --- a/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageModule.java +++ b/pmd-apex/src/main/java/net/sourceforge/pmd/lang/apex/ApexLanguageModule.java @@ -4,22 +4,33 @@ package net.sourceforge.pmd.lang.apex; +import static net.sourceforge.pmd.util.CollectionUtil.listOf; + +import java.util.List; + import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.LanguageModuleBase; import net.sourceforge.pmd.lang.LanguageProcessor; import net.sourceforge.pmd.lang.LanguagePropertyBundle; import net.sourceforge.pmd.lang.LanguageRegistry; -import apex.jorje.services.Version; - public class ApexLanguageModule extends LanguageModuleBase { public static final String NAME = "Apex"; public static final String TERSE_NAME = "apex"; + public static final List VERSIONS = listOf("52", "53", "54", "55", "56", "57"); + public ApexLanguageModule() { - super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("cls", "trigger") - .addDefaultVersion(String.valueOf((int) Version.CURRENT.getExternal()))); + super(createMetadata()); + } + + private static LanguageMetadata createMetadata() { + LanguageMetadata languageMetadata = LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("cls", "trigger"); + int lastVersion = VERSIONS.size() - 1; + VERSIONS.subList(0, lastVersion).forEach(languageMetadata::addVersion); + languageMetadata.addDefaultVersion(VERSIONS.get(lastVersion)); + return languageMetadata; } @Override diff --git a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/LanguageVersionTest.java b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/LanguageVersionTest.java index fe132bcb61..0379b1a16a 100644 --- a/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/LanguageVersionTest.java +++ b/pmd-apex/src/test/java/net/sourceforge/pmd/lang/apex/LanguageVersionTest.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.AbstractLanguageVersionTest; class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { - return Arrays.asList(new TestDescriptor(ApexLanguageModule.NAME, ApexLanguageModule.TERSE_NAME, "35", - getLanguage("Apex").getVersion("35"))); + return Arrays.asList(new TestDescriptor(ApexLanguageModule.NAME, ApexLanguageModule.TERSE_NAME, "57", + ApexLanguageModule.getInstance().getDefaultVersion())); } } diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/PlainTextLanguage.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/PlainTextLanguage.java index 29afc7d45d..3c14dd61de 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/PlainTextLanguage.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/PlainTextLanguage.java @@ -31,7 +31,9 @@ public final class PlainTextLanguage extends SimpleLanguageModuleBase { static final String TERSE_NAME = "text"; private PlainTextLanguage() { - super(LanguageMetadata.withId(TERSE_NAME).name("Plain text").extensions("plain-text-file-goo-extension"), + super(LanguageMetadata.withId(TERSE_NAME).name("Plain text") + .extensions("plain-text-file-goo-extension") + .addDefaultVersion("default"), new TextLvh()); } diff --git a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java index cf6304f58a..46d3e81ac2 100644 --- a/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java +++ b/pmd-dist/src/test/java/net/sourceforge/pmd/it/BinaryDistributionIT.java @@ -30,16 +30,29 @@ class BinaryDistributionIT extends AbstractBinaryDistributionTest { + " kotlin, lua, matlab, modelica, objectivec, perl," + System.lineSeparator() + " php, plsql, python, ruby, scala, swift, tsql," + System.lineSeparator() + " vf, xml"; - SUPPORTED_LANGUAGES_PMD = "Valid values: apex-54, ecmascript-ES6, html-," + System.lineSeparator() - + " java-1.10, java-1.3, java-1.4, java-1.5, java-1." + System.lineSeparator() - + " 6, java-1.7, java-1.8, java-1.9, java-10," + System.lineSeparator() + SUPPORTED_LANGUAGES_PMD = "Valid values: apex-52, apex-53, apex-54, apex-55," + System.lineSeparator() + + " apex-56, apex-57, ecmascript-3, ecmascript-5," + System.lineSeparator() + + " ecmascript-6, ecmascript-7, ecmascript-8," + System.lineSeparator() + + " ecmascript-9, ecmascript-ES2015," + System.lineSeparator() + + " ecmascript-ES2016, ecmascript-ES2017," + System.lineSeparator() + + " ecmascript-ES2018, ecmascript-ES6, html-4," + System.lineSeparator() + + " html-5, java-1.10, java-1.3, java-1.4, java-1.5," + System.lineSeparator() + + " java-1.6, java-1.7, java-1.8, java-1.9, java-10," + System.lineSeparator() + " java-11, java-12, java-13, java-14, java-15," + System.lineSeparator() + " java-16, java-17, java-18, java-18-preview," + System.lineSeparator() + " java-19, java-19-preview, java-5, java-6, java-7," + System.lineSeparator() - + " java-8, java-9, jsp-, kotlin-1.6, kotlin-1." + System.lineSeparator() - + " 6-rfc+0.1, modelica-, plsql-, pom-, scala-2.10," + System.lineSeparator() - + " scala-2.11, scala-2.12, scala-2.13, swift-, vf-," + System.lineSeparator() - + " vm-, wsdl-, xml-, xsl-"; + + " java-8, java-9, jsp-2, jsp-3, kotlin-1.6," + System.lineSeparator() + + " kotlin-1.7, modelica-3.4, modelica-3.5," + System.lineSeparator() + + " plsql-11g, plsql-12.1, plsql-12.2," + System.lineSeparator() + + " plsql-12c_Release_1, plsql-12c_Release_2," + System.lineSeparator() + + " plsql-18c, plsql-19c, plsql-21c, pom-4.0.0," + System.lineSeparator() + + " scala-2.10, scala-2.11, scala-2.12, scala-2.13," + System.lineSeparator() + + " swift-4.2, swift-5.0, swift-5.1, swift-5.2," + System.lineSeparator() + + " swift-5.3, swift-5.4, swift-5.5, swift-5.6," + System.lineSeparator() + + " swift-5.7, vf-52, vf-53, vf-54, vf-55, vf-56," + System.lineSeparator() + + " vf-57, vm-2.0, vm-2.1, vm-2.2, vm-2.3, wsdl-1.1," + System.lineSeparator() + + " wsdl-2.0, xml-1.0, xml-1.1, xsl-1.0, xsl-2.0," + System.lineSeparator() + + " xsl-3.0"; } private final String srcDir = new File(".", "src/test/resources/sample-source/java/").getAbsolutePath(); diff --git a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/HtmlLanguageModule.java b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/HtmlLanguageModule.java index f242c180be..e93401e190 100644 --- a/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/HtmlLanguageModule.java +++ b/pmd-html/src/main/java/net/sourceforge/pmd/lang/html/HtmlLanguageModule.java @@ -15,7 +15,9 @@ public final class HtmlLanguageModule extends SimpleLanguageModuleBase { public HtmlLanguageModule() { super(LanguageMetadata.withId(TERSE_NAME).name(NAME) - .extensions("html", "htm", "xhtml", "xht", "shtml"), + .extensions("html", "htm", "xhtml", "xht", "shtml") + .addVersion("4") + .addDefaultVersion("5"), new HtmlHandler()); } diff --git a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/LanguageVersionTest.java b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/LanguageVersionTest.java index c1baee0c98..3534875ac5 100644 --- a/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/LanguageVersionTest.java +++ b/pmd-html/src/test/java/net/sourceforge/pmd/lang/html/LanguageVersionTest.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.AbstractLanguageVersionTest; class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { - return Arrays.asList(new TestDescriptor(HtmlLanguageModule.NAME, HtmlLanguageModule.TERSE_NAME, "", + return Arrays.asList(new TestDescriptor(HtmlLanguageModule.NAME, HtmlLanguageModule.TERSE_NAME, "5", getLanguage(HtmlLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptLanguageModule.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptLanguageModule.java index e73a983d37..ea4ed73860 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptLanguageModule.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/EcmascriptLanguageModule.java @@ -19,7 +19,12 @@ public class EcmascriptLanguageModule extends SimpleLanguageModuleBase { public EcmascriptLanguageModule() { super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("js") - .addDefaultVersion("ES6"), + .addVersion("3") + .addVersion("5") + .addVersion("6", "ES6", "ES2015") + .addVersion("7", "ES2016") + .addVersion("8", "ES2017") + .addDefaultVersion("9", "ES2018"), properties -> () -> new EcmascriptParser(properties)); } diff --git a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParser.java b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParser.java index bb80c84d5b..6f6c00b5f8 100644 --- a/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParser.java +++ b/pmd-javascript/src/main/java/net/sourceforge/pmd/lang/ecmascript/ast/EcmascriptParser.java @@ -18,6 +18,7 @@ import org.mozilla.javascript.ast.ErrorCollector; import org.mozilla.javascript.ast.ParseProblem; import net.sourceforge.pmd.lang.LanguagePropertyBundle; +import net.sourceforge.pmd.lang.LanguageVersion; import net.sourceforge.pmd.lang.ast.AstInfo; import net.sourceforge.pmd.lang.ast.FileAnalysisException; import net.sourceforge.pmd.lang.ast.ParseException; @@ -30,11 +31,11 @@ public final class EcmascriptParser implements net.sourceforge.pmd.lang.ast.Pars this.properties = properties; } - private AstRoot parseEcmascript(final String sourceCode, final List parseProblems) throws ParseException { + private AstRoot parseEcmascript(final String sourceCode, final LanguageVersion version, final List parseProblems) throws ParseException { final CompilerEnvirons compilerEnvirons = new CompilerEnvirons(); compilerEnvirons.setRecordingComments(true); compilerEnvirons.setRecordingLocalJsDocComments(true); - compilerEnvirons.setLanguageVersion(Context.VERSION_ES6); + compilerEnvirons.setLanguageVersion(determineRhinoLanguageVersion(version)); // Scope's don't appear to get set right without this compilerEnvirons.setIdeMode(true); compilerEnvirons.setWarnTrailingComma(true); @@ -52,10 +53,19 @@ public final class EcmascriptParser implements net.sourceforge.pmd.lang.ast.Pars return astRoot; } + private static int determineRhinoLanguageVersion(LanguageVersion version) { + switch (version.getVersion()) { + case "3": return Context.VERSION_1_5; + case "5": return Context.VERSION_1_8; + default: return Context.VERSION_ES6; + } + } + @Override public RootNode parse(ParserTask task) throws FileAnalysisException { + final LanguageVersion version = task.getLanguageVersion(); final List parseProblems = new ArrayList<>(); - final AstRoot astRoot = parseEcmascript(task.getSourceText(), parseProblems); + final AstRoot astRoot = parseEcmascript(task.getSourceText(), version, parseProblems); final EcmascriptTreeBuilder treeBuilder = new EcmascriptTreeBuilder(parseProblems); ASTAstRoot tree = (ASTAstRoot) treeBuilder.build(astRoot); diff --git a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/LanguageVersionTest.java b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/LanguageVersionTest.java index 5df250aff5..73a35e13db 100644 --- a/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/LanguageVersionTest.java +++ b/pmd-javascript/src/test/java/net/sourceforge/pmd/lang/ecmascript/LanguageVersionTest.java @@ -13,7 +13,7 @@ class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { return Arrays.asList( - new TestDescriptor(EcmascriptLanguageModule.NAME, EcmascriptLanguageModule.TERSE_NAME, "ES6", + new TestDescriptor(EcmascriptLanguageModule.NAME, EcmascriptLanguageModule.TERSE_NAME, "9", getLanguage(EcmascriptLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/JspLanguageModule.java b/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/JspLanguageModule.java index 573a42b94c..d36076551d 100644 --- a/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/JspLanguageModule.java +++ b/pmd-jsp/src/main/java/net/sourceforge/pmd/lang/jsp/JspLanguageModule.java @@ -16,7 +16,9 @@ public class JspLanguageModule extends SimpleLanguageModuleBase { public JspLanguageModule() { super(LanguageMetadata.withId(TERSE_NAME).name(NAME).shortName("JSP") - .extensions("jsp", "jspx", "jspf", "tag"), + .extensions("jsp", "jspx", "jspf", "tag") + .addVersion("2") + .addDefaultVersion("3"), new JspHandler()); } diff --git a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/LanguageVersionTest.java b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/LanguageVersionTest.java index 4707c22101..ed81a65e96 100644 --- a/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/LanguageVersionTest.java +++ b/pmd-jsp/src/test/java/net/sourceforge/pmd/lang/jsp/LanguageVersionTest.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.AbstractLanguageVersionTest; class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { - return Arrays.asList(new TestDescriptor(JspLanguageModule.NAME, JspLanguageModule.TERSE_NAME, "", + return Arrays.asList(new TestDescriptor(JspLanguageModule.NAME, JspLanguageModule.TERSE_NAME, "3", getLanguage(JspLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/KotlinLanguageModule.java b/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/KotlinLanguageModule.java index 31e0d209d4..d82342bc4e 100644 --- a/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/KotlinLanguageModule.java +++ b/pmd-kotlin/src/main/java/net/sourceforge/pmd/lang/kotlin/KotlinLanguageModule.java @@ -25,8 +25,8 @@ public class KotlinLanguageModule extends SimpleLanguageModuleBase { */ public KotlinLanguageModule() { super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("kt", "ktm") - .addDefaultVersion("1.6-rfc+0.1", "1.6"), + .addVersion("1.6") + .addDefaultVersion("1.7"), new KotlinHandler()); - } } diff --git a/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/LanguageVersionTest.java b/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/LanguageVersionTest.java index 9417c8b537..5a6956aa8e 100644 --- a/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/LanguageVersionTest.java +++ b/pmd-kotlin/src/test/java/net/sourceforge/pmd/lang/kotlin/LanguageVersionTest.java @@ -13,9 +13,7 @@ class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { return Arrays.asList( - new TestDescriptor(KotlinLanguageModule.NAME, KotlinLanguageModule.TERSE_NAME, "1.6-rfc+0.1", - getLanguage(KotlinLanguageModule.NAME).getDefaultVersion()), - new TestDescriptor(KotlinLanguageModule.NAME, KotlinLanguageModule.TERSE_NAME, "1.6", + new TestDescriptor(KotlinLanguageModule.NAME, KotlinLanguageModule.TERSE_NAME, "1.7", getLanguage(KotlinLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-modelica/src/main/java/net/sourceforge/pmd/lang/modelica/ModelicaLanguageModule.java b/pmd-modelica/src/main/java/net/sourceforge/pmd/lang/modelica/ModelicaLanguageModule.java index 2746c21363..290533ba0d 100644 --- a/pmd-modelica/src/main/java/net/sourceforge/pmd/lang/modelica/ModelicaLanguageModule.java +++ b/pmd-modelica/src/main/java/net/sourceforge/pmd/lang/modelica/ModelicaLanguageModule.java @@ -11,7 +11,10 @@ public class ModelicaLanguageModule extends SimpleLanguageModuleBase { public static final String TERSE_NAME = "modelica"; public ModelicaLanguageModule() { - super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("mo"), + super(LanguageMetadata.withId(TERSE_NAME).name(NAME) + .extensions("mo") + .addVersion("3.4") + .addDefaultVersion("3.5"), new ModelicaHandler()); } diff --git a/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/LanguageVersionTest.java b/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/LanguageVersionTest.java index 367e843585..f06c1c8a1a 100644 --- a/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/LanguageVersionTest.java +++ b/pmd-modelica/src/test/java/net/sourceforge/pmd/lang/modelica/LanguageVersionTest.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.AbstractLanguageVersionTest; class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { - return Arrays.asList(new TestDescriptor(ModelicaLanguageModule.NAME, ModelicaLanguageModule.TERSE_NAME, "", + return Arrays.asList(new TestDescriptor(ModelicaLanguageModule.NAME, ModelicaLanguageModule.TERSE_NAME, "3.5", getLanguage(ModelicaLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLLanguageModule.java b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLLanguageModule.java index 0b74d631c2..6422362df0 100644 --- a/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLLanguageModule.java +++ b/pmd-plsql/src/main/java/net/sourceforge/pmd/lang/plsql/PLSQLLanguageModule.java @@ -27,7 +27,13 @@ public class PLSQLLanguageModule extends SimpleLanguageModuleBase { "pck", "pks", "pkh", "pkb", // Packages "typ", "tyb", // Object Types "tps", "tpb" // Object Types - ), + ) + .addVersion("11g") + .addVersion("12c_Release_1", "12.1") + .addVersion("12c_Release_2", "12.2") + .addVersion("18c") + .addVersion("19c") + .addDefaultVersion("21c"), new PLSQLHandler() ); } diff --git a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/LanguageVersionTest.java b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/LanguageVersionTest.java index f28d58964e..886b4c5fe5 100644 --- a/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/LanguageVersionTest.java +++ b/pmd-plsql/src/test/java/net/sourceforge/pmd/lang/plsql/LanguageVersionTest.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.AbstractLanguageVersionTest; class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { - return Arrays.asList(new TestDescriptor(PLSQLLanguageModule.NAME, PLSQLLanguageModule.TERSE_NAME, "", + return Arrays.asList(new TestDescriptor(PLSQLLanguageModule.NAME, PLSQLLanguageModule.TERSE_NAME, "21c", getLanguage(PLSQLLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/SwiftLanguageModule.java b/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/SwiftLanguageModule.java index 1b05e94b4b..5e94c303f0 100644 --- a/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/SwiftLanguageModule.java +++ b/pmd-swift/src/main/java/net/sourceforge/pmd/lang/swift/SwiftLanguageModule.java @@ -20,6 +20,17 @@ public class SwiftLanguageModule extends SimpleLanguageModuleBase { * Create a new instance of Swift Language Module. */ public SwiftLanguageModule() { - super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("swift"), new SwiftHandler()); + super(LanguageMetadata.withId(TERSE_NAME).name(NAME) + .extensions("swift") + .addVersion("4.2") + .addVersion("5.0") + .addVersion("5.1") + .addVersion("5.2") + .addVersion("5.3") + .addVersion("5.4") + .addVersion("5.5") + .addVersion("5.6") + .addDefaultVersion("5.7"), + new SwiftHandler()); } } diff --git a/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/LanguageVersionTest.java b/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/LanguageVersionTest.java index e56e9f3ca9..9f5302ba72 100644 --- a/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/LanguageVersionTest.java +++ b/pmd-swift/src/test/java/net/sourceforge/pmd/lang/swift/LanguageVersionTest.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.AbstractLanguageVersionTest; class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { - return Arrays.asList(new TestDescriptor(SwiftLanguageModule.NAME, SwiftLanguageModule.TERSE_NAME, "", + return Arrays.asList(new TestDescriptor(SwiftLanguageModule.NAME, SwiftLanguageModule.TERSE_NAME, "5.7", getLanguage(SwiftLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageModule.java b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageModule.java index b75d9ffba6..3223c311d2 100644 --- a/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageModule.java +++ b/pmd-visualforce/src/main/java/net/sourceforge/pmd/lang/vf/VfLanguageModule.java @@ -20,12 +20,21 @@ public class VfLanguageModule extends SimpleLanguageModuleBase { public static final String TERSE_NAME = "vf"; public VfLanguageModule() { - super(LanguageMetadata.withId(TERSE_NAME).name(NAME) - .extensions("page", "component") - .dependsOnLanguage(ApexLanguageModule.TERSE_NAME), + super(createMetdata(), p -> new VfHandler((VfLanguageProperties) p)); } + private static LanguageMetadata createMetdata() { + LanguageMetadata languageMetadata = LanguageMetadata.withId(TERSE_NAME).name(NAME) + .extensions("page", "component") + .dependsOnLanguage(ApexLanguageModule.TERSE_NAME); + // use the same versions as in Apex + int lastVersion = ApexLanguageModule.VERSIONS.size() - 1; + ApexLanguageModule.VERSIONS.subList(0, lastVersion).forEach(languageMetadata::addVersion); + languageMetadata.addDefaultVersion(ApexLanguageModule.VERSIONS.get(lastVersion)); + return languageMetadata; + } + @Override public LanguagePropertyBundle newPropertyBundle() { return new VfLanguageProperties(); diff --git a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/LanguageVersionTest.java b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/LanguageVersionTest.java index 141d62ed8c..38c68b028a 100644 --- a/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/LanguageVersionTest.java +++ b/pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/LanguageVersionTest.java @@ -8,11 +8,13 @@ import java.util.Arrays; import java.util.Collection; import net.sourceforge.pmd.AbstractLanguageVersionTest; +import net.sourceforge.pmd.lang.apex.ApexLanguageModule; class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { - return Arrays.asList(new TestDescriptor(VfLanguageModule.NAME, VfLanguageModule.TERSE_NAME, "", - getLanguage(VfLanguageModule.NAME).getDefaultVersion())); + return Arrays.asList(new TestDescriptor(VfLanguageModule.NAME, VfLanguageModule.TERSE_NAME, + ApexLanguageModule.getInstance().getDefaultVersion().getVersion(), + getLanguage(VfLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/VmLanguageModule.java b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/VmLanguageModule.java index 553fb8a4e8..0cc028c236 100644 --- a/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/VmLanguageModule.java +++ b/pmd-vm/src/main/java/net/sourceforge/pmd/lang/vm/VmLanguageModule.java @@ -15,7 +15,13 @@ public class VmLanguageModule extends SimpleLanguageModuleBase { public static final String TERSE_NAME = "vm"; public VmLanguageModule() { - super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("vm"), new VmHandler()); + super(LanguageMetadata.withId(TERSE_NAME).name(NAME) + .extensions("vm") + .addVersion("2.0") + .addVersion("2.1") + .addVersion("2.2") + .addDefaultVersion("2.3"), + new VmHandler()); } } diff --git a/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/LanguageVersionTest.java b/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/LanguageVersionTest.java index 2e5645fc11..32f4877901 100644 --- a/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/LanguageVersionTest.java +++ b/pmd-vm/src/test/java/net/sourceforge/pmd/lang/vm/LanguageVersionTest.java @@ -12,7 +12,7 @@ import net.sourceforge.pmd.AbstractLanguageVersionTest; class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { - return Arrays.asList(new TestDescriptor(VmLanguageModule.NAME, VmLanguageModule.TERSE_NAME, "", + return Arrays.asList(new TestDescriptor(VmLanguageModule.NAME, VmLanguageModule.TERSE_NAME, "2.3", getLanguage(VmLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/pom/PomLanguageModule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/pom/PomLanguageModule.java index 7de4d4da0b..9f91051657 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/pom/PomLanguageModule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/pom/PomLanguageModule.java @@ -12,7 +12,10 @@ public class PomLanguageModule extends SimpleLanguageModuleBase { public static final String TERSE_NAME = "pom"; public PomLanguageModule() { - super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("pom"), new XmlHandler()); + super(LanguageMetadata.withId(TERSE_NAME).name(NAME) + .extensions("pom") + .addDefaultVersion("4.0.0"), + new XmlHandler()); } } diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/wsdl/WsdlLanguageModule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/wsdl/WsdlLanguageModule.java index ed9512d1cb..f48d4c9ddd 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/wsdl/WsdlLanguageModule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/wsdl/WsdlLanguageModule.java @@ -15,7 +15,11 @@ public class WsdlLanguageModule extends SimpleLanguageModuleBase { public static final String TERSE_NAME = "wsdl"; public WsdlLanguageModule() { - super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("wsdl"), new XmlHandler()); + super(LanguageMetadata.withId(TERSE_NAME).name(NAME) + .extensions("wsdl") + .addVersion("1.1") + .addDefaultVersion("2.0"), + new XmlHandler()); } } diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlLanguageModule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlLanguageModule.java index 5df4a35b06..21bf0e22bc 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlLanguageModule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xml/XmlLanguageModule.java @@ -15,6 +15,10 @@ public class XmlLanguageModule extends SimpleLanguageModuleBase { public static final String TERSE_NAME = "xml"; public XmlLanguageModule() { - super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("xml"), new XmlHandler()); + super(LanguageMetadata.withId(TERSE_NAME).name(NAME) + .extensions("xml") + .addVersion("1.0") + .addDefaultVersion("1.1"), + new XmlHandler()); } } diff --git a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xsl/XslLanguageModule.java b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xsl/XslLanguageModule.java index c51c48096a..ce0b833b44 100644 --- a/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xsl/XslLanguageModule.java +++ b/pmd-xml/src/main/java/net/sourceforge/pmd/lang/xsl/XslLanguageModule.java @@ -16,7 +16,12 @@ public class XslLanguageModule extends SimpleLanguageModuleBase { public static final String TERSE_NAME = "xsl"; public XslLanguageModule() { - super(LanguageMetadata.withId(TERSE_NAME).name(NAME).extensions("xsl", "xslt"), new XmlHandler()); + super(LanguageMetadata.withId(TERSE_NAME).name(NAME) + .extensions("xsl", "xslt") + .addVersion("1.0") + .addVersion("2.0") + .addDefaultVersion("3.0"), + new XmlHandler()); } } diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/LanguageVersionTest.java b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/LanguageVersionTest.java index 4e4816f7fb..0654616943 100644 --- a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/LanguageVersionTest.java +++ b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/LanguageVersionTest.java @@ -16,13 +16,13 @@ class LanguageVersionTest extends AbstractLanguageVersionTest { static Collection data() { return Arrays.asList( - new TestDescriptor(XmlLanguageModule.NAME, XmlLanguageModule.TERSE_NAME, "", + new TestDescriptor(XmlLanguageModule.NAME, XmlLanguageModule.TERSE_NAME, "1.1", getLanguage(XmlLanguageModule.NAME).getDefaultVersion()), - new TestDescriptor(XslLanguageModule.NAME, XslLanguageModule.TERSE_NAME, "", + new TestDescriptor(XslLanguageModule.NAME, XslLanguageModule.TERSE_NAME, "3.0", getLanguage(XslLanguageModule.NAME).getDefaultVersion()), - new TestDescriptor(WsdlLanguageModule.NAME, WsdlLanguageModule.TERSE_NAME, "", + new TestDescriptor(WsdlLanguageModule.NAME, WsdlLanguageModule.TERSE_NAME, "2.0", getLanguage(WsdlLanguageModule.NAME).getDefaultVersion()), - new TestDescriptor(PomLanguageModule.NAME, PomLanguageModule.TERSE_NAME, "", + new TestDescriptor(PomLanguageModule.NAME, PomLanguageModule.TERSE_NAME, "4.0.0", getLanguage(PomLanguageModule.NAME).getDefaultVersion())); } } diff --git a/pmd-xml/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml b/pmd-xml/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml index 52ba35fc8c..db7406fb77 100644 --- a/pmd-xml/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml +++ b/pmd-xml/src/test/resources/net/sourceforge/pmd/ant/xml/pmdtasktest.xml @@ -7,7 +7,7 @@ - +