diff --git a/pmd-jedit/config/actions.xml b/pmd-jedit/config/actions.xml new file mode 100644 index 0000000000..c97a81948b --- /dev/null +++ b/pmd-jedit/config/actions.xml @@ -0,0 +1,9 @@ + + + + + + net.sourceforge.pmd.jedit.PMDJEditPlugin.check(view); + + + \ No newline at end of file diff --git a/pmd-jedit/config/jedit.html b/pmd-jedit/config/jedit.html new file mode 100644 index 0000000000..5aab6e6d78 --- /dev/null +++ b/pmd-jedit/config/jedit.html @@ -0,0 +1,32 @@ + + + PMD JEdit Plug-in Users' Guide

PMD JEdit Plug-in Users' Guide


Table of Contents

Installation
System requirements
Installation
Integration
License

Installation

System requirements

+The PMD JEdit Plug-in requires at least JEdit 4.0final. +

+

+Refer to the PMD user manual for the basic requirements to run PMD (You +may find the latest version on the PMD website, +http://PMD.sf.net/) +

Installation

+The Plug-in comes as a single .zip file. +Unzipping this file into a directory of your choice (referred +to as <HOME_DIR>) will produce two +subdirectories /bin and /docs. +

+Further installation is simple: just copy the file +<HOME_DIR>/bin/PMD-jedit-bundle-<version>.jar +into the /jars directory of your JEdit distribution. +JEdit will then need to be restarted before PMD begins working. +

Integration

+The software adds a new menu item group into the Plugins +menu of the editor view. Available is a new menu item: +

  • +Plugins->PMD->Check active buffer (Ctrl-Shift-F11). +

    +Checks the contents of the active text area. +

    +

    +
  • +

License

+The JEdit Plug-in is free software, released under the Apache license. +

\ No newline at end of file diff --git a/pmd-jedit/config/pmd.props b/pmd-jedit/config/pmd.props new file mode 100644 index 0000000000..7e9291c6d3 --- /dev/null +++ b/pmd-jedit/config/pmd.props @@ -0,0 +1,17 @@ +# +# Plugin properties +# +plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.name=PMD Java Source Code Checker +plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.author=Tom Copeland +plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.version=0.1 +plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.docs=jedit.html +plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.depend.0=jdk 1.3 +plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.depend.1=jedit 04.00.99.00 +plugin.net.sourceforge.pmd.jedit.PMDJEditPlugin.jars=pmd.jar + +# +# Menu properties +# +pmd-menu=pmd.check +pmd-menu.label=PMD +pmd.check.label=$Check active buffer diff --git a/pmd-jedit/etc/build.xml b/pmd-jedit/etc/build.xml new file mode 100644 index 0000000000..193563e977 --- /dev/null +++ b/pmd-jedit/etc/build.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pmd-jedit/etc/changelog.txt b/pmd-jedit/etc/changelog.txt new file mode 100644 index 0000000000..c53e2804ac --- /dev/null +++ b/pmd-jedit/etc/changelog.txt @@ -0,0 +1,2 @@ +???? 2002 - 0.1: +Initial release diff --git a/pmd-jedit/etc/doing_the_next_pmd_jedit_release.txt b/pmd-jedit/etc/doing_the_next_pmd_jedit_release.txt new file mode 100644 index 0000000000..ee2a5c83f3 --- /dev/null +++ b/pmd-jedit/etc/doing_the_next_pmd_jedit_release.txt @@ -0,0 +1,40 @@ +update the release date in the changelog + +ant release <-- new task, should create jar and zip it up into a pmd-jedit.zip that looks like: +jars/pmd-0.3.jar +jars/PMDJEditPlugin.jar + +so that it can be unzipped like an overlay + +cvs add -kb pmd-jedit-0.1.jar +cvs rm pmd-jedit-0.1.jar +cvs ci -m "adding new jar, removing old one" +cd c:\data\pmd-jedit +cvs rtag -D tomorrow "pmd_jedit_release_0_4" pmd-jedit +rmdir /q /s c:\tmp\pmd-jedit +mkdir c:\tmp\pmd-jedit +cvs export -d c:\tmp\pmd-jedit -r pmd_jedit_release_0_1 pmd-jedit +zip it up, rename it to pmd-jedit-0.1.zip +unzip it into c:\jedit +TESTS: Can you +1) run jedit ok? +2) open the options panel? +3) run PMD on a file? + +if you see a bug and fix it, you can delete the release using: +cvs rtag -d pmd_jedit_release_0_1 pmd +and then retag everything + +FTP the zip file to SF +ftp upload.sourceforge.net +generic userid/password: anonymous/tomcopeland@users.sourceforge.net +cd incoming +bin +put pmd-jedit-0.1.zip + +Go to Admin, Edit/Release Files, click on Add new release +Paste stuff into the changelog/readme boxes +Add the pmd-jedit-0.1.zip file +Classify the file + +Submit some news saying "hey, new release of the JEdit plugin!" diff --git a/pmd-jedit/etc/scp.bat b/pmd-jedit/etc/scp.bat new file mode 100755 index 0000000000..488147b70f --- /dev/null +++ b/pmd-jedit/etc/scp.bat @@ -0,0 +1,4 @@ +@echo off +set CLASSPATH=build/ +set CLASSPATH=%CLASSPATH%;lib\pmd-0.3.jar +set CLASSPATH=%CLASSPATH%;lib\jedit.jar \ No newline at end of file diff --git a/pmd-jedit/jedit-pmd.ipr b/pmd-jedit/jedit-pmd.ipr new file mode 100644 index 0000000000..d0e89733f2 --- /dev/null +++ b/pmd-jedit/jedit-pmd.ipr @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pmd-jedit/lib/jedit.jar b/pmd-jedit/lib/jedit.jar new file mode 100644 index 0000000000..fc3a4d4ce5 Binary files /dev/null and b/pmd-jedit/lib/jedit.jar differ diff --git a/pmd-jedit/lib/pmd-0.3.jar b/pmd-jedit/lib/pmd-0.3.jar new file mode 100644 index 0000000000..2f3f211450 Binary files /dev/null and b/pmd-jedit/lib/pmd-0.3.jar differ diff --git a/pmd-jedit/src/net/sourceforge/pmd/jedit/PMDJEditPlugin.java b/pmd-jedit/src/net/sourceforge/pmd/jedit/PMDJEditPlugin.java new file mode 100644 index 0000000000..0338cf4615 --- /dev/null +++ b/pmd-jedit/src/net/sourceforge/pmd/jedit/PMDJEditPlugin.java @@ -0,0 +1,92 @@ +/* + * User: tom + * Date: Jul 3, 2002 + * Time: 2:33:24 PM + */ +package net.sourceforge.pmd.jedit; + +import org.gjt.sp.jedit.*; +import org.gjt.sp.jedit.gui.OptionsDialog; + +import javax.swing.*; +import java.util.Vector; +import java.util.Iterator; +import java.io.FileNotFoundException; +import java.io.FileInputStream; +import java.io.StringBufferInputStream; + +import net.sourceforge.pmd.*; +import net.sourceforge.pmd.reports.ReportFactory; + +public class PMDJEditPlugin extends EBPlugin { + + +/* + private static class PMDJEditOptionPane extends AbstractOptionPane implements OptionPane { + public PMDJEditOptionPane() { + super("pmd.general"); + } + public String getName() { + return "PMD Option Pane"; + } + } +*/ + + public static final String NAME = "PMD"; + public static final String MENU = "pmd-menu"; + public static final String PROPERTY_PREFIX = "plugin.net.sourceforge.pmd.jedit."; +// public static final String OPTION_PREFIX = "options.pmd."; + + private static PMDJEditPlugin instance = new PMDJEditPlugin(); + + public void createMenuItems(Vector menuItems) { + menuItems.addElement(GUIUtilities.loadMenu(MENU)); + } + +/* + public void createOptionPanes(OptionsDialog dialog) { + dialog.addOptionPane(new PMDJEditOptionPane()); + } +*/ + + public void instanceCheck(View view) { + //view.getStatus().setMessage("HELLO PMD"); + String text = view.getTextArea().getText(); + + PMD pmd = new PMD(); + + ReportFactory rf = new ReportFactory(); + RuleContext ctx = new RuleContext(); + RuleSetFactory ruleSetFactory = new RuleSetFactory(); + RuleSet rules = ruleSetFactory.createRuleSet(pmd.getClass().getClassLoader().getResourceAsStream("rulesets/unusedcode.xml")); + + ctx.setReport(rf.createReport("xml")); + ctx.setSourceCodeFilename("this"); + try { + // TODO switch to use StringReader once PMD 0.4 gets released + pmd.processFile(new StringBufferInputStream(text), rules, ctx); + + String msg = ""; + for (Iterator i = ctx.getReport().iterator(); i.hasNext();) { + RuleViolation rv = (RuleViolation)i.next(); + msg += rv.getDescription() + " at line " + rv.getLine() + System.getProperty("line.separator"); + } + JOptionPane.showMessageDialog(view, msg, "PMD Results", JOptionPane.INFORMATION_MESSAGE); + } catch (FileNotFoundException fnfe) { + fnfe.printStackTrace(); + } + } + + public void instanceDisplayPreferencesDialog(View view) { + //view.getStatus().setMessage("HELLO PMD DIALOG"); + } + + public static void check(View view) { + instance.instanceCheck(view); + } + + public static void displayPreferencesDialog(View view) { + instance.instanceDisplayPreferencesDialog(view); + } + +}