Rectified checkOpenBuffers to correctly parse buffers of any type whether remote or local.

git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2260 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
Jiger Patel
2003-09-15 08:17:47 +00:00
parent 3cd3d8c908
commit e121a70719
2 changed files with 27 additions and 15 deletions

View File

@ -1,4 +1,4 @@
<project name="PMDJEditPlugin" default="jar" basedir=".">
<project name="PMDPlugin" default="jar" basedir=".">
<property file="build.properties"></property>
<property name="config" value="."/>

View File

@ -133,16 +133,18 @@ public class PMDJEditPlugin extends EBPlugin {
// I'm putting the files in a Set to work around some
// odd behavior in jEdit - the buffer.getNext()
// seems to iterate over the files twice.
Set fileSet = new HashSet();
for (int i=0; i<jEdit.getBufferCount(); i++ ) {
Buffer buffer = jEdit.getFirstBuffer();
while (buffer != null) {
//System.out.println("file = " + buffer.getFile());
if (buffer.getName().endsWith(".java")) {
//fileSet.add(buffer.getFile());
instanceCheck(buffer,view);
}
buffer = buffer.getNext();
Buffer buffers[] = jEdit.getBuffers();
if(buffers != null)
{
for (int i=0; i<buffers.length; i++ )
{
if (buffers[i].getName().endsWith(".java"))
{
//fileSet.add(buffer.getFile());
System.out.println("checking = " + buffers[i].getPath());
instanceCheck(buffers[i],view, false);
}
}
}
@ -204,19 +206,25 @@ public class PMDJEditPlugin extends EBPlugin {
// check current buffer
public static void check(Buffer buffer, View view) {
instance.instanceCheck(buffer, view);
instance.instanceCheck(buffer, view, true);
}
public void instanceCheck(Buffer buffer, View view) {
public void instanceCheck(Buffer buffer, View view, boolean clearErrorList) {
try {
errorSource.clear();
if(clearErrorList)
{
errorSource.clear();
}
PMD pmd = new PMD();
SelectedRules selectedRuleSets = new SelectedRules();
RuleContext ctx = new RuleContext();
ctx.setReport(new Report());
ctx.setSourceCodeFilename(buffer.getPath());
pmd.processFile(new StringReader(view.getTextArea().getText()), selectedRuleSets.getSelectedRules(), ctx);
VFS vfs = buffer.getVFS();
pmd.processFile(vfs._createInputStream(vfs.createVFSSession(buffer.getPath(),view),buffer.getPath(),false,view), selectedRuleSets.getSelectedRules(), ctx);
if (ctx.getReport().isEmpty()) {
JOptionPane.showMessageDialog(jEdit.getFirstView(), "No problems found", "PMD", JOptionPane.INFORMATION_MESSAGE);
errorSource.clear();
@ -233,6 +241,10 @@ public class PMDJEditPlugin extends EBPlugin {
pmde.printStackTrace();
JOptionPane.showMessageDialog(jEdit.getFirstView(), "Error while processing " + buffer.getPath());
}
catch(Exception e)
{
e.printStackTrace();
}
}// check current buffer
private void processFiles(List files) {