forked from phoedos/pmd
rls preps; updated to work with 1013 final and pmd-3.5
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4174 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -3,9 +3,10 @@
|
||||
<property name="config" value="config/"/>
|
||||
<property name="src" value="src/"/>
|
||||
<property name="etc" value="etc/"/>
|
||||
<property name="pmdjar" value="pmd-3.4.jar"/>
|
||||
<property name="pluginversion" value="1.7"/>
|
||||
<property name="bundle.jarname" value="net.sourceforge.pmd.jdeveloper.${pluginversion}.jar"/>
|
||||
<property name="pmdjar" value="pmd-3.5.jar"/>
|
||||
<property name="pluginversion" value="1.8"/>
|
||||
<property name="bundle.dirname" value="net.sourceforge.pmd.jdeveloper.${pluginversion}"/>
|
||||
<property name="bundle.jarname" value="${bundle.dirname}.jar"/>
|
||||
<property name="jdeveloper.install.dir" value="c:/data/jdev1013/jdev/lib/ext/${ant.project.name}-${pluginversion}"/>
|
||||
<property name="linux.jdeveloper.install.dir" value="/home/tom/pmd/ides/jdev1013/jdev/extensions/"/>
|
||||
|
||||
@ -48,19 +49,22 @@
|
||||
<copy file="lib/${ant.project.name}-${pluginversion}.jar" todir="${jdeveloper.install.dir}/lib"/>
|
||||
<copy file="lib/${pmdjar}" todir="${jdeveloper.install.dir}/lib"/>
|
||||
<copy file="lib/jaxen-1.1-beta-7.jar" todir="${jdeveloper.install.dir}/lib"/>
|
||||
<copy file="lib/jakarta-oro-2.0.8.jar" todir="${jdeveloper.install.dir}/lib"/>
|
||||
</target>
|
||||
|
||||
<target name="deploylinux" depends="delete,jar">
|
||||
<mkdir dir="${linux.jdeveloper.install.dir}"/>
|
||||
<copy file="lib/${bundle.jarname}" todir="${linux.jdeveloper.install.dir}"/>
|
||||
<copy file="lib/${pmdjar}" todir="${linux.jdeveloper.install.dir}/net.sourceforge.pmd.jdeveloper.1.7/lib"/>
|
||||
<copy file="lib/jaxen-1.1-beta-7.jar" todir="${linux.jdeveloper.install.dir}/net.sourceforge.pmd.jdeveloper.1.7/lib"/>
|
||||
<copy file="lib/${pmdjar}" todir="${linux.jdeveloper.install.dir}/net.sourceforge.pmd.jdeveloper.${pluginversion}/lib"/>
|
||||
<copy file="lib/jaxen-1.1-beta-7.jar" todir="${linux.jdeveloper.install.dir}/net.sourceforge.pmd.jdeveloper.${pluginversion}/lib"/>
|
||||
<copy file="lib/jakarta-oro-2.0.8.jar" todir="${linux.jdeveloper.install.dir}/net.sourceforge.pmd.jdeveloper.${pluginversion}/lib"/>
|
||||
</target>
|
||||
|
||||
<target name="release" depends="clean,jar">
|
||||
<mkdir dir="tmp/${ant.project.name}-${pluginversion}/lib"/>
|
||||
<copy file="lib/${ant.project.name}-${pluginversion}.jar" todir="tmp/${ant.project.name}-${pluginversion}/lib/"/>
|
||||
<copy file="lib/${pmdjar}" todir="tmp/${ant.project.name}-${pluginversion}/lib/"/>
|
||||
<copy file="lib/jaxen-1.1-beta-7.jar" todir="tmp/${ant.project.name}-${pluginversion}/lib"/>
|
||||
<mkdir dir="tmp/${bundle.dirname}/lib"/>
|
||||
<copy file="lib/${bundle.jarname}" todir="tmp/${bundle.dirname}/lib/"/>
|
||||
<copy file="lib/jaxen-1.1-beta-7.jar" todir="tmp/${bundle.dirname}/lib"/>
|
||||
<copy file="lib/jakarta-oro-2.0.8.jar" todir="tmp/${bundle.dirname}/lib"/>
|
||||
<zip zipfile="${ant.project.name}-bin-${pluginversion}.zip" basedir="tmp/"/>
|
||||
<move file="${ant.project.name}-bin-${pluginversion}.zip" todir="/home/tom/tmp"/>
|
||||
<delete dir="tmp"/>
|
||||
@ -80,7 +84,7 @@
|
||||
<delete>
|
||||
<fileset dir="/home/tom/jdev1013/jdev/extensions/" includes="jaxen*.jar,*pmd*"/>
|
||||
</delete>
|
||||
<delete dir="/home/tom/jdev1013/jdev/extensions/net.sourceforge.pmd.jdeveloper.1.7"/>
|
||||
<delete dir="/home/tom/jdev1013/jdev/extensions/net.sourceforge.pmd.jdeveloper.${pluginversion}"/>
|
||||
|
||||
<delete dir="update-center-bundle/"/>
|
||||
|
||||
@ -90,6 +94,7 @@
|
||||
<copy file="lib/${bundle.jarname}" todir="update-center-bundle/"/>
|
||||
<copy file="lib/${pmdjar}" todir="update-center-bundle/net.sourceforge.pmd.jdeveloper.${pluginversion}/lib/"/>
|
||||
<copy file="lib/jaxen-1.1-beta-7.jar" todir="update-center-bundle/net.sourceforge.pmd.jdeveloper.${pluginversion}/lib/"/>
|
||||
<copy file="lib/jakarta-oro-2.0.8.jar" todir="update-center-bundle/net.sourceforge.pmd.jdeveloper.${pluginversion}/lib/"/>
|
||||
<zip destfile="update-center-bundle/pmd-jdeveloper1013-${pluginversion}.zip" basedir="update-center-bundle">
|
||||
<exclude name="center.xml"/>
|
||||
</zip>
|
||||
|
@ -4,7 +4,7 @@
|
||||
xmlns:u="http://xmlns.oracle.com/jdeveloper/update">
|
||||
<u:update id="net.sourceforge.pmd.jdeveloper">
|
||||
<u:name>PMD JDeveloper Extension</u:name>
|
||||
<u:version>1.7</u:version>
|
||||
<u:version>1.8</u:version>
|
||||
<u:author>Tom Copeland</u:author>
|
||||
<u:author-url>http://pmd.sf.net</u:author-url>
|
||||
<u:description>Install the PMD extension in your instance of JDeveloper</u:description>
|
||||
|
@ -4,10 +4,10 @@
|
||||
xmlns:u="http://xmlns.oracle.com/jdeveloper/update">
|
||||
<u:update id="net.sourceforge.pmd.jdeveloper">
|
||||
<u:name>PMD JDeveloper Extension</u:name>
|
||||
<u:version>1.7</u:version>
|
||||
<u:version>1.8</u:version>
|
||||
<u:author>Tom Copeland</u:author>
|
||||
<u:author-url>http://pmd.sf.net</u:author-url>
|
||||
<u:description>Install the PMD extension in your instance of JDeveloper</u:description>
|
||||
<u:bundle-url>http://pmd.sf.net/pmd-jdeveloper1013-1.7.zip</u:bundle-url>
|
||||
<u:bundle-url>http://pmd.sf.net/pmd-jdeveloper1013-1.8.zip</u:bundle-url>
|
||||
</u:update>
|
||||
</updates>
|
@ -1,8 +1,8 @@
|
||||
????, 2005 - 1.8:
|
||||
January 30, 2005 - 1.8:
|
||||
Better presentation of the rule violations.
|
||||
PMD menu item now appears on Package node
|
||||
Cleaned up code examples in preferences panel.
|
||||
Upgraded to PMD 3.4.
|
||||
Upgraded to PMD 3.5.
|
||||
|
||||
Oct 18, 2005 - 1.7:
|
||||
Merged in changes from Olaf Heimburger to update plugin to work with JDev 10.1.3 early access.
|
||||
|
@ -1,6 +1,6 @@
|
||||
update the release date in the changelog
|
||||
change the build.xml to reflect pmd-jdeveloper1013 release 1.6
|
||||
Update Plugin.version() to reflect release 1.6.
|
||||
change the build.xml to reflect pmd-jdeveloper1013 release 1.8
|
||||
Update Plugin.version() to reflect release 1.8.
|
||||
|
||||
Create the binary release:
|
||||
ant release
|
||||
@ -15,22 +15,22 @@ Create the src release:
|
||||
|
||||
CVSROOT=:ext:tomcopeland@cvs.sourceforge.net:/cvsroot/pmd && export CVSROOT
|
||||
cd ~/pmd/
|
||||
cvs -q tag -D tomorrow "pmd_jdeveloper1013_release_1_6" pmd-jdeveloper1013
|
||||
cvs -q tag -D tomorrow "pmd_jdeveloper1013_release_1_8" pmd-jdeveloper1013
|
||||
rm -rf ~/tmp/pmd-jdeveloper1013
|
||||
mkdir -p ~/tmp/pmd-jdeveloper1013
|
||||
cvs -q export -d tmp -r pmd_jdeveloper1013_release_1_6 pmd-jdeveloper1013
|
||||
cvs -q export -d tmp -r pmd_jdeveloper1013_release_1_8 pmd-jdeveloper1013
|
||||
mv tmp/* ~/tmp/pmd-jdeveloper1013
|
||||
rmdir tmp/
|
||||
cp pmd-jdeveloper1013/lib/pmd-jdeveloper1013-1.6.jar ~/tmp/pmd-jdeveloper1013/lib
|
||||
cp pmd-jdeveloper1013/lib/pmd-jdeveloper1013-1.8.jar ~/tmp/pmd-jdeveloper1013/lib
|
||||
cd ~/tmp
|
||||
zip -q -r pmd-jdeveloper1013-src-1.6.zip pmd-jdeveloper1013
|
||||
ncftpput upload.sourceforge.net incoming/ pmd-jdeveloper1013-bin-1.6.zip pmd-jdeveloper1013-src-1.6.zip
|
||||
zip -q -r pmd-jdeveloper1013-src-1.8.zip pmd-jdeveloper1013
|
||||
ncftpput upload.sourceforge.net incoming/ pmd-jdeveloper1013-bin-1.8.zip pmd-jdeveloper1013-src-1.8.zip
|
||||
rm -rf pmd-jdeveloper1013/
|
||||
|
||||
Go to Admin, Edit/Release Files, click on Add new release
|
||||
Paste stuff into the changelog/readme boxes
|
||||
Add the pmd-jdeveloper1013-src-1.6.zip file
|
||||
Add the pmd-jdeveloper1013-bin-1.6.zip file
|
||||
Add the pmd-jdeveloper1013-src-1.8.zip file
|
||||
Add the pmd-jdeveloper1013-bin-1.8.zip file
|
||||
Classify the file
|
||||
|
||||
Submit some news saying "hey, new release of the jdeveloper 1013 plugin!"
|
||||
|
@ -2,12 +2,13 @@
|
||||
<ex:extension xmlns:ex="http://jcp.org/jsr/198/extension-manifest"
|
||||
xmlns="http://xmlns.oracle.com/jdeveloper/1013/extension"
|
||||
xmlns:jdev="http://xmlns.oracle.com/jdeveloper/1013/jdev-libraries"
|
||||
id="net.sourceforge.pmd.jdeveloper" version="1.7.1" esdk-version="1.0">
|
||||
id="net.sourceforge.pmd.jdeveloper" version="1.8" esdk-version="1.0">
|
||||
<ex:name>PMD Extension</ex:name>
|
||||
<ex:owner>Tom Copeland</ex:owner>
|
||||
<ex:classpaths>
|
||||
<ex:classpath>${ide.extension.install.home}/lib/pmd-3.4.jar</ex:classpath>
|
||||
<ex:classpath>${ide.extension.install.home}/lib/pmd-3.5.jar</ex:classpath>
|
||||
<ex:classpath>${ide.extension.install.home}/lib/jaxen-1.1-beta-7.jar</ex:classpath>
|
||||
<ex:classpath>${ide.extension.install.home}/lib/jakarta-oro-2.0.8.jar</ex:classpath>
|
||||
</ex:classpaths>
|
||||
<ex:dependencies>
|
||||
<ex:import version="10.1.3">oracle.jdeveloper</ex:import>
|
||||
|
@ -6,7 +6,8 @@
|
||||
<extension>
|
||||
<addin>net.sourceforge.pmd.jdeveloper.Plugin</addin>
|
||||
<classpath>jaxen-1.1-beta-7.jar</classpath>
|
||||
<classpath>pmd-3.4.jar</classpath>
|
||||
<classpath>jakarta-oro-2.0.8.jar</classpath>
|
||||
<classpath>pmd-3.5.jar</classpath>
|
||||
<gallery>
|
||||
<name>net.sourceforge.pmd.jdeveloper.Plugin</name>
|
||||
<category>General</category>
|
||||
|
@ -7,8 +7,8 @@ set PATH=c:\j2sdk1.4.2_04\bin;c:\ant\bin\;%PATH%
|
||||
set CLASSPATH=../build/
|
||||
set CLASSPATH=%CLASSPATH%;../
|
||||
set CLASSPATH=%CLASSPATH%;../lib/jaxen-1.1-beta-7.jar
|
||||
set CLASSPATH=%CLASSPATH%;../lib/jakarta-oro-2.0.8.jar
|
||||
set CLASSPATH=%CLASSPATH%;../lib/xercesImpl-2.6.2.jar
|
||||
set CLASSPATH=%CLASSPATH%;../lib/xmlParserAPIs-2.6.2.jar
|
||||
set CLASSPATH=%CLASSPATH%;c:\javacc2.1\bin\lib\JavaCC.zip
|
||||
set CLASSPATH=%CLASSPATH%;c:\ant\lib\ant.jar
|
||||
set CLASSPATH=%CLASSPATH%;c:\ant\lib\junit.j
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -5,16 +5,23 @@ import net.sourceforge.pmd.PMDException;
|
||||
import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.RuleViolation;
|
||||
import net.sourceforge.pmd.cpd.CPD;
|
||||
import net.sourceforge.pmd.cpd.LanguageFactory;
|
||||
import net.sourceforge.pmd.cpd.Match;
|
||||
import net.sourceforge.pmd.cpd.TokenEntry;
|
||||
import oracle.ide.Addin;
|
||||
import oracle.ide.AddinManager;
|
||||
import oracle.ide.Context;
|
||||
import oracle.ide.Ide;
|
||||
import oracle.ide.ceditor.CodeEditor;
|
||||
import oracle.ide.config.IdeSettings;
|
||||
import oracle.ide.controller.ContextMenu;
|
||||
import oracle.ide.controller.ContextMenuListener;
|
||||
import oracle.ide.controller.Controller;
|
||||
import oracle.ide.controller.IdeAction;
|
||||
import oracle.ide.editor.EditorManager;
|
||||
import oracle.ide.layout.ViewId;
|
||||
import oracle.ide.log.AbstractLogPage;
|
||||
import oracle.ide.log.LogManager;
|
||||
import oracle.ide.log.LogPage;
|
||||
import oracle.ide.log.LogWindow;
|
||||
@ -29,6 +36,11 @@ import oracle.jdeveloper.compiler.IdeStorage;
|
||||
import oracle.jdeveloper.model.JavaSourceNode;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.awt.Component;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
@ -41,27 +53,113 @@ import java.util.Map;
|
||||
|
||||
public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
|
||||
public class CPDViolationPage extends AbstractLogPage implements TreeSelectionListener {
|
||||
|
||||
private JScrollPane scrollPane;
|
||||
private JTree tree;
|
||||
private DefaultMutableTreeNode top;
|
||||
|
||||
public CPDViolationPage() {
|
||||
super(new ViewId("PMDPage", Plugin.CPD_TITLE), null, false);
|
||||
top = new DefaultMutableTreeNode("CPD");
|
||||
tree = new JTree(top);
|
||||
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
|
||||
tree.addTreeSelectionListener(this);
|
||||
scrollPane = new JScrollPane(tree);
|
||||
}
|
||||
|
||||
public void valueChanged(TreeSelectionEvent e) {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
|
||||
if (node != null && node.isLeaf()) {
|
||||
CPDViolationWrapper nodeInfo = (CPDViolationWrapper)node.getUserObject();
|
||||
EditorManager.getEditorManager().openDefaultEditorInFrame(nodeInfo.file.getURL());
|
||||
((CodeEditor)EditorManager.getEditorManager().getCurrentEditor()).gotoLine(nodeInfo.mark.getBeginLine(), 0, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Match match) {
|
||||
Node file1 = (Node) cpdFileToNodeMap.get(match.getFirstMark().getTokenSrcID());
|
||||
DefaultMutableTreeNode matchNode = new DefaultMutableTreeNode(file1.getShortLabel() + " contains a " + match.getLineCount() + " line block of duplicated code", true);
|
||||
top.add(matchNode);
|
||||
for (Iterator i = match.iterator(); i.hasNext();) {
|
||||
TokenEntry mark = (TokenEntry) i.next();
|
||||
Node file = (Node) cpdFileToNodeMap.get(mark.getTokenSrcID());
|
||||
DefaultMutableTreeNode markTreeNode = new DefaultMutableTreeNode(new CPDViolationWrapper(mark, file, file.getShortLabel() + " has some at line " + mark.getBeginLine()), false);
|
||||
matchNode.add(markTreeNode);
|
||||
}
|
||||
}
|
||||
|
||||
public Component getGUI() {
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
public void clearAll() {
|
||||
System.out.println("clearing nodes");
|
||||
System.out.println("before: top now has " + top.getChildCount());
|
||||
top.removeAllChildren();
|
||||
System.out.println("after: top now has " + top.getChildCount());
|
||||
tree.repaint();
|
||||
scrollPane.repaint();
|
||||
//tree.removeSelectionPath(new TreePath(new Object[] {top}));
|
||||
}
|
||||
}
|
||||
|
||||
private static class CPDViolationWrapper {
|
||||
private String label;
|
||||
public Node file;
|
||||
public TokenEntry mark;
|
||||
public CPDViolationWrapper(TokenEntry mark, Node file, String label) {
|
||||
this.label = label;
|
||||
this.mark = mark;
|
||||
this.file = file;
|
||||
}
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String RUN_PMD_CMD = "net.sourceforge.pmd.jdeveloper.Check";
|
||||
public static final int RUN_PMD_CMD_ID = Ide.createCmdID("PMDJDeveloperPlugin.RUN_PMD_CMD_ID");
|
||||
public static final String TITLE = "PMD";
|
||||
|
||||
public static final String RUN_CPD_CMD = "net.sourceforge.pmd.jdeveloper.CheckCPD";
|
||||
public static final int RUN_CPD_CMD_ID = Ide.createCmdID("PMDJDeveloperPlugin.RUN_CPD_CMD_ID");
|
||||
|
||||
public static final String PMD_TITLE = "PMD";
|
||||
public static final String CPD_TITLE = "CPD";
|
||||
|
||||
private JMenuItem pmdMenuItem;
|
||||
private JMenuItem cpdMenuItem;
|
||||
|
||||
private RuleViolationPage ruleViolationPage;
|
||||
private CPDViolationPage cpdViolationPage;
|
||||
|
||||
private boolean added;
|
||||
private Map fileToNodeMap = new HashMap(); // whew, this is kludgey
|
||||
private Map pmdFileToNodeMap = new HashMap(); // whew, this is kludgey
|
||||
private Map cpdFileToNodeMap = new HashMap(); // whew, this is kludgey
|
||||
|
||||
// Addin
|
||||
public void initialize() {
|
||||
IdeAction action = IdeAction.get(RUN_PMD_CMD_ID, AddinManager.getAddinManager().getCommand(RUN_PMD_CMD_ID, RUN_PMD_CMD), TITLE, TITLE, null, null, null, true);
|
||||
action.addController(this);
|
||||
pmdMenuItem = Ide.getMenubar().createMenuItem(action);
|
||||
pmdMenuItem.setText(TITLE);
|
||||
IdeAction pmdAction = IdeAction.get(RUN_PMD_CMD_ID, AddinManager.getAddinManager().getCommand(RUN_PMD_CMD_ID, RUN_PMD_CMD), PMD_TITLE, PMD_TITLE, null, null, null, true);
|
||||
pmdAction.addController(this);
|
||||
pmdMenuItem = Ide.getMenubar().createMenuItem(pmdAction);
|
||||
pmdMenuItem.setText(PMD_TITLE);
|
||||
pmdMenuItem.setMnemonic('P');
|
||||
|
||||
/*
|
||||
IdeAction cpdAction = IdeAction.get(RUN_CPD_CMD_ID, AddinManager.getAddinManager().getCommand(RUN_CPD_CMD_ID, RUN_CPD_CMD), CPD_TITLE, CPD_TITLE, null, null, null, true);
|
||||
cpdAction.addController(this);
|
||||
cpdMenuItem = Ide.getMenubar().createMenuItem(cpdAction);
|
||||
cpdMenuItem.setText(CPD_TITLE);
|
||||
cpdMenuItem.setMnemonic('C');
|
||||
*/
|
||||
|
||||
NavigatorManager.getWorkspaceNavigatorManager().addContextMenuListener(this, null);
|
||||
EditorManager.getEditorManager().getContextMenu().addContextMenuListener(this, null);
|
||||
IdeSettings.registerUI(new Navigable(TITLE, SettingsPanel.class, new Navigable[]{}));
|
||||
Ide.getVersionInfo().addComponent(TITLE, " JDeveloper Extension " + version());
|
||||
IdeSettings.registerUI(new Navigable(PMD_TITLE, SettingsPanel.class, new Navigable[]{}));
|
||||
Ide.getVersionInfo().addComponent(PMD_TITLE, " JDeveloper Extension " + version());
|
||||
|
||||
ruleViolationPage = new RuleViolationPage();
|
||||
// cpdViolationPage = new CPDViolationPage();
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
@ -70,7 +168,7 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
}
|
||||
|
||||
public float version() {
|
||||
return 1.7f;
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public float ideVersion() {
|
||||
@ -96,7 +194,7 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
}
|
||||
if (ideAction.getCommandId() == RUN_PMD_CMD_ID) {
|
||||
try {
|
||||
fileToNodeMap.clear();
|
||||
pmdFileToNodeMap.clear();
|
||||
PMD pmd = new PMD();
|
||||
SelectedRules rules = new SelectedRules(SettingsPanel.createSettingsStorage());
|
||||
RuleContext ctx = new RuleContext();
|
||||
@ -108,7 +206,7 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
Project project = (Project) context.getElement();
|
||||
checkTree(project.getChildren(), pmd, rules, ctx);
|
||||
} else if (context.getElement() instanceof JavaSourceNode) {
|
||||
fileToNodeMap.put(context.getNode().getLongLabel(), context.getNode());
|
||||
pmdFileToNodeMap.put(context.getNode().getLongLabel(), context.getNode());
|
||||
ctx.setSourceCodeFilename(context.getNode().getLongLabel());
|
||||
pmd.processFile(context.getNode().getInputStream(), rules.getSelectedRules(), ctx);
|
||||
render(ctx);
|
||||
@ -117,10 +215,51 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
} catch (PMDException e) {
|
||||
e.printStackTrace();
|
||||
e.getReason().printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Error while running PMD: " + e.getMessage(), TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Error while running PMD: " + e.getMessage(), PMD_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Error while running PMD: " + e.getMessage(), TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Error while running PMD: " + e.getMessage(), PMD_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
} else if (ideAction.getCommandId() == RUN_CPD_CMD_ID) {
|
||||
try {
|
||||
cpdFileToNodeMap.clear();
|
||||
|
||||
// TODO get minimum tokens from prefs panel
|
||||
CPD cpd = new CPD(100, new LanguageFactory().createLanguage("java"));
|
||||
|
||||
// add all files to CPD
|
||||
if (context.getElement() instanceof RelativeDirectoryContextFolder) {
|
||||
RelativeDirectoryContextFolder folder = (RelativeDirectoryContextFolder) context.getElement();
|
||||
glomToCPD(folder.getChildren(), cpd);
|
||||
} else if (context.getElement() instanceof Project) {
|
||||
Project project = (Project) context.getElement();
|
||||
glomToCPD(project.getChildren(), cpd);
|
||||
} else if (context.getElement() instanceof JavaSourceNode) {
|
||||
cpd.add(new File(context.getNode().getLongLabel()));
|
||||
cpdFileToNodeMap.put(context.getNode().getLongLabel(), context.getNode());
|
||||
}
|
||||
|
||||
cpd.go();
|
||||
|
||||
cpdViolationPage.show();
|
||||
cpdViolationPage.clearAll();
|
||||
if (!cpd.getMatches().hasNext()) {
|
||||
JOptionPane.showMessageDialog(null, "No problems found", CPD_TITLE, JOptionPane.INFORMATION_MESSAGE);
|
||||
LogPage page = LogManager.getLogManager().getMsgPage();
|
||||
if (page instanceof LogWindow) {
|
||||
((LogWindow) page).show();
|
||||
}
|
||||
} else {
|
||||
for (Iterator i = cpd.getMatches(); i.hasNext();) {
|
||||
cpdViolationPage.add((Match) i.next());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JOptionPane.showMessageDialog(null, "Error while running CPD: " + e.getMessage(), CPD_TITLE, JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@ -141,6 +280,7 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
// RelativeDirectoryContextFolder -> a package
|
||||
if (doc instanceof Project || doc instanceof JavaSourceNode || doc instanceof RelativeDirectoryContextFolder) {
|
||||
contextMenu.add(pmdMenuItem);
|
||||
contextMenu.add(cpdMenuItem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,11 +293,12 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
return Package.getPackage("net.sourceforge.pmd.jdeveloper").getImplementationVersion();
|
||||
}
|
||||
|
||||
|
||||
private void render(RuleContext ctx) {
|
||||
ruleViolationPage.show();
|
||||
ruleViolationPage.clearAll();
|
||||
if (ctx.getReport().isEmpty()) {
|
||||
JOptionPane.showMessageDialog(null, "No problems found", TITLE, JOptionPane.INFORMATION_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "No problems found", PMD_TITLE, JOptionPane.INFORMATION_MESSAGE);
|
||||
LogPage page = LogManager.getLogManager().getMsgPage();
|
||||
if (page instanceof LogWindow) {
|
||||
((LogWindow) page).show();
|
||||
@ -166,13 +307,27 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
List list = new ArrayList();
|
||||
for (Iterator i = ctx.getReport().iterator(); i.hasNext();) {
|
||||
RuleViolation rv = (RuleViolation) i.next();
|
||||
Node node = (Node) fileToNodeMap.get(rv.getFilename());
|
||||
list.add(new IdeLog.Message(Ide.getActiveWorkspace(), Ide.getActiveProject(), new IdeStorage(node), rv.getDescription(), 2, rv.getNode().getBeginLine() + 1, rv.getNode().getBeginColumn()));
|
||||
Node node = (Node) pmdFileToNodeMap.get(rv.getFilename());
|
||||
list.add(new IdeLog.Message(Ide.getActiveWorkspace(), Ide.getActiveProject(), new IdeStorage(node), rv.getDescription(), 2, rv.getNode().getBeginLine(), rv.getNode().getBeginColumn()));
|
||||
}
|
||||
ruleViolationPage.add(list);
|
||||
}
|
||||
}
|
||||
|
||||
private void glomToCPD(Iterator i, CPD cpd) throws IOException {
|
||||
while (i.hasNext()) {
|
||||
Object obj = i.next();
|
||||
if (!(obj instanceof JavaSourceNode)) {
|
||||
continue;
|
||||
}
|
||||
JavaSourceNode candidate = (JavaSourceNode) obj;
|
||||
if (candidate.getLongLabel().endsWith(".java") && new File(candidate.getLongLabel()).exists()) {
|
||||
cpdFileToNodeMap.put(candidate.getLongLabel(), candidate);
|
||||
cpd.add(new File(candidate.getLongLabel()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void checkTree(Iterator i, PMD pmd, SelectedRules rules, RuleContext ctx) throws IOException, PMDException {
|
||||
while (i.hasNext()) {
|
||||
Object obj = i.next();
|
||||
@ -181,7 +336,7 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
}
|
||||
JavaSourceNode candidate = (JavaSourceNode) obj;
|
||||
if (candidate.getLongLabel().endsWith(".java") && new File(candidate.getLongLabel()).exists()) {
|
||||
fileToNodeMap.put(candidate.getLongLabel(), candidate);
|
||||
pmdFileToNodeMap.put(candidate.getLongLabel(), candidate);
|
||||
ctx.setSourceCodeFilename(candidate.getLongLabel());
|
||||
FileInputStream fis = new FileInputStream(new File(candidate.getLongLabel()));
|
||||
pmd.processFile(fis, rules.getSelectedRules(), ctx);
|
||||
@ -189,6 +344,6 @@ public class Plugin implements Addin, Controller, ContextMenuListener {
|
||||
}
|
||||
}
|
||||
render(ctx);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.util.List;
|
||||
public class RuleViolationPage extends CompilerPage {
|
||||
|
||||
public RuleViolationPage() {
|
||||
super(Plugin.TITLE, Plugin.TITLE, null);
|
||||
super(Plugin.PMD_TITLE, Plugin.PMD_TITLE, null);
|
||||
}
|
||||
|
||||
public void add(List list) {
|
||||
|
@ -19,7 +19,6 @@ import java.io.File;
|
||||
|
||||
public class SettingsPanel extends DefaultTraversablePanel {
|
||||
|
||||
|
||||
private class FindListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent evt){
|
||||
FileDialog fdlg = new FileDialog(new Frame(), "Find", FileDialog.LOAD);
|
||||
|
Reference in New Issue
Block a user