diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index c209dc9ba1..63622b0f79 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -10,6 +10,7 @@ Fixed bug 1037: Facing a showstopper issue in PMD Report Class (report listeners Fixed bug 1039: pmd-nicerhtml.xsl is packaged in wrong location Fixed bug 1043: node.getEndLine() always returns 0 (ECMAscript) Fixed bug 1044: Unknown option: -excludemarker +Fixed bug 1046: ant task CPDTask doesn't accept ecmascript Fixed bug 1047: False Positive in 'for' loops for LocalVariableCouldBeFinal in 5.0.1 Fixed bug 1048: CommentContent Rule, String Index out of range Exception Fixed bug 1055: Please add a colon in the ant output after line,column for Oracle JDeveloper IDE usage diff --git a/pmd/src/main/java/net/sourceforge/pmd/cpd/CPDTask.java b/pmd/src/main/java/net/sourceforge/pmd/cpd/CPDTask.java index cebcbaafac..0f7caa64e9 100644 --- a/pmd/src/main/java/net/sourceforge/pmd/cpd/CPDTask.java +++ b/pmd/src/main/java/net/sourceforge/pmd/cpd/CPDTask.java @@ -188,16 +188,9 @@ public class CPDTask extends Task { } } - /* - * FIXME Can't we do something cleaner and - * more dynamic ? Maybe externalise to a properties files that will - * be generated when building pmd ? This will not have to add manually - * new language here ? - */ public static class LanguageAttribute extends EnumeratedAttribute { - private static final String[] LANGUAGES = new String[]{"java","jsp","cpp", "c","php", "ruby", "fortran", "cs"}; public String[] getValues() { - return LANGUAGES; + return LanguageFactory.supportedLanguages; } } } diff --git a/pmd/src/main/java/net/sourceforge/pmd/cpd/GUI.java b/pmd/src/main/java/net/sourceforge/pmd/cpd/GUI.java index 40a9b83b04..6fc89184e0 100644 --- a/pmd/src/main/java/net/sourceforge/pmd/cpd/GUI.java +++ b/pmd/src/main/java/net/sourceforge/pmd/cpd/GUI.java @@ -106,19 +106,22 @@ public class GUI implements CPDListener { {"Fortran", new LanguageConfig() { public Language languageFor(LanguageFactory lf, Properties p) { return lf.createLanguage("fortran"); } public String[] extensions() { return new String[] {".rb" }; }; } }, - {"by extension...", new LanguageConfig() { - public Language languageFor(LanguageFactory lf, Properties p) { return lf.createLanguage(LanguageFactory.BY_EXTENSION, p); } - public String[] extensions() { return new String[] {"" }; }; } }, - {"PHP", new LanguageConfig() { + {"PHP", new LanguageConfig() { public Language languageFor(LanguageFactory lf, Properties p) { return lf.createLanguage("php"); } public String[] extensions() { return new String[] {".php" }; }; } }, - {"C#", new LanguageConfig() { + {"C#", new LanguageConfig() { public Language languageFor(LanguageFactory lf, Properties p) { return lf.createLanguage("cs"); } public String[] extensions() { return new String[] {".cs" }; }; } }, + {"Ecmascript", new LanguageConfig() { + public Language languageFor(LanguageFactory lf, Properties p) { return lf.createLanguage("js"); } + public String[] extensions() { return new String[] {".js" }; }; } }, + {"by extension...", new LanguageConfig() { + public Language languageFor(LanguageFactory lf, Properties p) { return lf.createLanguage(LanguageFactory.BY_EXTENSION, p); } + public String[] extensions() { return new String[] {"" }; }; } }, }; private static final int DEFAULT_CPD_MINIMUM_LENGTH = 75; - private static final Map LANGUAGE_CONFIGS_BY_LABEL = new HashMap(LANGUAGE_SETS.length); + private static final Map LANGUAGE_CONFIGS_BY_LABEL = new HashMap(LANGUAGE_SETS.length); private static final KeyStroke COPY_KEY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_C,ActionEvent.CTRL_MASK,false); private static final KeyStroke DELETE_KEY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0); @@ -148,12 +151,12 @@ public class GUI implements CPDListener { static { for (int i=0; i