From 85cc2b5a1027a8825bb4f7c402cd6a8e579ce439 Mon Sep 17 00:00:00 2001 From: Romain Pelisse Date: Sat, 24 Sep 2011 00:30:19 +0000 Subject: [PATCH] applied patch 2996539 : Add support for C# to CPD (simple parser) git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7328 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd/bin/cpd.sh | 4 ++-- pmd/etc/changelog.txt | 3 +++ pmd/src/net/sourceforge/pmd/cpd/CPDTask.java | 2 +- pmd/src/net/sourceforge/pmd/cpd/GUI.java | 4 ++++ pmd/src/net/sourceforge/pmd/cpd/LanguageFactory.java | 2 +- pmd/xdocs/cpd.xml | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/pmd/bin/cpd.sh b/pmd/bin/cpd.sh index 89aff04685..9ceb5a7d97 100755 --- a/pmd/bin/cpd.sh +++ b/pmd/bin/cpd.sh @@ -19,7 +19,7 @@ usage() { } supported_languages() { - echo "c, cpp, fortran, java, jsp, php, ruby" + echo "c, cpp, fortran, java, jsp, php, ruby,cs" } is_cygwin() { @@ -56,7 +56,7 @@ cygwin_paths() { language_settings() { readonly LANGUAGE=${LANGUAGE:-cpp} case "${LANGUAGE}" in - c|cpp|fortran|java|jsp|php|ruby) + c|cs|cpp|fortran|java|jsp|php|ruby) echo "Language is set to ${LANGUAGE}" ;; *) diff --git a/pmd/etc/changelog.txt b/pmd/etc/changelog.txt index c4ef9a478e..b0f95e37f2 100644 --- a/pmd/etc/changelog.txt +++ b/pmd/etc/changelog.txt @@ -320,8 +320,11 @@ XPathRules can now query using XPath 2.0 with 'version=2.0"', or XPath 2.0 in XP Rules can now use property values in messages, for example ${propertyName} will expand to the value of the 'propertyName' property on the Rule. Rules can now use violation specific values in messages, specifically ${variableName}, ${methodName}, ${className}, ${packageName}. New XPath function 'getCommentOn' can be used to search for strings in comments - Thanks to Andy Throgmorton + +CPD: Add .hxx and .hpp as valid file extension for CPD - Thanks to Ryan Pavlik Add options to to the CPD command line task - Thanks to Cd-Man +Add C# support for CPD - thanks to Florian Bauer Other changes: Rule property API upgrades: diff --git a/pmd/src/net/sourceforge/pmd/cpd/CPDTask.java b/pmd/src/net/sourceforge/pmd/cpd/CPDTask.java index 605877ccdc..17fbbbf350 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/CPDTask.java +++ b/pmd/src/net/sourceforge/pmd/cpd/CPDTask.java @@ -185,7 +185,7 @@ public class CPDTask extends Task { * new language here ? */ public static class LanguageAttribute extends EnumeratedAttribute { - private static final String[] LANGUAGES = new String[]{"java","jsp","cpp", "c","php", "ruby", "fortran"}; + private static final String[] LANGUAGES = new String[]{"java","jsp","cpp", "c","php", "ruby", "fortran", "cs"}; public String[] getValues() { return LANGUAGES; } diff --git a/pmd/src/net/sourceforge/pmd/cpd/GUI.java b/pmd/src/net/sourceforge/pmd/cpd/GUI.java index 343ae246fe..b04c6f4c50 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/GUI.java +++ b/pmd/src/net/sourceforge/pmd/cpd/GUI.java @@ -113,6 +113,10 @@ public class GUI implements CPDListener { public Language languageFor(LanguageFactory lf, Properties p) { return lf.createLanguage("php"); } public boolean ignoreLiteralsByDefault() { return false; } public String[] extensions() { return new String[] {".php" }; }; } }, + {"C#", new LanguageConfig() { + public Language languageFor(LanguageFactory lf, Properties p) { return lf.createLanguage("cs"); } + public boolean ignoreLiteralsByDefault() { return false; } + public String[] extensions() { return new String[] {".cs" }; }; } }, }; private static final int DEFAULT_CPD_MINIMUM_LENGTH = 75; diff --git a/pmd/src/net/sourceforge/pmd/cpd/LanguageFactory.java b/pmd/src/net/sourceforge/pmd/cpd/LanguageFactory.java index ed0625b207..ee23a08d4d 100644 --- a/pmd/src/net/sourceforge/pmd/cpd/LanguageFactory.java +++ b/pmd/src/net/sourceforge/pmd/cpd/LanguageFactory.java @@ -7,7 +7,7 @@ import java.util.Properties; public class LanguageFactory { - public static String[] supportedLanguages = new String[]{"java", "jsp", "cpp", "c", "php", "ruby","fortran", "ecmascript" }; + public static String[] supportedLanguages = new String[]{"java", "jsp", "cpp", "c", "php", "ruby","fortran", "ecmascript","cs" }; private static final String SUFFIX = "Language"; public static final String EXTENSION = "extension"; public static final String BY_EXTENSION = "by_extension"; diff --git a/pmd/xdocs/cpd.xml b/pmd/xdocs/cpd.xml index 5be0aa1884..09361ad9aa 100644 --- a/pmd/xdocs/cpd.xml +++ b/pmd/xdocs/cpd.xml @@ -76,7 +76,7 @@ language - Flag to select the appropriate language (e.g. cpp, java, php, ruby); defaults to java. + Flag to select the appropriate language (e.g. cpp, cs java, php, ruby, and ecmascript); defaults to java. No