diff --git a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageModuleBase.java b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageModuleBase.java index fd997eccd0..c6c98922b7 100644 --- a/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageModuleBase.java +++ b/pmd-core/src/main/java/net/sourceforge/pmd/lang/LanguageModuleBase.java @@ -4,6 +4,7 @@ package net.sourceforge.pmd.lang; +import static net.sourceforge.pmd.util.CollectionUtil.emptyList; import static net.sourceforge.pmd.util.CollectionUtil.setOf; import java.util.ArrayList; @@ -22,6 +23,8 @@ import org.apache.commons.lang3.StringUtils; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; +import net.sourceforge.pmd.cpd.PmdCapableLanguage; +import net.sourceforge.pmd.lang.LanguageModuleBase.LanguageMetadata.LangVersionMetadata; import net.sourceforge.pmd.util.AssertionUtil; import net.sourceforge.pmd.util.StringUtil; @@ -55,7 +58,13 @@ public abstract class LanguageModuleBase implements Language { LanguageVersion defaultVersion = null; if (metadata.versionMetadata.isEmpty()) { - throw new IllegalStateException("No versions for '" + getId() + "'"); + if (this instanceof PmdCapableLanguage) { + // pmd languages need to have versions + throw new IllegalStateException("No versions for '" + getId() + "'"); + } else { + // for others, a version is declared implicitly + metadata.versionMetadata.add(new LangVersionMetadata()); + } } int i = 0; @@ -374,6 +383,12 @@ public abstract class LanguageModuleBase implements Language { final List aliases; final boolean isDefault; + private LangVersionMetadata() { + this.name = ""; + this.aliases = emptyList(); + this.isDefault = true; + } + private LangVersionMetadata(String name, List aliases, boolean isDefault) { checkVersionName(name); for (String alias : aliases) { diff --git a/pmd-dart/src/main/java/net/sourceforge/pmd/lang/dart/DartLanguageModule.java b/pmd-dart/src/main/java/net/sourceforge/pmd/lang/dart/DartLanguageModule.java index b137f4dece..baffacee31 100644 --- a/pmd-dart/src/main/java/net/sourceforge/pmd/lang/dart/DartLanguageModule.java +++ b/pmd-dart/src/main/java/net/sourceforge/pmd/lang/dart/DartLanguageModule.java @@ -14,11 +14,9 @@ import net.sourceforge.pmd.lang.impl.CpdOnlyLanguageModuleBase; */ public class DartLanguageModule extends CpdOnlyLanguageModuleBase { - /** - * Creates a new Dart Language instance. - */ public DartLanguageModule() { - super(LanguageMetadata.withId("dart").name("Dart").extensions("dart")); + super(LanguageMetadata.withId("dart").name("Dart").extensions("dart") + .addDefaultVersion("2")); } @Override diff --git a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/XmlParsingHelper.java b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/XmlParsingHelper.java index 4595fb7f50..50e75ef852 100644 --- a/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/XmlParsingHelper.java +++ b/pmd-xml/src/test/java/net/sourceforge/pmd/lang/xml/XmlParsingHelper.java @@ -4,10 +4,7 @@ package net.sourceforge.pmd.lang.xml; -import java.sql.ParameterMetaData; - import net.sourceforge.pmd.cpd.PmdCapableLanguage; -import net.sourceforge.pmd.lang.Language; import net.sourceforge.pmd.lang.ast.test.BaseParsingHelper; import net.sourceforge.pmd.lang.xml.ast.internal.XmlParserImpl.RootXmlNode;