| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.google.javascript.jscomp; |
| 18 |
|
| 19 |
import com.google.common.base.Preconditions; |
| 20 |
import com.google.common.collect.Lists; |
| 21 |
|
| 22 |
import java.util.List; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public class ShowByPathWarningsGuard extends WarningsGuard { |
| 31 |
private static final long serialVersionUID = 1L; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public enum ShowType { |
| 38 |
INCLUDE, |
| 39 |
EXCLUDE; |
| 40 |
} |
| 41 |
|
| 42 |
private final ByPathWarningsGuard warningsGuard; |
| 43 |
|
| 44 |
public ShowByPathWarningsGuard(String checkWarningsOnlyForPath) { |
| 45 |
this(checkWarningsOnlyForPath, ShowType.INCLUDE); |
| 46 |
} |
| 47 |
|
| 48 |
public ShowByPathWarningsGuard(String[] checkWarningsOnlyForPath) { |
| 49 |
this(checkWarningsOnlyForPath, ShowType.INCLUDE); |
| 50 |
} |
| 51 |
|
| 52 |
public ShowByPathWarningsGuard(String path, ShowType showType) { |
| 53 |
this(new String[] { path }, showType); |
| 54 |
} |
| 55 |
|
| 56 |
public ShowByPathWarningsGuard(String[] paths, ShowType showType) { |
| 57 |
Preconditions.checkArgument(paths != null); |
| 58 |
Preconditions.checkArgument(showType != null); |
| 59 |
List<String> pathList = Lists.newArrayList(paths); |
| 60 |
if (showType == ShowType.INCLUDE) { |
| 61 |
warningsGuard = ByPathWarningsGuard.exceptPath(pathList, CheckLevel.OFF); |
| 62 |
} else { |
| 63 |
warningsGuard = ByPathWarningsGuard.forPath(pathList, CheckLevel.OFF); |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
@Override |
| 68 |
public CheckLevel level(JSError error) { |
| 69 |
return warningsGuard.level(error); |
| 70 |
} |
| 71 |
|
| 72 |
@Override |
| 73 |
protected int getPriority() { |
| 74 |
return warningsGuard.getPriority(); |
| 75 |
} |
| 76 |
} |