forked from phoedos/pmd
Add back default version for CPD languages
This commit is contained in:
parent
255fdf050b
commit
0f17cc83f6
@ -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<String> aliases;
|
||||
final boolean isDefault;
|
||||
|
||||
private LangVersionMetadata() {
|
||||
this.name = "";
|
||||
this.aliases = emptyList();
|
||||
this.isDefault = true;
|
||||
}
|
||||
|
||||
private LangVersionMetadata(String name, List<String> aliases, boolean isDefault) {
|
||||
checkVersionName(name);
|
||||
for (String alias : aliases) {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user