Adding files to the project
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1166 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
BIN
pmd-netbeans/lib/pmd-1.0rc3.jar
Normal file
BIN
pmd-netbeans/lib/pmd-1.0rc3.jar
Normal file
Binary file not shown.
11
pmd-netbeans/src/manifest.mf
Normal file
11
pmd-netbeans/src/manifest.mf
Normal file
@@ -0,0 +1,11 @@
|
||||
Manifest-Version: 1.0
|
||||
OpenIDE-Module-Specification-Version: 0.11
|
||||
Created-By: NetBeans
|
||||
Class-Path: ext\pmd-1.0rc3.jar
|
||||
OpenIDE-Module: pmd
|
||||
OpenIDE-Module-Layer: pmd/mf-layer.xml
|
||||
|
||||
Name: pmd/RunPMDAction.class
|
||||
OpenIDE-Module-Class: Action
|
||||
|
||||
|
12
pmd-netbeans/src/pmd/Bundle.properties
Normal file
12
pmd-netbeans/src/pmd/Bundle.properties
Normal file
@@ -0,0 +1,12 @@
|
||||
## Resource bundle for package pmd
|
||||
#Thu Oct 17 16:52:26 CEST 2002
|
||||
LBL_loaderName=PMD Data Loader
|
||||
LBL_Action=pmd
|
||||
# Actions API
|
||||
LBL_Action=PMD
|
||||
|
||||
OpenIDE-Module-Name=PMD
|
||||
|
||||
OpenIDE-Module-Display-Category=Tools
|
||||
|
||||
OpenIDE-Module-Short-Description=Runs the pmd tool
|
98
pmd-netbeans/src/pmd/Fault.java
Normal file
98
pmd-netbeans/src/pmd/Fault.java
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Ole-Martin M<>rk
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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 PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package pmd;
|
||||
|
||||
/**
|
||||
* Contains a fault that pmd discovers
|
||||
* @author Ole-Martin M<>rk
|
||||
* @created 17. oktober 2002
|
||||
*/
|
||||
public class Fault implements Comparable
|
||||
{
|
||||
|
||||
private int line;
|
||||
private String clazz;
|
||||
private String message;
|
||||
|
||||
/**
|
||||
* Creates a new instance of Fault
|
||||
*
|
||||
* @param line the line of the fault
|
||||
* @param clazz the class of the fault
|
||||
* @param message the pmd message
|
||||
*/
|
||||
public Fault( int line, String clazz, String message )
|
||||
{
|
||||
this.line = line;
|
||||
this.message = message;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares <code>obj</code> to <code>this</code>.
|
||||
* Sorts by linenumber
|
||||
* @param obj the other object to compare with this
|
||||
* @return this.linenumber - that.linenumber
|
||||
*/
|
||||
public int compareTo( Object obj )
|
||||
{
|
||||
if( obj instanceof Fault ) {
|
||||
return line - ( ( Fault )obj ).line;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this object
|
||||
* @see #getFault()
|
||||
* @return the fault as a string
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return getFault();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fault as listed in the output pane
|
||||
* @return the fault as a string
|
||||
*/
|
||||
public String getFault()
|
||||
{
|
||||
return clazz + " [" + line + "]: " + message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the fault and returns the linenumber
|
||||
* @param fault the fault
|
||||
* @return the linenumber
|
||||
* @see #getFault()
|
||||
*/
|
||||
public static int getLineNum( String fault )
|
||||
{
|
||||
return Integer.parseInt( fault.substring( fault.indexOf( '[' ) + 1, fault.indexOf( ']' ) ) );
|
||||
}
|
||||
}
|
74
pmd-netbeans/src/pmd/FaultRegistry.java
Normal file
74
pmd-netbeans/src/pmd/FaultRegistry.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Ole-Martin M<>rk
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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 PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package pmd;
|
||||
|
||||
import java.util.HashMap;
|
||||
import org.openide.loaders.DataObject;
|
||||
|
||||
/**
|
||||
* A register holding all the faults the pmd finds. Used to lookup the coorect
|
||||
* file and line of the file.
|
||||
* @author Ole-Martin M<>rk
|
||||
* @created 24. oktober 2002
|
||||
*/
|
||||
abstract class FaultRegistry
|
||||
{
|
||||
|
||||
/** The registered faults */
|
||||
private static HashMap faults = new HashMap();
|
||||
|
||||
/**
|
||||
* Returns the associated dataobject
|
||||
* @param key the value of the fault
|
||||
* @return the associated dataobject
|
||||
* @see pmd.Fault#getFault()
|
||||
*/
|
||||
public static DataObject getDataObject( String key )
|
||||
{
|
||||
return ( DataObject )faults.get( key );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears all entries of the registry
|
||||
*/
|
||||
public static void clearRegistry()
|
||||
{
|
||||
faults.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a new fault
|
||||
* @param fault the fault that's used as key
|
||||
* @param object the object where the fault is
|
||||
* @see pmd.Fault#getFault()
|
||||
*/
|
||||
public static void registerFault( Fault fault, DataObject object )
|
||||
{
|
||||
faults.put( fault.getFault(), object );
|
||||
}
|
||||
}
|
67
pmd-netbeans/src/pmd/PMDOutputListener.java
Normal file
67
pmd-netbeans/src/pmd/PMDOutputListener.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Ole-Martin M<>rk
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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 PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package pmd;
|
||||
|
||||
import org.openide.cookies.EditorCookie;
|
||||
import org.openide.cookies.OpenCookie;
|
||||
import org.openide.loaders.DataObject;
|
||||
import org.openide.text.Line;
|
||||
import org.openide.text.Line.Set;
|
||||
import org.openide.windows.OutputEvent;
|
||||
import org.openide.windows.OutputListener;
|
||||
import org.openide.windows.WindowManager;
|
||||
|
||||
/**
|
||||
* @author Ole-Martin M<>rk
|
||||
* @created 24. oktober 2002
|
||||
*/
|
||||
public class PMDOutputListener implements OutputListener
|
||||
{
|
||||
|
||||
public void outputLineAction( OutputEvent outputEvent )
|
||||
{
|
||||
|
||||
DataObject object = FaultRegistry.getDataObject( outputEvent.getLine() );
|
||||
OpenCookie openC = ( OpenCookie )object.getCookie( OpenCookie.class );
|
||||
openC.open();
|
||||
EditorCookie cookie = ( EditorCookie )WindowManager.getDefault().getRegistry().getActivatedNodes()[0].getCookie( EditorCookie.class );
|
||||
Set set = cookie.getLineSet();
|
||||
int lineNum = Fault.getLineNum( outputEvent.getLine() );
|
||||
Line line = set.getOriginal( lineNum - 1 );
|
||||
line.markError();
|
||||
line.show( Line.SHOW_GOTO );
|
||||
}
|
||||
|
||||
public void outputLineCleared( OutputEvent outputEvent )
|
||||
{
|
||||
}
|
||||
|
||||
public void outputLineSelected( OutputEvent outputEvent )
|
||||
{
|
||||
}
|
||||
|
||||
}
|
241
pmd-netbeans/src/pmd/RunPMDAction.java
Normal file
241
pmd-netbeans/src/pmd/RunPMDAction.java
Normal file
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Ole-Martin M<>rk
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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 PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package pmd;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.sourceforge.pmd.PMD;
|
||||
import net.sourceforge.pmd.Report;
|
||||
import net.sourceforge.pmd.RuleContext;
|
||||
import net.sourceforge.pmd.RuleSet;
|
||||
import net.sourceforge.pmd.RuleSetFactory;
|
||||
import net.sourceforge.pmd.RuleSetNotFoundException;
|
||||
import net.sourceforge.pmd.RuleViolation;
|
||||
|
||||
import org.openide.ErrorManager;
|
||||
import org.openide.TopManager;
|
||||
import org.openide.cookies.EditorCookie;
|
||||
import org.openide.cookies.SourceCookie;
|
||||
import org.openide.filesystems.FileObject;
|
||||
import org.openide.loaders.DataFolder;
|
||||
import org.openide.loaders.DataObject;
|
||||
import org.openide.nodes.Node;
|
||||
import org.openide.util.HelpCtx;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.actions.CookieAction;
|
||||
import org.openide.windows.InputOutput;
|
||||
import org.openide.windows.OutputWriter;
|
||||
|
||||
import pmd.config.PMDOptionsSettings;
|
||||
|
||||
/**
|
||||
* Action that can always be invoked and work procedurally.
|
||||
*
|
||||
* @author Ole-Martin M<>rk
|
||||
* @created 17. oktober 2002
|
||||
*/
|
||||
public class RunPMDAction extends CookieAction
|
||||
{
|
||||
/** Indicates if any violations has been printed */
|
||||
private boolean printed = false;
|
||||
|
||||
/**
|
||||
* Gets the name of this action
|
||||
* @return the name of this action
|
||||
*/
|
||||
public String getName()
|
||||
{
|
||||
return NbBundle.getMessage( RunPMDAction.class, "LBL_Action" );
|
||||
}
|
||||
/**
|
||||
* Gets the filename of the icon associated with this action
|
||||
* @return the name of the icon
|
||||
*/
|
||||
protected String iconResource()
|
||||
{
|
||||
return "pmd/resources/MyActionIcon.gif";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns default help
|
||||
* @return HelpCtx.DEFAULT_HELP
|
||||
*/
|
||||
public HelpCtx getHelpCtx()
|
||||
{
|
||||
return HelpCtx.DEFAULT_HELP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cookies that can use this action
|
||||
* @return DataFolder.class and SourceCookie.class
|
||||
*/
|
||||
protected Class[] cookieClasses()
|
||||
{
|
||||
return new Class[]{DataFolder.class, SourceCookie.class};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the mode of this action
|
||||
* @see org.openide.util.actions.SystemAction#MODE_EXACTLY_ONE
|
||||
*/
|
||||
protected int mode()
|
||||
{
|
||||
return MODE_EXACTLY_ONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs pmd on the specified cookie
|
||||
* @param dataobject the dataobject to check
|
||||
* @param listener the listener to be used as listener for the output window
|
||||
* @param writer the writer to use to write to the output window
|
||||
* @exception IOException If the method can't read the files it should check
|
||||
* or can't write to the output window
|
||||
*/
|
||||
private void checkCookie( DataObject dataobject, PMDOutputListener listener, OutputWriter writer )
|
||||
throws IOException
|
||||
{
|
||||
SourceCookie cookie = ( SourceCookie )dataobject.getCookie( SourceCookie.class );
|
||||
Reader reader = getSourceReader( dataobject );
|
||||
String name = cookie.getSource().getClasses()[0].getName().getFullName();
|
||||
|
||||
PMD pmd = new PMD();
|
||||
RuleContext ctx = new RuleContext();
|
||||
Report report = new Report();
|
||||
ctx.setReport( report );
|
||||
ctx.setSourceCodeFilename( name );
|
||||
RuleSet set = constructRuleSets();
|
||||
pmd.processFile( reader, set, ctx );
|
||||
Iterator iterator = ctx.getReport().iterator();
|
||||
if( !ctx.getReport().isEmpty() ) {
|
||||
|
||||
ArrayList list = new ArrayList( ctx.getReport().size() );
|
||||
while( iterator.hasNext() ) {
|
||||
RuleViolation violation = ( RuleViolation )iterator.next();
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
buffer.append( violation.getRule().getName() ).append( ", " );
|
||||
buffer.append( violation.getDescription() );
|
||||
Fault fault = new Fault( violation.getLine(), name, buffer.toString() );
|
||||
list.add( fault );
|
||||
FaultRegistry.registerFault( fault, dataobject );
|
||||
}
|
||||
Collections.sort( list );
|
||||
for( int i = 0; i < list.size(); i++ ) {
|
||||
writer.println( String.valueOf( list.get( i ) ), listener );
|
||||
}
|
||||
printed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs the action this action is set up to do on the specified nodes
|
||||
* @param node the nodes that the action is involved on
|
||||
*/
|
||||
protected void performAction( Node[] node )
|
||||
{
|
||||
PMDOutputListener listener = new PMDOutputListener();
|
||||
FaultRegistry.clearRegistry();
|
||||
try {
|
||||
printed = false;
|
||||
SourceCookie cookie = (SourceCookie)node[0].getCookie( SourceCookie.class );
|
||||
InputOutput io = TopManager.getDefault().getIO( "PMD output", false );
|
||||
io.select();
|
||||
io.getOut().reset();
|
||||
//Checks to see if it's a java source file
|
||||
if( cookie != null ) {
|
||||
checkCookie( ( DataObject )node[0].getCookie( DataObject.class ), listener, io.getOut() );
|
||||
}
|
||||
//Or if it's a folder
|
||||
else {
|
||||
DataFolder folder = ( DataFolder )node[0].getCookie( DataFolder.class );
|
||||
Enumeration enumeration = folder.children( true );
|
||||
while( enumeration.hasMoreElements() ) {
|
||||
DataObject dataobject = ( DataObject )enumeration.nextElement();
|
||||
cookie = ( SourceCookie )dataobject.getCookie( SourceCookie.class );
|
||||
if( cookie != null ) {
|
||||
checkCookie( dataobject, listener, io.getOut() );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( !printed ) {
|
||||
io.getOut().println( "Everything ok", null );
|
||||
}
|
||||
|
||||
}
|
||||
catch( IOException e ) {
|
||||
ErrorManager.getDefault().notify( e );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs the ruleset.
|
||||
* @see pmd.config.PMDOptionsSettings#getRulesets()
|
||||
*/
|
||||
private static RuleSet constructRuleSets()
|
||||
{
|
||||
RuleSet rules = null;
|
||||
try {
|
||||
RuleSetFactory ruleSetFactory = new RuleSetFactory();
|
||||
rules = ruleSetFactory.createRuleSet(
|
||||
PMDOptionsSettings.getDefault().getRulesets() );
|
||||
}
|
||||
catch( RuleSetNotFoundException rsnfe ) {
|
||||
ErrorManager.getDefault().notify( rsnfe );
|
||||
}
|
||||
return rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the reader for the specified dataobject
|
||||
* @param dataobject the dataobject to read
|
||||
* @exception IOException if the object can't be read
|
||||
*/
|
||||
private Reader getSourceReader( DataObject dataobject ) throws IOException
|
||||
{
|
||||
Reader reader;
|
||||
EditorCookie editor = ( EditorCookie )dataobject.getCookie( EditorCookie.class );
|
||||
|
||||
//If it's the currently open document that's being checked
|
||||
if( editor.getOpenedPanes() != null ) {
|
||||
String text = editor.getOpenedPanes()[0].getText();
|
||||
reader = new StringReader( text );
|
||||
}
|
||||
else {
|
||||
Iterator iterator = dataobject.files().iterator();
|
||||
FileObject file = ( FileObject )iterator.next();
|
||||
reader = new InputStreamReader( file.getInputStream() );
|
||||
}
|
||||
return reader;
|
||||
}
|
||||
}
|
6
pmd-netbeans/src/pmd/config/Bundle.properties
Normal file
6
pmd-netbeans/src/pmd/config/Bundle.properties
Normal file
@@ -0,0 +1,6 @@
|
||||
# Options API
|
||||
LBL_settings=PMD Settings
|
||||
PROP_rulesets=Rulesets
|
||||
HINT_rulesets=The rulesets that the pmd action uses
|
||||
Services/pmd-config-option.settings=\PMD Settings
|
||||
UI/Services/IDEConfiguration/ServerAndExternalToolSettings/pmd-config-option.shadow=link
|
105
pmd-netbeans/src/pmd/config/PMDOptionsSettings.java
Normal file
105
pmd-netbeans/src/pmd/config/PMDOptionsSettings.java
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Ole-Martin M<>rk
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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 PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package pmd.config;
|
||||
|
||||
import org.openide.options.SystemOption;
|
||||
import org.openide.util.HelpCtx;
|
||||
import org.openide.util.NbBundle;
|
||||
|
||||
/**
|
||||
* Options for PMD netbeans
|
||||
*
|
||||
* @author Ole-Martin M<>rk
|
||||
* @created 24. oktober 2002
|
||||
*/
|
||||
public class PMDOptionsSettings extends SystemOption
|
||||
{
|
||||
|
||||
// private static final long serialVersionUID = ...;
|
||||
|
||||
/**
|
||||
* The constant for the rulesets property
|
||||
**/
|
||||
public static final String PROP_RULESETS = "rulesets";
|
||||
|
||||
// No constructor please!
|
||||
|
||||
/**
|
||||
* Sets the default rulesets and initializes the option
|
||||
*/
|
||||
protected void initialize()
|
||||
{
|
||||
super.initialize();
|
||||
setRulesets( "rulesets/basic.xml,rulesets/imports.xml,rulesets/unusedcode.xml,rulesets/braces.xml" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the displayName of these options
|
||||
* @return the displayname
|
||||
*/
|
||||
public String displayName()
|
||||
{
|
||||
return NbBundle.getMessage( PMDOptionsSettings.class, "LBL_settings" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default help
|
||||
*/
|
||||
public HelpCtx getHelpCtx()
|
||||
{
|
||||
return HelpCtx.DEFAULT_HELP;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default instance of this system option, for the convenience of associated
|
||||
* classes.
|
||||
*
|
||||
* @return The default value
|
||||
*/
|
||||
public static PMDOptionsSettings getDefault()
|
||||
{
|
||||
return ( PMDOptionsSettings )findObject( PMDOptionsSettings.class, true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rulesets property
|
||||
* @return the rulesets property
|
||||
*/
|
||||
public String getRulesets()
|
||||
{
|
||||
return ( String )getProperty( PROP_RULESETS );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rulesets property
|
||||
* @param rulesets the rulesets value to set
|
||||
*/
|
||||
public void setRulesets( String rulesets )
|
||||
{
|
||||
putProperty( PROP_RULESETS, rulesets, true );
|
||||
}
|
||||
}
|
77
pmd-netbeans/src/pmd/config/PMDOptionsSettingsBeanInfo.java
Normal file
77
pmd-netbeans/src/pmd/config/PMDOptionsSettingsBeanInfo.java
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Ole-Martin M<>rk
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 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 PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*/
|
||||
package pmd.config;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.beans.*;
|
||||
|
||||
import org.openide.ErrorManager;
|
||||
import org.openide.util.NbBundle;
|
||||
import org.openide.util.Utilities;
|
||||
|
||||
/**
|
||||
* Description of {@link PMDOptionsSettings}.
|
||||
*
|
||||
* @author Ole-Martin M<>rk
|
||||
* @created 24. oktober 2002
|
||||
*/
|
||||
public class PMDOptionsSettingsBeanInfo extends SimpleBeanInfo
|
||||
{
|
||||
|
||||
/**
|
||||
* Returns the description of the PMD properties
|
||||
* @return the description of the rulesets property
|
||||
*/
|
||||
public PropertyDescriptor[] getPropertyDescriptors()
|
||||
{
|
||||
try {
|
||||
PropertyDescriptor rulesets = new PropertyDescriptor( "rulesets", PMDOptionsSettings.class );
|
||||
rulesets.setDisplayName( NbBundle.getMessage( PMDOptionsSettingsBeanInfo.class, "PROP_rulesets" ) );
|
||||
rulesets.setShortDescription( NbBundle.getMessage( PMDOptionsSettingsBeanInfo.class, "HINT_rulesets" ) );
|
||||
return new PropertyDescriptor[]{rulesets};
|
||||
}
|
||||
catch( IntrospectionException ie ) {
|
||||
ErrorManager.getDefault().notify( ie );
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the icon for the property.
|
||||
* @return the icon
|
||||
* @param type the type of icon
|
||||
*/
|
||||
public Image getIcon( int type )
|
||||
{
|
||||
if( type == BeanInfo.ICON_COLOR_16x16 || type == BeanInfo.ICON_MONO_16x16 ) {
|
||||
return Utilities.loadImage( "pmd/resources/PMDOptionsSettingsIcon.gif" );
|
||||
}
|
||||
else {
|
||||
return Utilities.loadImage( "pmd/resources/PMDOptionsSettingsIcon32.gif" );
|
||||
}
|
||||
}
|
||||
}
|
8
pmd-netbeans/src/pmd/config/option.xml
Normal file
8
pmd-netbeans/src/pmd/config/option.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd">
|
||||
<settings version="1.0">
|
||||
<module name="PMD" spec="0.1"/>
|
||||
<instanceof class="org.openide.options.SystemOption"/>
|
||||
<instanceof class="pmd.config.PMDOptionsSettings"/>
|
||||
<instance class="pmd.config.PMDOptionsSettings"/>
|
||||
</settings>
|
34
pmd-netbeans/src/pmd/mf-layer.xml
Normal file
34
pmd-netbeans/src/pmd/mf-layer.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
|
||||
<filesystem>
|
||||
|
||||
|
||||
<folder name="Services">
|
||||
<file name="pmd-config-option.settings" url="config/option.xml">
|
||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="pmd.config.Bundle"/>
|
||||
<attr name="SystemFileSystem.icon" urlvalue="nbresloc:/pmd/resources/PMDOptionsSettingsIcon.gif"/>
|
||||
<attr name="name" stringvalue="PMD Settings"/>
|
||||
</file>
|
||||
</folder>
|
||||
<folder name="UI">
|
||||
<folder name="Services">
|
||||
<folder name="IDEConfiguration">
|
||||
<folder name="ServerAndExternalToolSettings">
|
||||
<!-- Note: line break in file contents necessary: -->
|
||||
<file name="pmd-config-option.shadow">
|
||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="pmd.config.Bundle"/>
|
||||
<![CDATA[Services/pmd-config-option.settings
|
||||
SystemFileSystem
|
||||
]]>
|
||||
</file>
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
</folder>
|
||||
<folder name="Actions">
|
||||
<file name="pmd-RunPMDAction.instance">
|
||||
<attr name="SystemFileSystem.localizingBundle" stringvalue="pmd.Bundle"/>
|
||||
</file>
|
||||
</folder>
|
||||
|
||||
</filesystem>
|
BIN
pmd-netbeans/src/pmd/resources/MyActionIcon.gif
Normal file
BIN
pmd-netbeans/src/pmd/resources/MyActionIcon.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 906 B |
BIN
pmd-netbeans/src/pmd/resources/PMDOptionsSettingsIcon.gif
Normal file
BIN
pmd-netbeans/src/pmd/resources/PMDOptionsSettingsIcon.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 821 B |
BIN
pmd-netbeans/src/pmd/resources/PMDOptionsSettingsIcon32.gif
Normal file
BIN
pmd-netbeans/src/pmd/resources/PMDOptionsSettingsIcon32.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 848 B |
Reference in New Issue
Block a user