| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package com.google.javascript.jscomp.parsing; |
| 18 |
|
| 19 |
import com.google.common.collect.ImmutableMap; |
| 20 |
|
| 21 |
import java.util.Map; |
| 22 |
import java.util.Set; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public class Config { |
| 31 |
|
| 32 |
public enum LanguageMode { |
| 33 |
ECMASCRIPT3, |
| 34 |
ECMASCRIPT5, |
| 35 |
ECMASCRIPT5_STRICT, |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
final boolean parseJsDocDocumentation; |
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
final boolean isIdeMode; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
final Map<String, Annotation> annotationNames; |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
final Set<String> suppressionNames; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
final LanguageMode languageMode; |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
final boolean acceptConstKeyword; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
Config(Set<String> annotationWhitelist, Set<String> suppressionNames, |
| 74 |
boolean isIdeMode, LanguageMode languageMode, |
| 75 |
boolean acceptConstKeyword) { |
| 76 |
this.annotationNames = buildAnnotationNames(annotationWhitelist); |
| 77 |
this.parseJsDocDocumentation = isIdeMode; |
| 78 |
this.suppressionNames = suppressionNames; |
| 79 |
this.isIdeMode = isIdeMode; |
| 80 |
this.languageMode = languageMode; |
| 81 |
this.acceptConstKeyword = acceptConstKeyword; |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
private static Map<String, Annotation> buildAnnotationNames( |
| 89 |
Set<String> annotationWhitelist) { |
| 90 |
ImmutableMap.Builder<String, Annotation> annotationBuilder = |
| 91 |
ImmutableMap.builder(); |
| 92 |
annotationBuilder.putAll(Annotation.recognizedAnnotations); |
| 93 |
for (String unrecognizedAnnotation : annotationWhitelist) { |
| 94 |
if (!Annotation.recognizedAnnotations.containsKey( |
| 95 |
unrecognizedAnnotation)) { |
| 96 |
annotationBuilder.put( |
| 97 |
unrecognizedAnnotation, Annotation.NOT_IMPLEMENTED); |
| 98 |
} |
| 99 |
} |
| 100 |
return annotationBuilder.build(); |
| 101 |
} |
| 102 |
} |