Package com.google.javascript.jscomp
Class WarningsGuard
java.lang.Object
com.google.javascript.jscomp.WarningsGuard
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ByPathWarningsGuard
,ComposeWarningsGuard
,DiagnosticGroupWarningsGuard
,ShowByPathWarningsGuard
,StrictWarningsGuard
,WhitelistWarningsGuard
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 easily 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:
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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
The priority in which warnings guards are applied.abstract CheckLevel
Returns a new check level for a given error.
-
Constructor Details
-
WarningsGuard
public WarningsGuard()
-
-
Method Details
-
level
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
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
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.
-