net.happygiraffe.jslint
Class JSLint

java.lang.Object
  extended by net.happygiraffe.jslint.JSLint

public class JSLint
extends Object

A utility class to check JavaScript source code for potential problems.

Version:
$Id$
Author:
dom

Constructor Summary
JSLint()
          Create a new JSLint object.
 
Method Summary
 void addOption(Option o)
          Add an option to change the behaviour of the lint.
 List<Issue> lint(String systemId, Reader reader)
          Check for problems in a Reader which contains JavaScript source.
 List<Issue> lint(String systemId, String javaScript)
          Check for problems in JavaScript source.
 String report(String javaScript)
          Report on what variables / functions are in use by this code.
 String report(String javaScript, boolean errorsOnly)
          Report on what variables / functions are in use by this code.
 void resetOptions()
          Clear out all options that have been set with addOption(Option).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JSLint

public JSLint()
       throws IOException
Create a new JSLint object. This reads in the jslint JavaScript source as a resource.

Throws:
IOException - if something went wrong reading jslint.js.
Method Detail

addOption

public void addOption(Option o)
Add an option to change the behaviour of the lint.

Parameters:
o - Any Option.

lint

public List<Issue> lint(String systemId,
                        Reader reader)
                 throws IOException
Check for problems in a Reader which contains JavaScript source.

Parameters:
systemId - a filename
reader - a Reader over JavaScript source code.
Returns:
a List of Issues describing any problems.
Throws:
IOException

lint

public List<Issue> lint(String systemId,
                        String javaScript)
Check for problems in JavaScript source.

Parameters:
systemId - a filename
javaScript - a String of JavaScript source code.
Returns:
a List of Issues describing any problems.

report

public String report(String javaScript)
Report on what variables / functions are in use by this code.

Parameters:
javaScript -
Returns:
an HTML report.

report

public String report(String javaScript,
                     boolean errorsOnly)
Report on what variables / functions are in use by this code.

Parameters:
javaScript -
errorsOnly - If a report consisting solely of the problems is desired.
Returns:
an HTML report.

resetOptions

public void resetOptions()
Clear out all options that have been set with addOption(Option).