forked from phoedos/pmd
Code upgrade advised by Ryan:
* Using Language.commaSeparatedTerseNames(Language.findWithRuleSupport()), rather than specific method (which has been removed) * Getting ride off findByExactName, keeping only the "ignoreCase" one. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6463 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -9,7 +9,8 @@ TODO - Release blockers - Must implement before this release can be finished
|
||||
o Additional changes to Rule organization withing RuleSets as discussed on
|
||||
this forum thread:
|
||||
http://sourceforge.net/forum/forum.php?thread_id=1323593&forum_id=188194
|
||||
o Change PMD AntTask options to allow specifying both language and if
|
||||
o Adapt PMD command line to have multiple -lang options (should be cummulative).
|
||||
Change PMD AntTask options to allow specifying both language and if
|
||||
relevant language version. (assigned to rpelisse)
|
||||
o CPD needs work on use of Language. It currently is hardcoded to only
|
||||
handled Java 1.4. Integrate CPD needs into core PMD where appropriate.
|
||||
|
@ -176,7 +176,7 @@ public class CommandLineOptions {
|
||||
String languageSpecified = args[optionsIndex + LANG_NAME_INDEX];
|
||||
this.language = Language.findByTerseName(languageSpecified);
|
||||
if ( language == null ) {
|
||||
throw new IllegalArgumentException("language '" + languageSpecified + "' is not recognized. Availaible language are : " + Language.getCommaSeparatedOfAllSupportedLanguages());
|
||||
throw new IllegalArgumentException("language '" + languageSpecified + "' is not recognized. Availaible language are : " + Language.commaSeparatedTerseNames(Language.findWithRuleSupport()));
|
||||
}
|
||||
else {
|
||||
if ( args.length > (optionsIndex + LANG_VERSION_INDEX) ) {
|
||||
|
@ -212,7 +212,7 @@ public class RuleSetFactory {
|
||||
RuleSet ruleSet = new RuleSet();
|
||||
ruleSet.setFileName(fileName);
|
||||
ruleSet.setName(ruleSetElement.getAttribute("name"));
|
||||
ruleSet.setLanguage(Language.findByExactTerseName(ruleSetElement.getAttribute("language")));
|
||||
ruleSet.setLanguage(Language.findByTerseName(ruleSetElement.getAttribute("language")));
|
||||
|
||||
NodeList nodeList = ruleSetElement.getChildNodes();
|
||||
for (int i = 0; i < nodeList.getLength(); i++) {
|
||||
@ -337,7 +337,7 @@ public class RuleSetFactory {
|
||||
|
||||
if (ruleElement.hasAttribute("language")) {
|
||||
String languageName = ruleElement.getAttribute("language");
|
||||
Language language = Language.findByExactTerseName(languageName);
|
||||
Language language = Language.findByTerseName(languageName);
|
||||
if (language == null) {
|
||||
throw new IllegalArgumentException("Unknown Language '" + languageName + "' for Rule " + rule.getName()
|
||||
+ ", supported Languages are "
|
||||
|
@ -238,23 +238,6 @@ public enum Language {
|
||||
return languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility method to find the Language associated with the given
|
||||
* terse name.
|
||||
* @param terseName The Language terse name.
|
||||
* @return The Language with this terse name, <code>null</code> if there is
|
||||
* no Language with this terse name.
|
||||
*/
|
||||
public static Language findByExactTerseName(String terseName) {
|
||||
for (Language language : Language.values()) {
|
||||
if (language.getTerseName().equals(terseName)) {
|
||||
return language;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A utility method to find the Language associated with the given
|
||||
* terse name, whatever the case is.
|
||||
@ -286,22 +269,6 @@ public enum Language {
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a comma separated list of all languages actually known by pmd.
|
||||
* @return a string with the comma separated list.
|
||||
*/
|
||||
public static String getCommaSeparatedOfAllSupportedLanguages() {
|
||||
String commaSeparatedLanguagesString = "";
|
||||
Language[] supportedLanguages = Language.values();
|
||||
for (int idLanguage = 0; idLanguage < supportedLanguages.length ; idLanguage++ ) {
|
||||
commaSeparatedLanguagesString += "," + supportedLanguages[idLanguage];
|
||||
}
|
||||
// Remove the extra first comma before returning strings
|
||||
return commaSeparatedLanguagesString.substring(1,commaSeparatedLanguagesString.length());
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static void init() {
|
||||
// Force initialization of the LanguageVersion enum.
|
||||
|
Reference in New Issue
Block a user