addOnlyInstrumentReg(arg); } else if (arg.startsWith(JS_VERSION_PREFIX)) { ECMAVersion = Config.LanguageMode.valueOf(arg.substring(JS_VERSION_PREFIX.length())); } else if (arg.startsWith(LOG_LEVEL)) { logLevel = Level.parse(arg.substring(LOG_LEVEL.length()));
/** Returns the lowest {@link LanguageMode} that supports the specified feature set. */ public static LanguageMode minimumRequiredForSet(FeatureSet featureSet) { for (LanguageMode mode : LanguageMode.values()) { if (mode.featureSet.contains(featureSet)) { return mode; } } throw new IllegalStateException("No input language mode supports feature set: " + featureSet); }
addOnlyInstrumentReg(arg); } else if (arg.startsWith(JS_VERSION_PREFIX)) { ECMAVersion = Config.LanguageMode.valueOf(arg.substring(JS_VERSION_PREFIX.length())); } else if (arg.startsWith(LOG_LEVEL)) { logLevel = Level.parse(arg.substring(LOG_LEVEL.length()));
@Override Config getParserConfig(ConfigContext context) { if (parserConfig == null || externsParserConfig == null) { synchronized (this) { if (parserConfig == null) { Config.LanguageMode configLanguageMode = getParserConfigLanguageMode( options.getLanguageIn()); Config.StrictMode strictMode = options.expectStrictModeInput() ? Config.StrictMode.STRICT : Config.StrictMode.SLOPPY; parserConfig = createConfig(configLanguageMode, strictMode); // Externs must always be parsed with at least ES5 language mode. externsParserConfig = configLanguageMode.equals(Config.LanguageMode.ECMASCRIPT3) ? createConfig(Config.LanguageMode.ECMASCRIPT5, strictMode) : parserConfig; } } } switch (context) { case EXTERNS: return externsParserConfig; default: return parserConfig; } }
@Override public int hashCode() { int h = 1; h *= 1000003; h ^= this.languageMode.hashCode(); h *= 1000003; h ^= this.strictMode.hashCode(); h *= 1000003; h ^= this.jsDocParsingMode.hashCode(); h *= 1000003; h ^= this.runMode.hashCode(); h *= 1000003; h ^= this.annotations.hashCode(); h *= 1000003; h ^= this.suppressionNames.hashCode(); h *= 1000003; h ^= this.parseInlineSourceMaps ? 1231 : 1237; return h; }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Config) { Config that = (Config) o; return (this.languageMode.equals(that.languageMode())) && (this.strictMode.equals(that.strictMode())) && (this.jsDocParsingMode.equals(that.jsDocParsingMode())) && (this.runMode.equals(that.runMode())) && (this.annotations.equals(that.annotations())) && (this.suppressionNames.equals(that.suppressionNames())) && (this.parseInlineSourceMaps == that.parseInlineSourceMaps()); } return false; }
private void reportUntranspilable(Feature feature, Node node) { compiler.report( JSError.make( node, UNTRANSPILABLE_FEATURE_PRESENT, LanguageMode.minimumRequiredFor(feature).toString(), feature.toString())); }
/** * Returns the lowest {@link LanguageMode} that supports the specified feature. */ public static LanguageMode minimumRequiredFor(FeatureSet.Feature feature) { // relies on the LanguageMode enums being in the right order for (LanguageMode mode : LanguageMode.values()) { if (mode.featureSet.has(feature)) { return mode; } } throw new IllegalStateException("No input language mode supports feature: " + feature); }
String languageFeatureWarningMessage(Feature feature) { return "This language feature is only supported for " + LanguageMode.minimumRequiredFor(feature) + " mode or better: " + feature; }