forked from phoedos/pmd
code cleanup: unused imports
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@6506 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
@ -20,7 +20,7 @@
|
||||
* * Neither the name of "PMD for Eclipse Development Team" nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
@ -35,25 +35,14 @@
|
||||
*/
|
||||
package net.sourceforge.pmd.core;
|
||||
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||
import net.sourceforge.pmd.core.ext.RuleSetsExtensionProcessor;
|
||||
import net.sourceforge.pmd.core.impl.RuleSetManagerImpl;
|
||||
import net.sourceforge.pmd.eclipse.plugin.PMDActivator;
|
||||
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.osgi.framework.Bundle;
|
||||
|
||||
/**
|
||||
* The plugin class for the Core PMD Plugin.
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
* @version $Revision$
|
||||
*
|
||||
*
|
||||
* $Log: PMDCorePlugin.java,v $
|
||||
* Revision 1.6 2007/06/24 15:07:29 phherlin
|
||||
* Integrate PMD v4.0rc1
|
||||
@ -62,16 +51,16 @@ import org.osgi.framework.Bundle;
|
||||
* Integrate PMD v3.9
|
||||
* Revision 1.4 2006/06/20 21:04:49 phherlin Enable
|
||||
* PMD and fix error level violations
|
||||
*
|
||||
*
|
||||
* Revision 1.3 2006/04/10 20:58:18 phherlin Update to PMD 3.6
|
||||
*
|
||||
*
|
||||
* Revision 1.2 2005/07/02 14:33:05 phherlin Implement the RuleSets extension
|
||||
* point
|
||||
*
|
||||
*
|
||||
* Revision 1.1 2005/06/07 22:39:57 phherlin Implementing extra ruleset
|
||||
* declaration
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class PMDCorePlugin {
|
||||
|
||||
|
@ -1,27 +1,10 @@
|
||||
package net.sourceforge.pmd.eclipse.plugin;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||
import net.sourceforge.pmd.ui.nls.StringKeys;
|
||||
import net.sourceforge.pmd.ui.nls.StringTable;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Plugin;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageRegistry;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.sourceforge.pmd.core.IRuleSetManager;
|
||||
import net.sourceforge.pmd.core.PluginConstants;
|
||||
import net.sourceforge.pmd.core.ext.RuleSetsExtensionProcessor;
|
||||
@ -38,13 +21,27 @@ import net.sourceforge.pmd.runtime.properties.impl.PropertiesFactoryImpl;
|
||||
import net.sourceforge.pmd.runtime.writer.IAstWriter;
|
||||
import net.sourceforge.pmd.runtime.writer.IRuleSetWriter;
|
||||
import net.sourceforge.pmd.runtime.writer.impl.WriterFactoryImpl;
|
||||
import net.sourceforge.pmd.ui.nls.StringKeys;
|
||||
import net.sourceforge.pmd.ui.nls.StringTable;
|
||||
|
||||
import org.apache.log4j.ConsoleAppender;
|
||||
import org.apache.log4j.Layout;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
import org.apache.log4j.RollingFileAppender;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.jface.dialogs.MessageDialog;
|
||||
import org.eclipse.jface.resource.ImageDescriptor;
|
||||
import org.eclipse.jface.resource.ImageRegistry;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
/**
|
||||
* The activator class controls the plug-in life cycle
|
||||
@ -56,7 +53,7 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
|
||||
// The shared instance
|
||||
private static PMDActivator plugin;
|
||||
|
||||
|
||||
/**
|
||||
* The constructor
|
||||
*/
|
||||
@ -108,7 +105,7 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
public static ImageDescriptor getImageDescriptor(String path) {
|
||||
return AbstractUIPlugin.imageDescriptorFromPlugin("net.sourceforge.pmd.eclipse.plugin", path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an image corresponding to the severity
|
||||
*/
|
||||
@ -128,7 +125,7 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
|
||||
/**
|
||||
* Helper method to log error
|
||||
*
|
||||
*
|
||||
* @see IStatus
|
||||
*/
|
||||
public void logError(String message, Throwable t) {
|
||||
@ -140,7 +137,7 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
|
||||
/**
|
||||
* Helper method to log error
|
||||
*
|
||||
*
|
||||
* @see IStatus
|
||||
*/
|
||||
public void logError(IStatus status) {
|
||||
@ -158,13 +155,13 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
Display.getDefault().syncExec(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
|
||||
|
||||
MessageDialog.openError(Display.getCurrent().getActiveShell(), getStringTable().getString(StringKeys.MSGKEY_ERROR_TITLE), message
|
||||
+ String.valueOf(t));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return an instance of the string table
|
||||
*/
|
||||
@ -172,7 +169,7 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
if (this.stringTable == null) {
|
||||
this.stringTable = new StringTable();
|
||||
}
|
||||
|
||||
|
||||
return this.stringTable;
|
||||
}
|
||||
|
||||
@ -211,28 +208,28 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
private static final String PMD_ECLIPSE_APPENDER_NAME = "PMDEclipseAppender";
|
||||
private IPreferencesFactory preferencesFactory = new PreferencesFactoryImpl();
|
||||
private IPropertiesFactory propertiesFactory = new PropertiesFactoryImpl();
|
||||
|
||||
|
||||
/**
|
||||
* Load the PMD plugin preferences
|
||||
*/
|
||||
public IPreferences loadPreferences() {
|
||||
return getPreferencesManager().loadPreferences();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the plugin preferences manager
|
||||
*/
|
||||
public IPreferencesManager getPreferencesManager() {
|
||||
return this.preferencesFactory.getPreferencesManager();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the plugin project properties manager
|
||||
*/
|
||||
public IProjectPropertiesManager getPropertiesManager() {
|
||||
return this.propertiesFactory.getProjectPropertiesManager();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param project a workspace project
|
||||
* @return the PMD properties for that project
|
||||
@ -243,27 +240,27 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
|
||||
/**
|
||||
* Helper method to log information
|
||||
*
|
||||
*
|
||||
* @see IStatus
|
||||
*/
|
||||
public void logInformation(String message) {
|
||||
getLog().log(new Status(IStatus.INFO, getBundle().getSymbolicName(), 0, message, null));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return an instance of an AST writer
|
||||
*/
|
||||
public IAstWriter getAstWriter() {
|
||||
return new WriterFactoryImpl().getAstWriter();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return an instance of a ruleset writer
|
||||
*/
|
||||
public IRuleSetWriter getRuleSetWriter() {
|
||||
return new WriterFactoryImpl().getRuleSetWriter();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply the log preferencs
|
||||
*/
|
||||
@ -286,17 +283,17 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
private void configureLogs(IPreferences preferences) {
|
||||
try {
|
||||
Layout layout = new PatternLayout("%d{yyyy/MM/dd HH:mm:ss,SSS} %-5p %-32c{1} %m%n");
|
||||
|
||||
|
||||
RollingFileAppender appender = new RollingFileAppender(layout, preferences.getLogFileName());
|
||||
appender.setName(PMD_ECLIPSE_APPENDER_NAME);
|
||||
appender.setMaxBackupIndex(1);
|
||||
appender.setMaxFileSize("10MB");
|
||||
|
||||
|
||||
Logger.getRootLogger().addAppender(new ConsoleAppender(layout));
|
||||
Logger.getRootLogger().setLevel(Level.WARN);
|
||||
Logger.getRootLogger().setAdditivity(false);
|
||||
|
||||
Logger.getLogger(ROOT_LOG_ID).addAppender(appender);
|
||||
|
||||
Logger.getLogger(ROOT_LOG_ID).addAppender(appender);
|
||||
Logger.getLogger(ROOT_LOG_ID).setLevel(preferences.getLogLevel());
|
||||
Logger.getLogger(ROOT_LOG_ID).setAdditivity(false);
|
||||
|
||||
@ -316,7 +313,7 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
|
||||
/**
|
||||
* Logs inside the Eclipse environment
|
||||
*
|
||||
*
|
||||
* @param severity the severity of the log (IStatus code)
|
||||
* @param message the message to log
|
||||
* @param t a possible throwable, may be null
|
||||
@ -326,13 +323,13 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
if (bundle != null) {
|
||||
getLog().log(new Status(severity, bundle.getSymbolicName(), 0, message, t));
|
||||
}
|
||||
|
||||
|
||||
// TODO : when bundle is not created yet (ie at startup), we cannot log ; find a way to log.
|
||||
}
|
||||
|
||||
/**
|
||||
* Registering the standard rulesets
|
||||
*
|
||||
*
|
||||
*/
|
||||
private void registerStandardRuleSets() {
|
||||
final RuleSetFactory factory = new RuleSetFactory();
|
||||
@ -350,7 +347,7 @@ public class PMDActivator extends AbstractUIPlugin {
|
||||
/**
|
||||
* Register additional rulesets that may be provided by a fragment. Find
|
||||
* extension points implementation and call them
|
||||
*
|
||||
*
|
||||
*/
|
||||
private void registerAdditionalRuleSets() {
|
||||
try {
|
||||
|
@ -2,39 +2,20 @@ package net.sourceforge.pmd.runtime.writer.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.FactoryConfigurationError;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
import net.sourceforge.pmd.Rule;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleSetWriter;
|
||||
import net.sourceforge.pmd.runtime.writer.IRuleSetWriter;
|
||||
import net.sourceforge.pmd.runtime.writer.WriterException;
|
||||
|
||||
import org.apache.xml.serialize.DOMSerializer;
|
||||
import org.apache.xml.serialize.OutputFormat;
|
||||
import org.apache.xml.serialize.XMLSerializer;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Generate an XML rule set file from a rule set
|
||||
* This class is a rewritting of the original from PMD engine
|
||||
* that doesn't support xpath properties !
|
||||
*
|
||||
*
|
||||
* @author Philippe Herlin
|
||||
* @version $Revision$
|
||||
*
|
||||
*
|
||||
* $Log$
|
||||
* Revision 1.5 2007/06/24 16:41:31 phherlin
|
||||
* Integrate PMD v4.0rc1
|
||||
@ -80,9 +61,9 @@ import org.w3c.dom.Text;
|
||||
* Fix bug #810858.
|
||||
* Complete refactoring of rule set generation. Using a DOM tree and the Xerces 2 serializer.
|
||||
*
|
||||
*
|
||||
*
|
||||
* -- Renaming to RuleSetWriterImpl --
|
||||
*
|
||||
*
|
||||
* Revision 1.2 2003/10/14 21:26:32 phherlin
|
||||
* Upgrading to PMD 1.2.2
|
||||
*
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.sourceforge.pmd.ui.actions;
|
||||
|
||||
import net.sourceforge.pmd.runtime.PMDRuntimePlugin;
|
||||
import net.sourceforge.pmd.ui.PMDUiConstants;
|
||||
import net.sourceforge.pmd.ui.PMDUiPlugin;
|
||||
import net.sourceforge.pmd.ui.nls.StringKeys;
|
||||
@ -14,12 +13,12 @@ import org.eclipse.ui.PartInitException;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author SebastianRaffel ( 26.05.2005 )
|
||||
*/
|
||||
public class ShowDataflowAction implements IObjectActionDelegate {
|
||||
private IWorkbenchPage workbenchPage;
|
||||
|
||||
|
||||
/* @see org.eclipse.ui.IObjectActionDelegate#setActivePart(org.eclipse.jface.action.IAction, org.eclipse.ui.IWorkbenchPart) */
|
||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||
this.workbenchPage = targetPart.getSite().getPage();
|
||||
@ -30,16 +29,16 @@ public class ShowDataflowAction implements IObjectActionDelegate {
|
||||
if (this.workbenchPage != null) {
|
||||
try {
|
||||
this.workbenchPage.showView(PMDUiConstants.ID_DATAFLOWVIEW);
|
||||
|
||||
|
||||
} catch (PartInitException pie) {
|
||||
PMDUiPlugin.getDefault().logError(
|
||||
StringKeys.MSGKEY_ERROR_VIEW_EXCEPTION +
|
||||
StringKeys.MSGKEY_ERROR_VIEW_EXCEPTION +
|
||||
this.toString(), pie);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection) */
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
action.setEnabled(true);
|
||||
|
Reference in New Issue
Block a user