com.google.javascript.jscomp
Class WhitelistWarningsGuard

java.lang.Object
  extended by com.google.javascript.jscomp.WarningsGuard
      extended by com.google.javascript.jscomp.WhitelistWarningsGuard
All Implemented Interfaces:
Serializable

public abstract class WhitelistWarningsGuard
extends WarningsGuard

An extension of WarningsGuard that provides functionality to maintain a list of warnings (white-list). It is subclasses' responsibility to decide what to do with the white-list by implementing the level function. Warnings are defined by the name of the js file and the first line of warnings description.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.javascript.jscomp.WarningsGuard
WarningsGuard.Priority
 
Constructor Summary
WhitelistWarningsGuard(Set<String> whiteList)
          This class depends on an input set that contains the white-list.
 
Method Summary
protected  boolean containWarning(String formattedWarning)
          Determines whether a given warning is included in the white-list.
static String formatWarning(JSError error)
           
static String formatWarning(JSError error, boolean withLineNumber)
           
static String getFirstLine(String warning)
           
 int getPriority()
          The priority in which warnings guards are applied.
static Set<String> loadWhitelistedJsWarnings(File file)
          Loads legacy warnings list from the file.
protected static Set<String> loadWhitelistedJsWarnings(com.google.common.io.InputSupplier<InputStreamReader> supplier)
          Loads legacy warnings list from the file.
 
Methods inherited from class com.google.javascript.jscomp.WarningsGuard
disables, enables, level
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WhitelistWarningsGuard

public WhitelistWarningsGuard(Set<String> whiteList)
This class depends on an input set that contains the white-list. The format of each white-list string is: :

Parameters:
whiteList - The set of js-warnings that are white-listed. This is expected to have similar format as formatWarning(JSError).
Method Detail

containWarning

protected boolean containWarning(String formattedWarning)
Determines whether a given warning is included in the white-list.

Parameters:
formattedWarning - the warning formatted by formatWarning
Returns:
whether the given warning is white-listed or not.

getPriority

public int getPriority()
Description copied from class: WarningsGuard
The priority in which warnings guards are applied. Lower means the guard will be applied sooner. Expressed on a scale of 1 to 100.

Overrides:
getPriority in class WarningsGuard

loadWhitelistedJsWarnings

public static Set<String> loadWhitelistedJsWarnings(File file)
Loads legacy warnings list from the file. As during development line numbers are changed very often - we just cut it and compare without ones.

Returns:
known legacy warnings without line numbers.

loadWhitelistedJsWarnings

protected static Set<String> loadWhitelistedJsWarnings(com.google.common.io.InputSupplier<InputStreamReader> supplier)
Loads legacy warnings list from the file. As during development line numbers are changed very often - we just cut it and compare without ones.

Returns:
known legacy warnings without line numbers.

formatWarning

public static String formatWarning(JSError error)

formatWarning

public static String formatWarning(JSError error,
                                   boolean withLineNumber)

getFirstLine

public static String getFirstLine(String warning)