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
BARE_MINIMUM
The bare minimum set of features.static FeatureSet
BROWSER_2020
static FeatureSet
ES_NEXT
static FeatureSet
ES_NEXT_IN
static FeatureSet
ES_UNSUPPORTED
static FeatureSet
ES2018
static FeatureSet
ES2018_MODULES
static FeatureSet
ES2019
static FeatureSet
ES2019_MODULES
static FeatureSet
ES2020
static FeatureSet
ES2020_MODULES
static FeatureSet
ES3
Features from ES3.static FeatureSet
ES5
Features from ES5 only.static FeatureSet
ES6
The full set of ES6 features, not including modules.static FeatureSet
ES6_MODULES
All ES6 features, including modules.static FeatureSet
ES7
static FeatureSet
ES7_MODULES
static FeatureSet
ES8
static FeatureSet
ES8_MODULES
static FeatureSet
TS_UNSUPPORTED
static FeatureSet
TYPESCRIPT
-
Method Summary
All Methods Static Methods Instance Methods Concrete 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
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()
Returns a string representation useful for debugging.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.
-
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 use in polyfill definition files and 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 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.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()
-
-