Updated to work with PMD 1.1
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2087 51baf565-9d33-0410-a72c-fc3788e3496d
BIN
pmd-jbuilder/lib/jaxen-core-1.0-fcs.jar
Normal file
BIN
pmd-jbuilder/lib/pmd-1.1.jar
Normal file
BIN
pmd-jbuilder/lib/saxpath-1.0-fcs.jar
Normal file
BIN
pmd-jbuilder/lib/xercesImpl-2.0.2.jar
Normal file
BIN
pmd-jbuilder/lib/xmlParserAPIs-2.0.2.jar
Normal file
Before Width: | Height: | Size: 821 B After Width: | Height: | Size: 911 B |
Before Width: | Height: | Size: 821 B After Width: | Height: | Size: 913 B |
Before Width: | Height: | Size: 850 B After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 854 B After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1003 B After Width: | Height: | Size: 1005 B |
Before Width: | Height: | Size: 821 B After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 860 B After Width: | Height: | Size: 931 B |
@ -9,7 +9,7 @@ import net.sourceforge.pmd.cpd.CPDListener;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.event.WindowEvent;
|
||||
import net.sourceforge.pmd.cpd.Tile;
|
||||
//import net.sourceforge.pmd.cpd.Tile;
|
||||
|
||||
public class CPDDialog extends JFrame implements CPDListener, WindowListener {
|
||||
private CPD cpd;
|
||||
@ -25,7 +25,7 @@ public class CPDDialog extends JFrame implements CPDListener, WindowListener {
|
||||
public CPDDialog(CPD cpd) {
|
||||
super("CPD Status Monitor");
|
||||
this.cpd = cpd;
|
||||
cpd.setListener(this);
|
||||
cpd.setCpdListener(this);
|
||||
try {
|
||||
jbInit();
|
||||
}
|
||||
@ -39,7 +39,7 @@ public class CPDDialog extends JFrame implements CPDListener, WindowListener {
|
||||
}
|
||||
|
||||
|
||||
public boolean addedFile(int fileCount, File file) {
|
||||
public void addedFile(int fileCount, File file) {
|
||||
if (firstFile) {
|
||||
firstFile = false;
|
||||
jLabel1.setText("Adding Files...");
|
||||
@ -48,7 +48,6 @@ public class CPDDialog extends JFrame implements CPDListener, WindowListener {
|
||||
progress = 0;
|
||||
}
|
||||
jProgressBar1.setValue(++progress);
|
||||
return retCode;
|
||||
}
|
||||
|
||||
|
||||
@ -63,7 +62,7 @@ public class CPDDialog extends JFrame implements CPDListener, WindowListener {
|
||||
}
|
||||
|
||||
|
||||
public boolean addedNewTile(Tile tile, int tilesSoFar, int totalTiles) {
|
||||
/*public boolean addedNewTile(Tile tile, int tilesSoFar, int totalTiles) {
|
||||
if (firstNewTile) {
|
||||
firstNewTile = false;
|
||||
jLabel1.setText("Adding Tiles... ");
|
||||
@ -74,6 +73,11 @@ public class CPDDialog extends JFrame implements CPDListener, WindowListener {
|
||||
|
||||
jProgressBar1.setValue(tilesSoFar);
|
||||
return retCode;
|
||||
}*/
|
||||
|
||||
public void comparisonCountUpdate(long long0) {
|
||||
jLabel1.setText("Doing comparisons... " + long0);
|
||||
jProgressBar1.setValue((int)long0);
|
||||
}
|
||||
|
||||
public boolean wasCancelled() {
|
||||
|
@ -30,6 +30,7 @@ import com.borland.primetime.viewer.*;
|
||||
import net.sourceforge.pmd.*;
|
||||
import net.sourceforge.pmd.cpd.*;
|
||||
import com.borland.jbcl.control.MessageDialog;
|
||||
import net.sourceforge.pmd.cpd.LanguageFactory;
|
||||
|
||||
|
||||
|
||||
@ -52,6 +53,7 @@ public class PMDOpenTool {
|
||||
|
||||
static {
|
||||
try {
|
||||
|
||||
IMAGE_CHECK_PROJECT = new ImageIcon(PMDOpenTool.class.getClassLoader().getSystemResource("images/checkProject.gif"));
|
||||
IMAGE_CHECK_SELECTED_PACKAGE = new ImageIcon(PMDOpenTool.class.getClassLoader().getSystemResource("images/checkSelectedPackage.gif"));
|
||||
IMAGE_CPD = new ImageIcon(PMDOpenTool.class.getClassLoader().getSystemResource("images/cpd.gif"));
|
||||
@ -211,7 +213,6 @@ public class PMDOpenTool {
|
||||
*/
|
||||
public static Report instanceCheck (String text, RuleSet rules) {
|
||||
PMD pmd = new PMD();
|
||||
|
||||
RuleContext ctx = new RuleContext();
|
||||
if (rules == null) {
|
||||
rules = constructRuleSets();
|
||||
@ -329,8 +330,8 @@ public class PMDOpenTool {
|
||||
|
||||
static void checkCode(String srcCode, JavaFileNode node, RuleSet rules) {
|
||||
try {
|
||||
Report rpt = instanceCheck(srcCode, rules);
|
||||
|
||||
Report rpt = instanceCheck(srcCode, rules);
|
||||
if (rpt == null) {
|
||||
Message msg = new Message("Error Processing File");
|
||||
msg.setFont(stdMsgFont);
|
||||
@ -362,17 +363,20 @@ public class PMDOpenTool {
|
||||
Node node = Browser.getActiveBrowser().getActiveNode();
|
||||
if (node instanceof JavaFileNode) {
|
||||
Browser.getActiveBrowser().getMessageView().clearMessages(msgCat); //clear the message window
|
||||
TextNodeViewer viewer = (TextNodeViewer)Browser.getActiveBrowser().getViewerOfType(node,
|
||||
TextNodeViewer.class);
|
||||
TextNodeViewer viewer = (TextNodeViewer)Browser.getActiveBrowser().getViewerOfType(node, TextNodeViewer.class);
|
||||
if (viewer != null) {
|
||||
Document doc = viewer.getEditor().getDocument();
|
||||
try {
|
||||
checkCode(doc.getText(0, doc.getLength()), (JavaFileNode)node, null);
|
||||
}
|
||||
catch (Exception e){
|
||||
Browser.getActiveBrowser().getMessageView().addMessage(msgCat, "Error: " + e.toString());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
else {
|
||||
Browser.getActiveBrowser().getMessageView().addMessage(msgCat, "No active Browser.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,8 +445,8 @@ public class PMDOpenTool {
|
||||
private static void pmdCPD(PackageNode startingNode) {
|
||||
try {
|
||||
Browser.getActiveBrowser().getMessageView().clearMessages(cpdCat); //clear the message window
|
||||
final CPD cpd = new CPD();
|
||||
cpd.setMinimumTileSize(CPDPropertyGroup.PROP_MIN_TOKEN_COUNT.getInteger());
|
||||
final CPD cpd = new CPD(CPDPropertyGroup.PROP_MIN_TOKEN_COUNT.getInteger(), new LanguageFactory().createLanguage(LanguageFactory.JAVA_KEY));
|
||||
//cpd.setMinimumTileSize(CPDPropertyGroup.PROP_MIN_TOKEN_COUNT.getInteger());
|
||||
CPDDialog cpdd = new CPDDialog(cpd);
|
||||
|
||||
if (startingNode != null) { //rub cpd across the provided node
|
||||
@ -465,22 +469,28 @@ public class PMDOpenTool {
|
||||
cpdd.close();
|
||||
return;
|
||||
}
|
||||
Results results = cpd.getResults();
|
||||
//Results results = cpd.getResults();
|
||||
int resultCount = 0;
|
||||
if (results != null) {
|
||||
for (Iterator iter = results.getTiles(); iter.hasNext(); ) {
|
||||
Tile t = (Tile)iter.next();
|
||||
//if (results != null) {
|
||||
//for (Iterator iter = results.getTiles(); iter.hasNext(); ) {
|
||||
for (Iterator iter = cpd.getMatches(); iter.hasNext(); ) {
|
||||
//Tile t = (Tile)iter.next();
|
||||
Match m = (Match)iter.next();
|
||||
resultCount++;
|
||||
int tileLineCount = cpd.getLineCountFor(t);
|
||||
int dupCount = ((TileOccurrences)results).getOccurrenceCountFor(t);
|
||||
CPDMessage msg = CPDMessage.createMessage(String.valueOf(dupCount)+" duplicates in code set: " + resultCount, cpd.getImage(t));
|
||||
for (Iterator iter2 = results.getOccurrences(t); iter2.hasNext(); ) {
|
||||
TokenEntry te = (TokenEntry)iter2.next();
|
||||
msg.addChildMessage(te.getBeginLine(), tileLineCount, te.getTokenSrcID());
|
||||
int tileLineCount = m.getLineCount();
|
||||
int dupCount = 0;
|
||||
for (Iterator iter2 = m.iterator(); iter2.hasNext(); ) {
|
||||
dupCount++;
|
||||
iter2.next();
|
||||
}
|
||||
CPDMessage msg = CPDMessage.createMessage(String.valueOf(dupCount)+" duplicates in code set: " + resultCount, m.getSourceCodeSlice());
|
||||
for (Iterator iter2 = m.iterator(); iter2.hasNext(); ) {
|
||||
Mark mark = (Mark)iter2.next();
|
||||
msg.addChildMessage(mark.getBeginLine(), tileLineCount, mark.getTokenSrcID());
|
||||
}
|
||||
Browser.getActiveBrowser().getMessageView().addMessage(cpdCat, msg, false);
|
||||
}
|
||||
}
|
||||
|
||||
cpdd.close();
|
||||
}
|
||||
catch (Exception e) {
|
||||
@ -732,4 +742,3 @@ class HighlightMark extends LineMark {
|
||||
super(isLightWeight, highlightStyle);
|
||||
}
|
||||
}
|
||||
|
||||
|