Release 4.2.4.2.0
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6648 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -3,13 +3,13 @@
|
||||
<property name="config" value="config/"/>
|
||||
<property name="src" value="src/"/>
|
||||
<property name="etc" value="etc/"/>
|
||||
<property name="pmdjar" value="pmd-4.2.jar"/>
|
||||
<!-- first and second number for the pmd plugin -->
|
||||
<!-- third number JDeveloper Version 1:9.0.5-10.1.2, 2:10.1.3, 3:11.1.1 -->
|
||||
<!-- fourth and fifth number minor version number for the JDeveloper Plugin -->
|
||||
<property name="pluginversion" value="4.2.2.0.0"/>
|
||||
<property name="pmdjar" value="pmd-4.2.4.jar"/>
|
||||
<!-- first to third number for the pmd plugin -->
|
||||
<!-- fourth number JDeveloper Version 1:9.0.5-10.1.2, 2:10.1.3, 3:11.1.1 -->
|
||||
<!-- fifth number minor version number for the JDeveloper Plugin -->
|
||||
<property name="pluginversion" value="4.2.4.2.0"/>
|
||||
<property name="mainclass" value="net.sourceforge.pmd.jdeveloper"/>
|
||||
<property name="jdeveloper.dir" value="C:/Oracle/10gJD10133"/>
|
||||
<property name="jdeveloper.dir" value="C:/Oracle/10gJD10134"/>
|
||||
<property name="jdeveloper.ext.subdir" value="jdev/extensions"/>
|
||||
<property name="release.dir"
|
||||
value="C:/Documents and Settings/Torsten/My Documents/Eigene Programme/Java/PMD/releases"/>
|
||||
|
@ -2,10 +2,10 @@
|
||||
<update-bundle version="1.0" xmlns="http://xmlns.oracle.com/jdeveloper/updatebundle">
|
||||
<update id="net.sourceforge.pmd.jdeveloper" xmlns="http://xmlns.oracle.com/jdeveloper/update">
|
||||
<name>PMD JDeveloper Extension</name>
|
||||
<version>4.2.2.0.0</version>
|
||||
<version>4.2.4.2.0</version>
|
||||
<author>Torsten Kleiber</author>
|
||||
<author-url>http://pmd.sourceforge.net/</author-url>
|
||||
<description>Provides integrated support for PMD 4.2 in JDeveloper 10.1.3 - 11g Technology Preview 1.</description>
|
||||
<description>Provides integrated support for PMD 4.2.4 in JDeveloper 10.1.3 - 11g Technology Preview 1.</description>
|
||||
<requirements>
|
||||
<requires-extension id="oracle.jdeveloper" minVersion="10.1.3.00"
|
||||
maxVersion="11.1.1.0.20.45"/>
|
||||
|
@ -2,24 +2,24 @@
|
||||
<updates version="1.0" xmlns="http://xmlns.oracle.com/jdeveloper/updatecenter">
|
||||
<update id="net.sourceforge.pmd.jdeveloper" xmlns="http://xmlns.oracle.com/jdeveloper/update">
|
||||
<name>PMD JDeveloper Extension</name>
|
||||
<version>4.2.2.0.0</version>
|
||||
<version>4.2.4.2.0</version>
|
||||
<author>Torsten Kleiber</author>
|
||||
<author-url>http://pmd.sourceforge.net</author-url>
|
||||
<description>Provides integrated support for PMD 4.2 in JDeveloper 10.1.3 - 11g Technology Preview 1.</description>
|
||||
<bundle-url>http://downloads.sourceforge.net/pmd/pmd-jdeveloper1013-bundle-4.2.2.0.0.zip</bundle-url>
|
||||
<description>Provides integrated support for PMD 4.2.4 in JDeveloper 10.1.3 - 11g Technology Preview 1.</description>
|
||||
<bundle-url>http://downloads.sourceforge.net/pmd/pmd-jdeveloper1013-bundle-4.2.4.2.0.zip</bundle-url>
|
||||
<requirements>
|
||||
<requires-extension id="oracle.jdeveloper" minVersion="10.1.3.00" maxVersion="11.1.1.0.20.45" />
|
||||
</requirements>
|
||||
</update>
|
||||
<update id="net.sourceforge.pmd.jdeveloper" xmlns="http://xmlns.oracle.com/jdeveloper/update">
|
||||
<name>PMD JDeveloper Extension</name>
|
||||
<version>4.1.3.0.0</version>
|
||||
<version>4.2.4.3.0</version>
|
||||
<author>Torsten Kleiber</author>
|
||||
<author-url>http://pmd.sourceforge.net</author-url>
|
||||
<description>Provides integrated support for PMD 4.1 in JDeveloper 11g Technology Preview 2.</description>
|
||||
<bundle-url>http://downloads.sourceforge.net/pmd/pmd-jdeveloper1111-bundle-4.1.3.0.0.zip</bundle-url>
|
||||
<description>Provides integrated support for PMD 4.2.4 in JDeveloper 11g.</description>
|
||||
<bundle-url>http://downloads.sourceforge.net/pmd/pmd-jdeveloper1111-bundle-4.2.4.3.0.zip</bundle-url>
|
||||
<requirements>
|
||||
<requires-extension id="oracle.jdeveloper" minVersion="11.1.1.0.20.46.84" maxVersion="11.1.1.0.20.46.84" />
|
||||
<requires-extension id="oracle.jdeveloper" minVersion="11.1.1.0.31.51.56" maxVersion="11.1.1.0.31.51.56" />
|
||||
</requirements>
|
||||
</update>
|
||||
</updates>
|
@ -1,3 +1,6 @@
|
||||
October 21, 2008 - 4.2.4:
|
||||
Updated PMD version to 4.2.4 for 9.0.5 to 11.1.1
|
||||
|
||||
April 06, 2008 - 4.2:
|
||||
Updated PMD version to 4.2 for 9.0.5 to 10.1.3.
|
||||
11g version is not available because of classloading errors for jaxen lib.
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version = '1.0' encoding = 'UTF-8'?>
|
||||
<extension xmlns="http://jcp.org/jsr/198/extension-manifest"
|
||||
id="net.sourceforge.pmd.jdeveloper" version="4.2.2.0.0"
|
||||
id="net.sourceforge.pmd.jdeveloper" version="4.2.4.2.0"
|
||||
esdk-version="1.0">
|
||||
<name>PMD JDeveloper Extension</name>
|
||||
<owner>Torsten Kleiber</owner>
|
||||
@ -8,10 +8,9 @@
|
||||
<import>oracle.jdeveloper</import>
|
||||
</dependencies>
|
||||
<classpaths>
|
||||
<classpath>net.sourceforge.pmd.jdeveloper.4.2.2.0.0/lib/pmd-4.2.jar</classpath>
|
||||
<classpath>net.sourceforge.pmd.jdeveloper.4.2.2.0.0/lib/jaxen-1.1.1.jar</classpath>
|
||||
<classpath>net.sourceforge.pmd.jdeveloper.4.2.2.0.0/lib/asm-3.1.jar</classpath>
|
||||
<classpath>C:/Oracle/10gJD10133/jdk/jre/lib/rt.jar</classpath>
|
||||
<classpath>net.sourceforge.pmd.jdeveloper.4.2.4.2.0/lib/pmd-4.2.4.jar</classpath>
|
||||
<classpath>net.sourceforge.pmd.jdeveloper.4.2.4.2.0/lib/jaxen-1.1.1.jar</classpath>
|
||||
<classpath>net.sourceforge.pmd.jdeveloper.4.2.4.2.0/lib/asm-3.1.jar</classpath>
|
||||
</classpaths>
|
||||
<hooks>
|
||||
<jdeveloper-hook xmlns="http://xmlns.oracle.com/jdeveloper/1013/extension">
|
||||
@ -20,7 +19,7 @@
|
||||
</addins>
|
||||
</jdeveloper-hook>
|
||||
<feature-hook>
|
||||
<description>Provides integrated support for PMD 4.1 in JDeveloper 10.1.3 - 11g Technology Preview 1.</description>
|
||||
<description>Provides integrated support for PMD 4.2 in JDeveloper 10.1.3 - 11g Technology Preview 1.</description>
|
||||
<optional>false</optional>
|
||||
</feature-hook>
|
||||
</hooks>
|
||||
|
Binary file not shown.
@ -1,25 +1,25 @@
|
||||
<?xml version = '1.0' encoding = 'UTF-8'?>
|
||||
<jpr:project xmlns:jpr="http://xmlns.oracle.com/ide/project">
|
||||
<hash n="component-versions">
|
||||
<value n="oracle.adf.dt.migration.ProjectMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.adfdt.controller.jsf.addin.JSFProjectMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.adfdt.controller.struts.addin.db.ADFStrutsProjectMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.adfdt.controller.struts.addin.StrutsProjectMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.adfdtinternal.model.portlet.migration.WebCenterProjectMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.adfdtinternal.view.faces.addin.ADFFacesLibraryMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.bm.commonIde.ProjectUpgrader" v="10.1.3.3.0"/>
|
||||
<value n="oracle.ide.model.Project" v="10.1.3.3.0"/>
|
||||
<value n="oracle.ide.model.ResourcePathsMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.jbo.dt.jclient.migrator.JCProjectMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.jbo.dt.jdevx.ui.appnav.APProjectMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.jdeveloper.dbmodeler.migration.ProjectMigratorHelper" v="10.1.3.3.0"/>
|
||||
<value n="oracle.jdeveloper.ejb.EjbMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.jdeveloper.offlinedb.migration.OfflineDBProjectMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.jdevimpl.jsp.JsfLibraryMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.adf.dt.migration.ProjectMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.adfdt.controller.jsf.addin.JSFProjectMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.adfdt.controller.struts.addin.db.ADFStrutsProjectMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.adfdt.controller.struts.addin.StrutsProjectMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.adfdtinternal.model.portlet.migration.WebCenterProjectMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.adfdtinternal.view.faces.addin.ADFFacesLibraryMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.bm.commonIde.ProjectUpgrader" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.ide.model.Project" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.ide.model.ResourcePathsMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.jbo.dt.jclient.migrator.JCProjectMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.jbo.dt.jdevx.ui.appnav.APProjectMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.jdeveloper.dbmodeler.migration.ProjectMigratorHelper" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.jdeveloper.ejb.EjbMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.jdeveloper.offlinedb.migration.OfflineDBProjectMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.jdevimpl.jsp.JsfLibraryMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.jdevimpl.jsp.JspMigrator" v="10.1.3.1.0"/>
|
||||
<value n="oracle.jdevimpl.runner.RunConfigurationsMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.jdevimpl.webservices.WebServicesMigratorHelper" v="10.1.3.3.0"/>
|
||||
<value n="oracle.tip.tools.ide.pm.addin.PMProjectMigrator" v="10.1.3.3.0"/>
|
||||
<value n="oracle.jdevimpl.runner.RunConfigurationsMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.jdevimpl.webservices.WebServicesMigratorHelper" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.tip.tools.ide.pm.addin.PMProjectMigrator" v="10.1.3.3.0;10.1.3.4.0"/>
|
||||
<value n="oracle.toplink.addin.migration.TopLinkProjectMigrator" v="10.1.3.1.0"/>
|
||||
</hash>
|
||||
<list n="contentSets">
|
||||
@ -108,13 +108,13 @@
|
||||
<value n="custom" v="false"/>
|
||||
<value n="javaOptions" v=""/>
|
||||
<value n="name" v="Default"/>
|
||||
<url n="targetURL" path="../../../../../../../Oracle/10gJD10132/jdev/bin/jdev.conf"/>
|
||||
<url n="targetURL" path="../../../../../../../Oracle/10gJD10134/jdev/bin/jdev.conf"/>
|
||||
</hash>
|
||||
<hash n="Verbose">
|
||||
<value n="custom" v="false"/>
|
||||
<value n="javaOptions" v="-verbose:class"/>
|
||||
<value n="name" v="Verbose"/>
|
||||
<url n="targetURL" path="../../../../../../../Oracle/10gJD10132/jdev/bin/jdev.conf"/>
|
||||
<url n="targetURL" path="../../../../../../../Oracle/10gJD10134/jdev/bin/jdev.conf"/>
|
||||
</hash>
|
||||
</hash>
|
||||
<list n="runConfigurationList">
|
||||
@ -125,7 +125,7 @@
|
||||
<hash n="oracle.jdevimpl.config.JProjectLibraries">
|
||||
<list n="exportedReferences">
|
||||
<hash>
|
||||
<url n="id" path="../../../../../../../Oracle/10gJD10133/jdev/system/oracle.jdeveloper.10.1.3.41.57/PMD 4.2.library"/>
|
||||
<url n="id" path="../../../../../../../Oracle/10gJD10133/jdev/system/oracle.jdeveloper.10.1.3.41.57/PMD 4.2.4.library"/>
|
||||
<value n="isJDK" v="false"/>
|
||||
</hash>
|
||||
<hash>
|
||||
@ -140,7 +140,7 @@
|
||||
<hash n="internalDefinitions"/>
|
||||
<list n="libraryReferences">
|
||||
<hash>
|
||||
<url n="id" path="../../../../../../../Oracle/10gJD10133/jdev/system/oracle.jdeveloper.10.1.3.41.57/PMD 4.2.library"/>
|
||||
<url n="id" path="../../../../../../../Oracle/10gJD10133/jdev/system/oracle.jdeveloper.10.1.3.41.57/PMD 4.2.4.library"/>
|
||||
<value n="isJDK" v="false"/>
|
||||
</hash>
|
||||
<hash>
|
||||
|
@ -0,0 +1,87 @@
|
||||
package net.sourceforge.pmd.jdeveloper;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.event.TreeSelectionEvent;
|
||||
import javax.swing.event.TreeSelectionListener;
|
||||
import javax.swing.tree.DefaultMutableTreeNode;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
|
||||
import net.sourceforge.pmd.cpd.Match;
|
||||
import net.sourceforge.pmd.cpd.TokenEntry;
|
||||
|
||||
import oracle.ide.ceditor.CodeEditor;
|
||||
import oracle.ide.editor.EditorManager;
|
||||
import oracle.ide.layout.ViewId;
|
||||
import oracle.ide.log.AbstractLogPage;
|
||||
import oracle.ide.model.Node;
|
||||
|
||||
|
||||
public class CPDViolationPage extends AbstractLogPage implements TreeSelectionListener {
|
||||
|
||||
private final transient JScrollPane scrollPane;
|
||||
private final transient JTree tree;
|
||||
private final transient DefaultMutableTreeNode top;
|
||||
public final transient Map cpdFileToNodeMap =
|
||||
new HashMap(); // whew, this is kludgey
|
||||
|
||||
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(final TreeSelectionEvent event) {
|
||||
final DefaultMutableTreeNode node =
|
||||
(DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
|
||||
if (node != null && node.isLeaf()) {
|
||||
final CPDViolationWrapper nodeInfo =
|
||||
(CPDViolationWrapper)node.getUserObject();
|
||||
EditorManager.getEditorManager().openDefaultEditorInFrame(nodeInfo.file.getURL());
|
||||
((CodeEditor)EditorManager.getEditorManager().getCurrentEditor()).gotoLine(nodeInfo.mark.getBeginLine(),
|
||||
0,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(final Match match) {
|
||||
final Node file1 =
|
||||
(Node)cpdFileToNodeMap.get(match.getFirstMark().getTokenSrcID());
|
||||
final DefaultMutableTreeNode matchNode =
|
||||
new DefaultMutableTreeNode(file1.getShortLabel() + " contains a " +
|
||||
match.getLineCount() +
|
||||
" line block of duplicated code", true);
|
||||
top.add(matchNode);
|
||||
for (final Iterator i = match.iterator(); i.hasNext(); ) {
|
||||
final TokenEntry mark = (TokenEntry)i.next();
|
||||
final Node file = (Node)cpdFileToNodeMap.get(mark.getTokenSrcID());
|
||||
final 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() {
|
||||
top.removeAllChildren();
|
||||
tree.repaint();
|
||||
scrollPane.repaint();
|
||||
//tree.removeSelectionPath(new TreePath(new Object[] {top}));
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package net.sourceforge.pmd.jdeveloper;
|
||||
|
||||
import net.sourceforge.pmd.cpd.TokenEntry;
|
||||
|
||||
import oracle.ide.model.Node;
|
||||
|
||||
|
||||
public class CPDViolationWrapper {
|
||||
private final transient String label;
|
||||
public transient Node file;
|
||||
public transient TokenEntry mark;
|
||||
|
||||
public CPDViolationWrapper(final TokenEntry mark, final Node file,
|
||||
final String label) {
|
||||
this.label = label;
|
||||
this.mark = mark;
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return label;
|
||||
}
|
||||
}
|
@ -2,7 +2,9 @@ package net.sourceforge.pmd.jdeveloper;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
@ -38,9 +40,12 @@ public class FileStorage implements SettingsStorage {
|
||||
savedProperties.store(fos,
|
||||
"PMD-JDeveloper rule selections " + new Date());
|
||||
fos.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new SettingsException(e.getMessage());
|
||||
} catch (FileNotFoundException e) {
|
||||
Util.logMessage(e.getStackTrace());
|
||||
Util.showError(e, Plugin.PMD_TITLE);
|
||||
} catch (IOException e) {
|
||||
Util.logMessage(e.getStackTrace());
|
||||
Util.showError(e, Plugin.PMD_TITLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,11 +58,11 @@ public class FileStorage implements SettingsStorage {
|
||||
fis.close();
|
||||
return properties.getProperty(key);
|
||||
}
|
||||
return "false";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new SettingsException(e.getMessage());
|
||||
} catch (IOException e) {
|
||||
Util.logMessage(e.getStackTrace());
|
||||
Util.showError(e, Plugin.PMD_TITLE);
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,287 +0,0 @@
|
||||
package net.sourceforge.pmd.jdeveloper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.FactoryConfigurationError;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.transform.OutputKeys;
|
||||
import javax.xml.transform.Transformer;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RuleReference;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
|
||||
import net.sourceforge.pmd.RuleSetReference;
|
||||
|
||||
import org.w3c.dom.CDATASection;
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
/**
|
||||
* This class represents a way to serialize a RuleSet to an XML configuration file.
|
||||
* TODO Changed copy of net.sourceforge.pmd.RuleSetWriter
|
||||
* because of errors in oracle
|
||||
*/
|
||||
public class RuleSetWriter {
|
||||
private final OutputStream outputStream;
|
||||
private Document document;
|
||||
private Set<String> ruleSetFileNames;
|
||||
|
||||
public RuleSetWriter(OutputStream outputStream) {
|
||||
this.outputStream = outputStream;
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
public void write(RuleSet ruleSet) {
|
||||
try {
|
||||
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
|
||||
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
|
||||
this.document = documentBuilder.newDocument();
|
||||
this.ruleSetFileNames = new HashSet<String>();
|
||||
|
||||
Element ruleSetElement = createRuleSetElement(ruleSet);
|
||||
document.appendChild(ruleSetElement);
|
||||
|
||||
TransformerFactory transformerFactory = TransformerFactory.newInstance();
|
||||
Transformer transformer = transformerFactory.newTransformer();
|
||||
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
|
||||
// This is as close to pretty printing as we'll get using standard Java APIs.
|
||||
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
// TODO not working under oracle
|
||||
// transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "3");
|
||||
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
|
||||
transformer.transform(new DOMSource(document), new StreamResult(outputStream));
|
||||
} catch (DOMException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (FactoryConfigurationError e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ParserConfigurationException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (TransformerException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Element createRuleSetElement(RuleSet ruleSet) {
|
||||
Element ruleSetElement = document.createElement("ruleset");
|
||||
/* TODO not importable under oracle
|
||||
ruleSetElement.setAttribute("xmlns", "http://pmd.sf.net/ruleset/1.0.0");
|
||||
ruleSetElement.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:schemaLocation",
|
||||
"http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd");
|
||||
ruleSetElement.setAttributeNS("http://www.w3.org/2001/XMLSchema-instance", "xsi:noNamespaceSchemaLocation",
|
||||
"http://pmd.sf.net/ruleset_xml_schema.xsd");
|
||||
*/
|
||||
ruleSetElement.setAttribute("name", ruleSet.getName());
|
||||
|
||||
if (ruleSet.getLanguage() != null) {
|
||||
ruleSetElement.setAttribute("language", ruleSet.getLanguage().getName());
|
||||
}
|
||||
|
||||
Element descriptionElement = createDescriptionElement(ruleSet.getDescription());
|
||||
ruleSetElement.appendChild(descriptionElement);
|
||||
|
||||
for (String excludePattern : ruleSet.getExcludePatterns()) {
|
||||
Element excludePatternElement = createExcludePatternElement(excludePattern);
|
||||
ruleSetElement.appendChild(excludePatternElement);
|
||||
}
|
||||
for (String includePattern : ruleSet.getIncludePatterns()) {
|
||||
Element includePatternElement = createIncludePatternElement(includePattern);
|
||||
ruleSetElement.appendChild(includePatternElement);
|
||||
}
|
||||
for (Rule rule : ruleSet.getRules()) {
|
||||
Element ruleElement = createRuleElement(rule);
|
||||
if (ruleElement != null) {
|
||||
ruleSetElement.appendChild(ruleElement);
|
||||
}
|
||||
}
|
||||
|
||||
return ruleSetElement;
|
||||
}
|
||||
|
||||
private Element createDescriptionElement(String description) {
|
||||
return createTextElement("description", description);
|
||||
}
|
||||
|
||||
private Element createExcludePatternElement(String excludePattern) {
|
||||
return createTextElement("exclude-pattern", excludePattern);
|
||||
}
|
||||
|
||||
private Element createIncludePatternElement(String includePattern) {
|
||||
return createTextElement("include-pattern", includePattern);
|
||||
}
|
||||
|
||||
private Element createRuleElement(Rule rule) {
|
||||
if (rule instanceof RuleReference) {
|
||||
RuleReference ruleReference = (RuleReference)rule;
|
||||
RuleSetReference ruleSetReference = ruleReference.getRuleSetReference();
|
||||
if (ruleSetReference.isAllRules()) {
|
||||
if (!ruleSetFileNames.contains(ruleSetReference.getRuleSetFileName())) {
|
||||
ruleSetFileNames.add(ruleSetReference.getRuleSetFileName());
|
||||
Element ruleSetReferenceElement = createRuleSetReferenceElement(ruleSetReference);
|
||||
return ruleSetReferenceElement;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
String name = ruleReference.getOverriddenName();
|
||||
String ref = ruleReference.getRuleSetReference().getRuleSetFileName() + "/" + ruleReference.getName();
|
||||
String message = ruleReference.getOverriddenMessage();
|
||||
String externalInfoUrl = ruleReference.getOverriddenExternalInfoUrl();
|
||||
String description = ruleReference.getOverriddenDescription();
|
||||
Integer priority = ruleReference.getOverriddenPriority();
|
||||
Properties properties = ruleReference.getOverriddenProperties();
|
||||
List<String> examples = ruleReference.getOverriddenExamples();
|
||||
return createSingleRuleElement(name, null, ref, message, externalInfoUrl, null, null, null,
|
||||
description, priority, properties, examples);
|
||||
}
|
||||
} else {
|
||||
return createSingleRuleElement(rule.getName(), rule.getSince(), null, rule.getMessage(),
|
||||
rule.getExternalInfoUrl(), rule.getRuleClass(), rule.usesDFA(), rule.usesTypeResolution(),
|
||||
rule.getDescription(), rule.getPriority(), rule.getProperties(), rule.getExamples());
|
||||
}
|
||||
}
|
||||
|
||||
private Element createSingleRuleElement(String name, String since, String ref, String message,
|
||||
String externalInfoUrl, String clazz, Boolean dfa, Boolean typeResolution, String description,
|
||||
Integer priority, Properties properties, List<String> examples) {
|
||||
Element ruleElement = document.createElement("rule");
|
||||
if (name != null) {
|
||||
ruleElement.setAttribute("name", name);
|
||||
}
|
||||
if (since != null) {
|
||||
ruleElement.setAttribute("since", since);
|
||||
}
|
||||
if (ref != null) {
|
||||
ruleElement.setAttribute("ref", ref);
|
||||
}
|
||||
if (message != null) {
|
||||
ruleElement.setAttribute("message", message);
|
||||
}
|
||||
if (externalInfoUrl != null) {
|
||||
ruleElement.setAttribute("externalInfoUrl", externalInfoUrl);
|
||||
}
|
||||
if (clazz != null) {
|
||||
ruleElement.setAttribute("class", clazz);
|
||||
}
|
||||
if (dfa != null) {
|
||||
ruleElement.setAttribute("dfa", dfa.toString());
|
||||
}
|
||||
if (typeResolution != null) {
|
||||
ruleElement.setAttribute("typeResolution", typeResolution.toString());
|
||||
}
|
||||
|
||||
if (description != null) {
|
||||
Element descriptionElement = createDescriptionElement(description);
|
||||
ruleElement.appendChild(descriptionElement);
|
||||
}
|
||||
if (priority != null) {
|
||||
Element priorityElement = createPriorityElement(priority);
|
||||
ruleElement.appendChild(priorityElement);
|
||||
}
|
||||
if (properties != null) {
|
||||
Element propertiesElement = createPropertiesElement(properties);
|
||||
if (propertiesElement != null) {
|
||||
ruleElement.appendChild(propertiesElement);
|
||||
}
|
||||
}
|
||||
if (examples != null) {
|
||||
for (String example : examples) {
|
||||
Element exampleElement = createExampleElement(example);
|
||||
ruleElement.appendChild(exampleElement);
|
||||
}
|
||||
}
|
||||
return ruleElement;
|
||||
}
|
||||
|
||||
private Element createRuleSetReferenceElement(RuleSetReference ruleSetReference) {
|
||||
Element ruleSetReferenceElement = document.createElement("rule");
|
||||
ruleSetReferenceElement.setAttribute("ref", ruleSetReference.getRuleSetFileName());
|
||||
for (String exclude : ruleSetReference.getExcludes()) {
|
||||
Element excludeElement = createExcludeElement(exclude);
|
||||
ruleSetReferenceElement.appendChild(excludeElement);
|
||||
}
|
||||
return ruleSetReferenceElement;
|
||||
}
|
||||
|
||||
private Element createExcludeElement(String exclude) {
|
||||
return createTextElement("exclude", exclude);
|
||||
}
|
||||
|
||||
private Element createExampleElement(String example) {
|
||||
return createCDATASectionElement("example", example);
|
||||
}
|
||||
|
||||
private Element createPriorityElement(Integer priority) {
|
||||
return createTextElement("priority", priority.toString());
|
||||
}
|
||||
|
||||
private Element createPropertiesElement(Properties properties) {
|
||||
if (properties != null && !properties.isEmpty()) {
|
||||
Element propertiesElement = document.createElement("properties");
|
||||
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
|
||||
Element propertyElement = createPropertyElement(properties, (String)entry.getKey(),
|
||||
(String)entry.getValue());
|
||||
if (propertyElement != null) {
|
||||
propertiesElement.appendChild(propertyElement);
|
||||
}
|
||||
}
|
||||
return propertiesElement;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Element createPropertyElement(Properties properties, String key, String value) {
|
||||
Element propertyElement = document.createElement("property");
|
||||
propertyElement.setAttribute("name", key);
|
||||
if ("xpath".equals(key)) {
|
||||
if (properties.containsKey("pluginname")) {
|
||||
propertyElement.setAttribute("pluginname", properties.getProperty("pluginname"));
|
||||
}
|
||||
Element valueElement = createCDATASectionElement("value", value);
|
||||
propertyElement.appendChild(valueElement);
|
||||
} else if ("pluginname".equals(key)) {
|
||||
if (properties.containsKey("xpath")) {
|
||||
return null;
|
||||
} else {
|
||||
propertyElement.setAttribute("value", value);
|
||||
}
|
||||
} else {
|
||||
propertyElement.setAttribute("value", value);
|
||||
}
|
||||
|
||||
return propertyElement;
|
||||
}
|
||||
|
||||
private Element createTextElement(String name, String value) {
|
||||
Element element = document.createElement(name);
|
||||
Text text = document.createTextNode(value);
|
||||
element.appendChild(text);
|
||||
return element;
|
||||
}
|
||||
|
||||
private Element createCDATASectionElement(String name, String value) {
|
||||
Element element = document.createElement(name);
|
||||
CDATASection cdataSection = document.createCDATASection(value);
|
||||
element.appendChild(cdataSection);
|
||||
return element;
|
||||
}
|
||||
}
|
@ -46,8 +46,11 @@ public class SelectedRules {
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("Couldn't find a rule that mapped to the passed in JCheckBox " +
|
||||
candidate);
|
||||
final SettingsException exc =
|
||||
new SettingsException("Couldn't find a rule that mapped to the passed in JCheckBox " +
|
||||
candidate);
|
||||
Util.showError(exc, Plugin.PMD_TITLE);
|
||||
return null;
|
||||
}
|
||||
|
||||
public JCheckBox get(final Object key) {
|
||||
@ -77,12 +80,14 @@ public class SelectedRules {
|
||||
return newRuleSet;
|
||||
}
|
||||
|
||||
private JCheckBox createCheckBox(final String name, final SettingsStorage settings) {
|
||||
private JCheckBox createCheckBox(final String name,
|
||||
final SettingsStorage settings) {
|
||||
final JCheckBox box = new JCheckBox(name);
|
||||
try {
|
||||
box.setSelected(load(settings, name));
|
||||
} catch (SettingsException se) {
|
||||
System.out.println("Can't load settings so this rule will not be enabled");
|
||||
Util.logMessage(se.getStackTrace());
|
||||
Util.showError(se, Plugin.PMD_TITLE);
|
||||
}
|
||||
return box;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||
import net.sourceforge.pmd.RuleSets;
|
||||
import net.sourceforge.pmd.jdeveloper.RuleSetWriter;
|
||||
import net.sourceforge.pmd.RuleSetWriter;
|
||||
|
||||
import oracle.ide.panels.DefaultTraversablePanel;
|
||||
import oracle.ide.panels.TraversableContext;
|
||||
@ -163,7 +163,8 @@ public class SettingsPanel extends DefaultTraversablePanel {
|
||||
try {
|
||||
rules = new SelectedRules(createSettingsStorage());
|
||||
} catch (RuleSetNotFoundException rsne) {
|
||||
rsne.printStackTrace();
|
||||
Util.logMessage(rsne.getStackTrace());
|
||||
Util.showError(rsne, Plugin.PMD_TITLE);
|
||||
}
|
||||
|
||||
final JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
@ -237,11 +238,11 @@ public class SettingsPanel extends DefaultTraversablePanel {
|
||||
try {
|
||||
ruleSets = factory.createRuleSets(fileLocation);
|
||||
} catch (RuleSetNotFoundException e) {
|
||||
System.err.println("Error during reading ruleset : " +
|
||||
e.getMessage());
|
||||
Util.logMessage(e.getStackTrace());
|
||||
Util.showError(e, Plugin.PMD_TITLE);
|
||||
}
|
||||
if (ruleSets == null) {
|
||||
System.out.println("No rules to import");
|
||||
Util.logMessage("No rules to import");
|
||||
} else {
|
||||
final ListModel model = rulesList.getModel();
|
||||
final Set<Rule> allRules = ruleSets.getAllRules();
|
||||
@ -271,26 +272,20 @@ public class SettingsPanel extends DefaultTraversablePanel {
|
||||
RuleSetWriter ruleSetWriter = null;
|
||||
try {
|
||||
outputStream = new FileOutputStream(fileLocation);
|
||||
ruleSetWriter = new RuleSetWriter(outputStream);
|
||||
ruleSetWriter = new RuleSetWriter(outputStream, false);
|
||||
ruleSetWriter.write(selectedRules);
|
||||
outputStream.flush();
|
||||
// } catch (RuntimeException e) {
|
||||
// JOptionPane.showMessageDialog(null,
|
||||
// "Can't save selected rules to the file " +
|
||||
// e.getMessage(),
|
||||
// "Can't save settings",
|
||||
// JOptionPane.ERROR_MESSAGE);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error during file transfer : " +
|
||||
e.getMessage());
|
||||
Util.logMessage(e.getStackTrace());
|
||||
Util.showError(e, Plugin.PMD_TITLE);
|
||||
} finally {
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
ruleSetWriter.close();
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Error during file transfer closing : " +
|
||||
e.getMessage());
|
||||
Util.logMessage(e.getStackTrace());
|
||||
Util.showError(e, Plugin.PMD_TITLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,35 @@
|
||||
package net.sourceforge.pmd.jdeveloper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import oracle.ide.Ide;
|
||||
import oracle.ide.log.LogManager;
|
||||
|
||||
import oracle.javatools.dialogs.ExceptionDialog;
|
||||
|
||||
|
||||
final class Util {
|
||||
private Util() {
|
||||
}
|
||||
|
||||
public static void logMessage(final String msg) {
|
||||
LogManager.getLogManager().showLog();
|
||||
LogManager.getLogManager().getMsgPage().log(msg + "\n");
|
||||
}
|
||||
|
||||
public static void logMessage(final StackTraceElement[] stack) {
|
||||
LogManager.getLogManager().showLog();
|
||||
// TODO Output as Stack
|
||||
LogManager.getLogManager().getMsgPage().log(Arrays.toString(stack) +
|
||||
"\n");
|
||||
}
|
||||
|
||||
public static void showError(final Exception exc, final String title) {
|
||||
// JOptionPane.showMessageDialog(null,
|
||||
// "Error while running " + title + ": " +
|
||||
// "\n" + exc.getMessage(), title,
|
||||
// JOptionPane.ERROR_MESSAGE);
|
||||
ExceptionDialog.showExceptionDialog(Ide.getMainWindow(), exc);
|
||||
}
|
||||
|
||||
}
|
@ -7,24 +7,27 @@ import oracle.ide.Context;
|
||||
|
||||
import oracle.jdeveloper.compiler.OjcConfiguration;
|
||||
|
||||
class Version {
|
||||
final class Version {
|
||||
private Version() {
|
||||
}
|
||||
|
||||
public static void setJavaVersion(final Context context, final PMD pmd) {
|
||||
final OjcConfiguration config =
|
||||
OjcConfiguration.getInstance(context.getProject());
|
||||
final String source = config.getSource();
|
||||
if (source.equals("1.6")) {
|
||||
if ("1.6".equals(source)) {
|
||||
pmd.setJavaVersion(SourceType.JAVA_16);
|
||||
} else if (source.equals("1.5")) {
|
||||
} else if ("1.5".equals(source)) {
|
||||
pmd.setJavaVersion(SourceType.JAVA_15);
|
||||
} else if (source.equals("1.4")) {
|
||||
} else if ("1.4".equals(source)) {
|
||||
pmd.setJavaVersion(SourceType.JAVA_14);
|
||||
} else if (source.equals("1.3")) {
|
||||
} else if ("1.3".equals(source)) {
|
||||
pmd.setJavaVersion(SourceType.JAVA_13);
|
||||
}
|
||||
}
|
||||
|
||||
public static String version() {
|
||||
return "4.2.2.0.0";
|
||||
return "4.2.4.2.0";
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user