From f5461a958deb9389113c082f9101c9e2f66698a7 Mon Sep 17 00:00:00 2001 From: Dale Anson Date: Tue, 28 Jun 2011 22:10:25 +0000 Subject: [PATCH] Added "inclusions" regex. git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@7201 51baf565-9d33-0410-a72c-fc3788e3496d --- pmd-jedit/PMDPlugin/PMDPlugin.props | 1 + pmd-jedit/PMDPlugin/doc/jedit.html | 6 +++++- .../sourceforge/pmd/jedit/CPDFileFilter.java | 20 ++++++++++++++++++- .../sourceforge/pmd/jedit/PMDJEditPlugin.java | 16 +++++++++++++-- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/pmd-jedit/PMDPlugin/PMDPlugin.props b/pmd-jedit/PMDPlugin/PMDPlugin.props index 9514316ecb..2045c1d596 100644 --- a/pmd-jedit/PMDPlugin/PMDPlugin.props +++ b/pmd-jedit/PMDPlugin/PMDPlugin.props @@ -90,6 +90,7 @@ net.sf.pmd.Example=Example net.sf.pmd.Exclusions=Exclusions net.sf.pmd.Export_Output_as_=Export Output as: net.sf.pmd.Ignore_Literals_&_identifiers_when_detecting_Duplicate_Code=Ignore Literals & identifiers when detecting Duplicate Code +net.sf.pmb.Inclustions=Inclusions net.sf.pmd.Invalid_Renderer=Invalid Renderer net.sf.pmd.Minimum_Tile_Size>=Minimum Tile Size: net.sf.pmd.Minimum_Tile_size_>=Minimum Tile size : diff --git a/pmd-jedit/PMDPlugin/doc/jedit.html b/pmd-jedit/PMDPlugin/doc/jedit.html index a2ed8e8399..9873cbeb92 100644 --- a/pmd-jedit/PMDPlugin/doc/jedit.html +++ b/pmd-jedit/PMDPlugin/doc/jedit.html @@ -96,7 +96,11 @@

The CPD is very fast. It can also work on a variety of languages. Currently the fully supported languages are Java, JSP, PHP, C/C++, Fortran, Ruby, and Javascript. Additionally, CPD can work with just about every file mode supported by jEdit, although results may not be perfect as the modes not specifically supported use a generic tokenizer that may not suitable for a particular language.

- A new feature for running CPD in a directory is the ability to exclude files. This makes it much easier to run CPD on a high level directory in a Maven project so the files in the "target" directories can be skipped. Enter a regular expression in the "Exclusions" field in the directory chooser dialog. For Maven projects, enter .*?/target/.* to exclude all the "target" directories. The "Exclusions" regular expression works on the full path of a file, so this regex might not work in all cases (like maybe code for target.com?) + A new feature for running CPD in a directory is the ability to include files as specified by a regular expression. This makes it easy to narrow your search in a project that may have a lot of files with the same name. +

+ Another new feature for running CPD in a directory is the ability to exclude files. This makes it much easier to run CPD on a high level directory in a Maven project so the files in the "target" directories can be skipped. Enter a regular expression in the "Exclusions" field in the directory chooser dialog. For Maven projects, enter .*?/target/.* to exclude all the "target" directories. The "Exclusions" regular expression works on the full path of a file, so this regex might not work in all cases (like maybe code for target.com?) +

+ You can set both an inclusion regular expression and an exclusion regular expression. Files are first checked for inclusion then exclusion. This means the Maven example above is still valid.

Custom Rules

diff --git a/pmd-jedit/PMDPlugin/src/net/sourceforge/pmd/jedit/CPDFileFilter.java b/pmd-jedit/PMDPlugin/src/net/sourceforge/pmd/jedit/CPDFileFilter.java index 282dc5196d..a76374dd51 100644 --- a/pmd-jedit/PMDPlugin/src/net/sourceforge/pmd/jedit/CPDFileFilter.java +++ b/pmd-jedit/PMDPlugin/src/net/sourceforge/pmd/jedit/CPDFileFilter.java @@ -3,6 +3,7 @@ package net.sourceforge.pmd.jedit; import java.io.File; import java.util.regex.*; import javax.swing.filechooser.FileFilter; +import org.gjt.sp.util.Log; /** * This is a file filter for CPD. I wanted to use a FileNameExtension filter, but @@ -15,6 +16,7 @@ public class CPDFileFilter extends FileFilter implements Comparable 0) { + inclusionsPattern = Pattern.compile(regex); + } + } + public void setExclusions(String regex) { if (regex != null && regex.length() > 0) { exclusionsPattern = Pattern.compile(regex); @@ -50,7 +58,15 @@ public class CPDFileFilter extends FileFilter implements Comparable