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.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:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FeatureSet.Feature
Specific features that can be included in a FeatureSet.
-
Field Summary
Fields Modifier and Type Field Description static FeatureSet
ALL
static FeatureSet
BARE_MINIMUM
The bare minimum set of features.static FeatureSet
BROWSER_2020
static FeatureSet
BROWSER_2021
static FeatureSet
BROWSER_2022
static FeatureSet
ES_NEXT
static FeatureSet
ES_UNSTABLE
static FeatureSet
ES_UNSUPPORTED
static FeatureSet
ES2015
The full set of ES2015 features, not including modules.static FeatureSet
ES2015_MODULES
All ES2015 features, including modules.static FeatureSet
ES2016
static FeatureSet
ES2016_MODULES
static FeatureSet
ES2017
static FeatureSet
ES2017_MODULES
static FeatureSet
ES2018
static FeatureSet
ES2018_MODULES
static FeatureSet
ES2019
static FeatureSet
ES2019_MODULES
static FeatureSet
ES2020
static FeatureSet
ES2020_MODULES
static FeatureSet
ES2021
static FeatureSet
ES2021_MODULES
static FeatureSet
ES3
Features from ES3.static FeatureSet
ES5
Features from ES5 only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static 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
equals(java.lang.Object other)
com.google.common.collect.ImmutableSet<FeatureSet.Feature>
getFeatures()
boolean
has(FeatureSet.Feature feature)
Does thisFeatureSet
includefeature
?int
hashCode()
static FeatureSet
latest()
java.lang.String
toString()
FeatureSet
union(FeatureSet other)
static FeatureSet
valueOf(java.lang.String name)
Parses known strings into feature sets.java.lang.String
version()
Returns a string representation suitable for use in polyfill definition files and encoding in depgraph and deps.js files.java.lang.String
versionForDebugging()
Deprecated.Please useversion()
instead.FeatureSet
with(FeatureSet newFeatures)
Returns a feature set combining all the features fromthis
andnewFeatures
.FeatureSet
with(FeatureSet.Feature feature)
Returns a feature set combining all the features fromthis
andfeature
.FeatureSet
with(FeatureSet.Feature... newFeatures)
Returns a feature set combining all the features fromthis
andnewFeatures
.FeatureSet
with(java.util.Set<FeatureSet.Feature> newFeatures)
Returns a feature set combining all the features fromthis
andnewFeatures
.FeatureSet
without(FeatureSet other)
FeatureSet
without(FeatureSet.Feature featureToRemove, FeatureSet.Feature... moreFeaturesToRemove)
FeatureSet
withoutTypes()
-
-
-
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.
-
ES2015_MODULES
public static final FeatureSet ES2015_MODULES
All ES2015 features, including modules.
-
ES2015
public static final FeatureSet ES2015
The full set of ES2015 features, not including modules.
-
ES2016_MODULES
public static final FeatureSet ES2016_MODULES
-
ES2016
public static final FeatureSet ES2016
-
ES2017_MODULES
public static final FeatureSet ES2017_MODULES
-
ES2017
public static final FeatureSet ES2017
-
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
-
ES2021_MODULES
public static final FeatureSet ES2021_MODULES
-
ES2021
public static final FeatureSet ES2021
-
ES_NEXT
public static final FeatureSet ES_NEXT
-
ES_UNSTABLE
public static final FeatureSet ES_UNSTABLE
-
ES_UNSUPPORTED
public static final FeatureSet ES_UNSUPPORTED
-
BROWSER_2020
public static final FeatureSet BROWSER_2020
-
BROWSER_2021
public static final FeatureSet BROWSER_2021
-
BROWSER_2022
public static final FeatureSet BROWSER_2022
-
ALL
public static final FeatureSet ALL
-
-
Method Detail
-
version
public java.lang.String version()
Returns a string representation suitable for use in polyfill definition files and encoding in depgraph and deps.js files.
-
versionForDebugging
@Deprecated public java.lang.String versionForDebugging()
Deprecated.Please useversion()
instead.Returns a string representation useful for debugging.
-
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)
-
containsAtLeastOneOf
public boolean containsAtLeastOneOf(FeatureSet other)
Does thisFeatureSet
contain at least one of the features ofother
?
-
contains
public boolean contains(FeatureSet other)
Does thisFeatureSet
contain all of the features ofother
?
-
contains
public boolean contains(FeatureSet.Feature feature)
Does thisFeatureSet
contain the given feature?
-
with
public FeatureSet with(FeatureSet.Feature feature)
Returns a feature set combining all the features fromthis
andfeature
.
-
with
public FeatureSet with(FeatureSet.Feature... newFeatures)
Returns a feature set combining all the features fromthis
andnewFeatures
.
-
with
public FeatureSet with(java.util.Set<FeatureSet.Feature> newFeatures)
Returns a feature set combining all the features fromthis
andnewFeatures
.
-
with
public FeatureSet with(FeatureSet newFeatures)
Returns a feature set combining all the features fromthis
andnewFeatures
.
-
has
public boolean has(FeatureSet.Feature feature)
Does thisFeatureSet
includefeature
?
-
getFeatures
public com.google.common.collect.ImmutableSet<FeatureSet.Feature> getFeatures()
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
valueOf
public static FeatureSet valueOf(java.lang.String name)
Parses known strings into feature sets.
-
all
public static FeatureSet 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
public static FeatureSet latest()
-
-