Refactored Checker to not take a PrintStream. All errors are not logged to
standard output.
This commit is contained in:
parent
5a527aba40
commit
15c7162ea4
|
|
@ -288,7 +288,7 @@ public class CheckStyleTask
|
|||
final int numErrs;
|
||||
Checker c = null;
|
||||
try {
|
||||
c = new Checker(mConfig, System.out);
|
||||
c = new Checker(mConfig);
|
||||
AuditListener[] listeners = getListeners();
|
||||
for (int i = 0; i < listeners.length; i++) {
|
||||
c.addListener(listeners[i]);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import java.io.FileReader;
|
|||
import java.io.IOException;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -49,13 +48,12 @@ public class Checker
|
|||
/**
|
||||
* Constructs the object.
|
||||
* @param aConfig contains the configuration to check with
|
||||
* @param aLog the PrintStream to log messages to
|
||||
* @throws RESyntaxException unable to create a regexp object
|
||||
**/
|
||||
public Checker(Configuration aConfig, PrintStream aLog)
|
||||
public Checker(Configuration aConfig)
|
||||
throws RESyntaxException
|
||||
{
|
||||
mCache = new PropertyCacheFile(aConfig.getCacheFile(), aLog);
|
||||
mCache = new PropertyCacheFile(aConfig.getCacheFile());
|
||||
final Verifier v = new Verifier(aConfig);
|
||||
VerifierSingleton.setInstance(v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,8 +86,7 @@ public final class Main
|
|||
Checker c = null;
|
||||
try {
|
||||
c = new Checker(new Configuration(System.getProperties(),
|
||||
System.out),
|
||||
System.out);
|
||||
System.out));
|
||||
c.addListener(listener);
|
||||
}
|
||||
catch (RESyntaxException rese) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ import java.io.FileInputStream;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
|
|
@ -35,8 +34,6 @@ class PropertyCacheFile
|
|||
{
|
||||
/** name of file to store details **/
|
||||
private final String mDetailsFile;
|
||||
/** where to log messages **/
|
||||
private final PrintStream mLog;
|
||||
/** the details on files **/
|
||||
private final Properties mDetails = new Properties();
|
||||
|
||||
|
|
@ -45,11 +42,9 @@ class PropertyCacheFile
|
|||
*
|
||||
* @param aFileName name of properties file that contains details. if the
|
||||
file does not exist, it will be created
|
||||
* @param aLog where to log errors
|
||||
*/
|
||||
PropertyCacheFile(String aFileName, PrintStream aLog)
|
||||
PropertyCacheFile(String aFileName)
|
||||
{
|
||||
mLog = aLog;
|
||||
boolean setInActive = true;
|
||||
if (aFileName != null) {
|
||||
try {
|
||||
|
|
@ -61,8 +56,8 @@ class PropertyCacheFile
|
|||
setInActive = false;
|
||||
}
|
||||
catch (IOException e) {
|
||||
mLog.println("Unable to open cache file, ignoring.");
|
||||
e.printStackTrace(mLog);
|
||||
System.out.println("Unable to open cache file, ignoring.");
|
||||
e.printStackTrace(System.out);
|
||||
}
|
||||
}
|
||||
mDetailsFile = (setInActive) ? null : aFileName;
|
||||
|
|
@ -76,8 +71,8 @@ class PropertyCacheFile
|
|||
mDetails.store(new FileOutputStream(mDetailsFile), null);
|
||||
}
|
||||
catch (IOException e) {
|
||||
mLog.println("Unable to save cache file");
|
||||
e.printStackTrace(mLog);
|
||||
System.out.println("Unable to save cache file");
|
||||
e.printStackTrace(System.out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public class CheckerTest
|
|||
throws RESyntaxException
|
||||
{
|
||||
final AuditListener listener = new BriefLogger(mStream);
|
||||
final Checker c = new Checker(mConfig, mStream);
|
||||
final Checker c = new Checker(mConfig);
|
||||
c.addListener(listener);
|
||||
return c;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue