com.google.javascript.jscomp
Class WarningsGuard

java.lang.Object
  extended by com.google.javascript.jscomp.WarningsGuard
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ComposeWarningsGuard, DiagnosticGroupWarningsGuard, ShowByPathWarningsGuard, StrictWarningsGuard, WhitelistWarningsGuard

public abstract class WarningsGuard
extends Object
implements Serializable

Class that allows to flexibly manage what to do with a reported warning/error. Guard has several choices: - return OFF - suppress the warning/error - return WARNING - return ERROR report it with high severity - return null. Does not know what to do with it. Lets the other guard decide what to do with it. Although the interface is very simple it allows you easyly customize what warnings you are interested in. For example there are could be several implementations: StrictGuard - {return ERROR}. All warnings should be treat as errors. SilentGuard - {if (WARNING) return OFF}. Suppress all warnings but still fail if js has errors. WhitelistGuard (if !whitelistErrors.contains(error) return ERROR) return error if it does not present in the whitelist.

See Also:
Serialized Form

Nested Class Summary
static class WarningsGuard.Priority
           
 
Constructor Summary
WarningsGuard()
           
 
Method Summary
protected  boolean disables(DiagnosticGroup group)
          Returns whether all warnings in the given diagnostic group will be filtered out.
protected  boolean enables(DiagnosticGroup group)
          Returns whether any of the warnings in the given diagnostic group will be upgraded to a warning or error.
protected  int getPriority()
          The priority in which warnings guards are applied.
abstract  CheckLevel level(JSError error)
          Returns a new check level for a given error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WarningsGuard

public WarningsGuard()
Method Detail

level

public abstract CheckLevel level(JSError error)
Returns a new check level for a given error. OFF - suppress it, ERROR - report as error. null means that this guard does not know what to do with the error. Null is extremely helpful when you have a chain of guards. If current guard returns null, then the next in the chain should process it.

Parameters:
error - a reported error.
Returns:
what level given error should have.

getPriority

protected int getPriority()
The priority in which warnings guards are applied. Lower means the guard will be applied sooner. Expressed on a scale of 1 to 100.


disables

protected boolean disables(DiagnosticGroup group)
Returns whether all warnings in the given diagnostic group will be filtered out. Used to determine which passes to skip.

Parameters:
group - A group of DiagnosticTypes.
Returns:
Whether all warnings of these types are disabled by this guard.

enables

protected boolean enables(DiagnosticGroup group)
Returns whether any of the warnings in the given diagnostic group will be upgraded to a warning or error.

Parameters:
group - A group of DiagnosticTypes.
Returns:
Whether any warnings of these types are enabled by this guard.