Class FeatureSet
java.lang.Object
com.google.javascript.jscomp.parsing.parser.FeatureSet
- All Implemented Interfaces:
Serializable
Represents 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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Specific features that can be included in a FeatureSet. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final FeatureSet
static final FeatureSet
The bare minimum set of features.static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
The full set of ES2015 features, not including modules.static final FeatureSet
All ES2015 features, including modules.static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
static final FeatureSet
Features from ES3.static final FeatureSet
Features from ES5 only. -
Method Summary
Modifier and TypeMethodDescriptionstatic FeatureSet
all()
Returns aFeatureSet
containing all known features.boolean
contains
(FeatureSet other) Does thisFeatureSet
contain all of the features ofother
?boolean
contains
(FeatureSet.Feature feature) Does thisFeatureSet
contain the given feature?boolean
containsAtLeastOneOf
(FeatureSet other) Does thisFeatureSet
contain at least one of the features ofother
?boolean
com.google.common.collect.ImmutableSet
<FeatureSet.Feature> boolean
has
(FeatureSet.Feature feature) Does thisFeatureSet
includefeature
?int
hashCode()
static FeatureSet
latest()
toString()
union
(FeatureSet other) static FeatureSet
Parses known strings into feature sets.version()
Returns a string representation suitable for use in polyfill definition files and encoding in depgraph and deps.js files.Deprecated.with
(FeatureSet newFeatures) Returns a feature set combining all the features fromthis
andnewFeatures
.with
(FeatureSet.Feature feature) Returns a feature set combining all the features fromthis
andfeature
.with
(FeatureSet.Feature... newFeatures) Returns a feature set combining all the features fromthis
andnewFeatures
.with
(Set<FeatureSet.Feature> newFeatures) Returns a feature set combining all the features fromthis
andnewFeatures
.without
(FeatureSet other) without
(FeatureSet.Feature featureToRemove, FeatureSet.Feature... moreFeaturesToRemove)
-
Field Details
-
BARE_MINIMUM
The bare minimum set of features. -
ES3
Features from ES3. -
ES5
Features from ES5 only. -
ES2015_MODULES
All ES2015 features, including modules. -
ES2015
The full set of ES2015 features, not including modules. -
ES2016_MODULES
-
ES2016
-
ES2017_MODULES
-
ES2017
-
ES2018_MODULES
-
ES2018
-
ES2019_MODULES
-
ES2019
-
ES2020_MODULES
-
ES2020
-
ES2021_MODULES
-
ES2021
-
ES_NEXT
-
ES_UNSTABLE
-
ES_UNSUPPORTED
-
BROWSER_2020
-
BROWSER_2021
-
BROWSER_2022
-
BROWSER_2023
-
BROWSER_2024
-
BROWSER_2025
-
ALL
-
-
Method Details
-
version
Returns a string representation suitable for use in polyfill definition files and encoding in depgraph and deps.js files. -
versionForDebugging
Deprecated.Please useversion()
instead.Returns a string representation useful for debugging. -
without
public FeatureSet without(FeatureSet.Feature featureToRemove, FeatureSet.Feature... moreFeaturesToRemove) -
without
-
withoutTypes
-
union
-
containsAtLeastOneOf
Does thisFeatureSet
contain at least one of the features ofother
? -
contains
Does thisFeatureSet
contain all of the features ofother
? -
contains
Does thisFeatureSet
contain the given feature? -
with
Returns a feature set combining all the features fromthis
andfeature
. -
with
Returns a feature set combining all the features fromthis
andnewFeatures
. -
with
Returns a feature set combining all the features fromthis
andnewFeatures
. -
with
Returns a feature set combining all the features fromthis
andnewFeatures
. -
has
Does thisFeatureSet
includefeature
? -
getFeatures
-
equals
-
hashCode
public int hashCode() -
toString
-
valueOf
Parses known strings into feature sets. -
all
Returns aFeatureSet
containing all known features.NOTE:
PassFactory
classes that claim to supportFeatureSet.all()
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
-
version()
instead.