Class FeatureSet
- java.lang.Object
-
- com.google.javascript.jscomp.parsing.parser.FeatureSet
-
- All Implemented Interfaces:
java.io.Serializable
@Immutable public final class FeatureSet extends java.lang.Object implements java.io.SerializableRepresents various aspects of language version and support.This is somewhat redundant with LanguageMode, but is separate for two reasons: (1) it's used for parsing, which cannot depend on LanguageMode, and (2) it's concerned with slightly different nuances: implemented features and modules rather than strictness.
In the long term, it would be good to disentangle all these concerns and pull out a single LanguageSyntax enum with a separate strict mode flag, and then these could possibly be unified.
Instances of this class are immutable.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFeatureSet.FeatureSpecific features that can be included in a FeatureSet.
-
Field Summary
Fields Modifier and Type Field Description static FeatureSetBARE_MINIMUMThe bare minimum set of features.static FeatureSetBROWSER_2020static FeatureSetES_NEXTstatic FeatureSetES_NEXT_INstatic FeatureSetES_UNSUPPORTEDstatic FeatureSetES2018static FeatureSetES2018_MODULESstatic FeatureSetES2019static FeatureSetES2019_MODULESstatic FeatureSetES2020static FeatureSetES2020_MODULESstatic FeatureSetES3Features from ES3.static FeatureSetES5Features from ES5 only.static FeatureSetES6The full set of ES6 features, not including modules.static FeatureSetES6_MODULESAll ES6 features, including modules.static FeatureSetES7static FeatureSetES7_MODULESstatic FeatureSetES8static FeatureSetES8_MODULESstatic FeatureSetTS_UNSUPPORTEDstatic FeatureSetTYPESCRIPT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static FeatureSetall()Returns aFeatureSetcontaining all known features.booleancontains(FeatureSet other)Does thisFeatureSetcontain all of the features ofother?booleancontains(FeatureSet.Feature feature)Does thisFeatureSetcontain the given feature?booleanequals(java.lang.Object other)com.google.common.collect.ImmutableSet<FeatureSet.Feature>getFeatures()booleanhas(FeatureSet.Feature feature)Does thisFeatureSetincludefeature?inthashCode()static FeatureSetlatest()java.lang.StringtoString()FeatureSetunion(FeatureSet other)static FeatureSetvalueOf(java.lang.String name)Parses known strings into feature sets.java.lang.Stringversion()Returns a string representation suitable for encoding in depgraph and deps.js files.java.lang.StringversionForDebugging()Returns a string representation useful for debugging.FeatureSetwith(FeatureSet newFeatures)Returns a feature set combining all the features fromthisandnewFeatures.FeatureSetwith(FeatureSet.Feature feature)Returns a feature set combining all the features fromthisandfeature.FeatureSetwith(FeatureSet.Feature... newFeatures)Returns a feature set combining all the features fromthisandnewFeatures.FeatureSetwith(java.util.Set<FeatureSet.Feature> newFeatures)Returns a feature set combining all the features fromthisandnewFeatures.FeatureSetwithout(FeatureSet other)FeatureSetwithout(FeatureSet.Feature featureToRemove, FeatureSet.Feature... moreFeaturesToRemove)FeatureSetwithoutTypes()
-
-
-
Field Detail
-
BARE_MINIMUM
public static final FeatureSet BARE_MINIMUM
The bare minimum set of features.
-
ES3
public static final FeatureSet ES3
Features from ES3.
-
ES5
public static final FeatureSet ES5
Features from ES5 only.
-
ES6_MODULES
public static final FeatureSet ES6_MODULES
All ES6 features, including modules.
-
ES6
public static final FeatureSet ES6
The full set of ES6 features, not including modules.
-
ES7_MODULES
public static final FeatureSet ES7_MODULES
-
ES7
public static final FeatureSet ES7
-
ES8_MODULES
public static final FeatureSet ES8_MODULES
-
ES8
public static final FeatureSet ES8
-
ES2018_MODULES
public static final FeatureSet ES2018_MODULES
-
ES2018
public static final FeatureSet ES2018
-
ES2019_MODULES
public static final FeatureSet ES2019_MODULES
-
ES2019
public static final FeatureSet ES2019
-
ES2020_MODULES
public static final FeatureSet ES2020_MODULES
-
ES2020
public static final FeatureSet ES2020
-
ES_NEXT
public static final FeatureSet ES_NEXT
-
ES_NEXT_IN
public static final FeatureSet ES_NEXT_IN
-
ES_UNSUPPORTED
public static final FeatureSet ES_UNSUPPORTED
-
TYPESCRIPT
public static final FeatureSet TYPESCRIPT
-
BROWSER_2020
public static final FeatureSet BROWSER_2020
-
TS_UNSUPPORTED
public static final FeatureSet TS_UNSUPPORTED
-
-
Method Detail
-
version
public java.lang.String version()
Returns a string representation suitable for encoding in depgraph and deps.js files.
-
versionForDebugging
public java.lang.String versionForDebugging()
Returns a string representation useful for debugging.This is not suitable for encoding in deps.js or depgraph files, because it may return strings like 'otiSupported' and 'ntiSupported' which are not real language modes.
-
without
public FeatureSet without(FeatureSet.Feature featureToRemove, FeatureSet.Feature... moreFeaturesToRemove)
-
without
public FeatureSet without(FeatureSet other)
-
withoutTypes
public FeatureSet withoutTypes()
-
union
public FeatureSet union(FeatureSet other)
-
contains
public boolean contains(FeatureSet other)
Does thisFeatureSetcontain all of the features ofother?
-
contains
public boolean contains(FeatureSet.Feature feature)
Does thisFeatureSetcontain the given feature?
-
with
public FeatureSet with(FeatureSet.Feature feature)
Returns a feature set combining all the features fromthisandfeature.
-
with
public FeatureSet with(FeatureSet.Feature... newFeatures)
Returns a feature set combining all the features fromthisandnewFeatures.
-
with
public FeatureSet with(java.util.Set<FeatureSet.Feature> newFeatures)
Returns a feature set combining all the features fromthisandnewFeatures.
-
with
public FeatureSet with(FeatureSet newFeatures)
Returns a feature set combining all the features fromthisandnewFeatures.
-
has
public boolean has(FeatureSet.Feature feature)
Does thisFeatureSetincludefeature?
-
getFeatures
public com.google.common.collect.ImmutableSet<FeatureSet.Feature> getFeatures()
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
valueOf
public static FeatureSet valueOf(java.lang.String name)
Parses known strings into feature sets.
-
all
public static FeatureSet all()
Returns aFeatureSetcontaining all known features.NOTE:
PassFactoryclasses that claim to supportFeatureSet.everything()should be only those that cannot be broken by new features being added to the language. Mainly these are passes that don't have to actually look at the AST at all, like empty marker passes.
-
latest
public static FeatureSet latest()
-
-