Class ByPathWarningsGuard

java.lang.Object
com.google.javascript.jscomp.WarningsGuard
com.google.javascript.jscomp.ByPathWarningsGuard
All Implemented Interfaces:
Serializable

public class ByPathWarningsGuard extends WarningsGuard
An implementation of a WarningsGuard that can modify the CheckLevel based on the file that caused the warning, and whether this file matches a set of paths (specified either as include or exclude of path name parts).

For example:

 List paths = new ArrayList();
 paths.add("foo");
 WarningsGuard guard =
     ByPathWarningsGuard.forPath(paths, CheckLevel.ERROR, 1);
 
This guard will convert any warning that came from a file that contains "foo" in its path to an error.
See Also:
  • Method Details

    • forPath

      public static ByPathWarningsGuard forPath(List<String> paths, CheckLevel level)
      Parameters:
      paths - Paths for matching.
      level - The CheckLevel to apply on affected files.
      Returns:
      a new ByPathWarningsGuard that would affect any file in the given set of paths.
    • exceptPath

      public static ByPathWarningsGuard exceptPath(List<String> paths, CheckLevel level)
      Parameters:
      paths - Paths for matching.
      level - The CheckLevel to apply on affected files.
      Returns:
      a new ByPathWarningsGuard that would affect any file not in the given set of paths.
    • level

      public CheckLevel level(JSError error)
      Description copied from class: WarningsGuard
      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.
      Specified by:
      level in class WarningsGuard
      Parameters:
      error - a reported error.
      Returns:
      what level given error should have.
    • getPriority

      protected 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