From 076d4a09b1682cbf84d0f9e3841344b2baacf279 Mon Sep 17 00:00:00 2001 From: oinuma-kazuhiro Date: Tue, 30 Sep 2014 15:42:17 +0900 Subject: [PATCH 1/2] Add Go support to CPD --- pmd/.gitignore | 2 ++ .../net/sourceforge/pmd/cpd/GoLanguage.java | 15 +++++++++++ .../net/sourceforge/pmd/cpd/GoTokenizer.java | 27 +++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 pmd/src/main/java/net/sourceforge/pmd/cpd/GoLanguage.java create mode 100644 pmd/src/main/java/net/sourceforge/pmd/cpd/GoTokenizer.java diff --git a/pmd/.gitignore b/pmd/.gitignore index bbfdba11d8..fcf8e3bf52 100644 --- a/pmd/.gitignore +++ b/pmd/.gitignore @@ -7,3 +7,5 @@ bin/ .ruleset .settings/ *.patch +*.iml +.idea diff --git a/pmd/src/main/java/net/sourceforge/pmd/cpd/GoLanguage.java b/pmd/src/main/java/net/sourceforge/pmd/cpd/GoLanguage.java new file mode 100644 index 0000000000..35df28b34f --- /dev/null +++ b/pmd/src/main/java/net/sourceforge/pmd/cpd/GoLanguage.java @@ -0,0 +1,15 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ +package net.sourceforge.pmd.cpd; + +/** + * GoLang + * + * @author oinume@gmail.com + */ +public class GoLanguage extends AbstractLanguage { + public GoLanguage() { + super(new GoTokenizer(), ".go"); + } +} diff --git a/pmd/src/main/java/net/sourceforge/pmd/cpd/GoTokenizer.java b/pmd/src/main/java/net/sourceforge/pmd/cpd/GoTokenizer.java new file mode 100644 index 0000000000..0ec970d4c1 --- /dev/null +++ b/pmd/src/main/java/net/sourceforge/pmd/cpd/GoTokenizer.java @@ -0,0 +1,27 @@ +/** + * BSD-style license; for more info see http://pmd.sourceforge.net/license.html + */ +package net.sourceforge.pmd.cpd; + +import java.util.ArrayList; + +/** + * GoLang + * + * @author oinume@gmail.com + */ +public class GoTokenizer extends AbstractTokenizer { + public GoTokenizer() { + // setting markers for "string" in Go + this.stringToken = new ArrayList(); + this.stringToken.add("\""); + this.stringToken.add("`"); + + // setting markers for 'ignorable character' in Go + this.ignorableCharacter = new ArrayList(); + this.ignorableCharacter.add(";"); + + // setting markers for 'ignorable string' in Go + this.ignorableStmt = new ArrayList(); + } +} From 8ca38052188dab7f67a5b8e2e117443136eae627 Mon Sep 17 00:00:00 2001 From: oinuma-kazuhiro Date: Tue, 30 Sep 2014 15:44:52 +0900 Subject: [PATCH 2/2] Fix indent tab --- pmd/src/main/java/net/sourceforge/pmd/cpd/GoLanguage.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pmd/src/main/java/net/sourceforge/pmd/cpd/GoLanguage.java b/pmd/src/main/java/net/sourceforge/pmd/cpd/GoLanguage.java index 35df28b34f..c997669fdf 100644 --- a/pmd/src/main/java/net/sourceforge/pmd/cpd/GoLanguage.java +++ b/pmd/src/main/java/net/sourceforge/pmd/cpd/GoLanguage.java @@ -9,7 +9,7 @@ package net.sourceforge.pmd.cpd; * @author oinume@gmail.com */ public class GoLanguage extends AbstractLanguage { - public GoLanguage() { - super(new GoTokenizer(), ".go"); - } + public GoLanguage() { + super(new GoTokenizer(), ".go"); + } }