@Immutable
public final class FeatureSet
extends java.lang.Object
implements java.io.Serializable
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.
Modifier and Type | Class and Description |
---|---|
static class |
FeatureSet.Feature
Specific features that can be included in a FeatureSet.
|
Modifier and Type | Field and Description |
---|---|
static FeatureSet |
BARE_MINIMUM
The bare minimum set of features.
|
static FeatureSet |
BROWSER_2020 |
static FeatureSet |
ES_NEXT |
static FeatureSet |
ES_UNSUPPORTED |
static FeatureSet |
ES2018 |
static FeatureSet |
ES2018_MODULES |
static FeatureSet |
ES2019 |
static FeatureSet |
ES2019_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 |
Modifier and Type | Method and Description |
---|---|
static FeatureSet |
all()
Returns a
FeatureSet containing all known features. |
boolean |
contains(FeatureSet.Feature feature)
Does this
FeatureSet contain the given feature? |
boolean |
contains(FeatureSet other)
Does this
FeatureSet contain all of the features of other ? |
boolean |
equals(java.lang.Object other) |
com.google.common.collect.ImmutableSet<FeatureSet.Feature> |
getFeatures() |
boolean |
has(FeatureSet.Feature feature)
Does this
FeatureSet include feature ? |
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 encoding in depgraph and deps.js files.
|
java.lang.String |
versionForDebugging()
Returns a string representation useful for debugging.
|
FeatureSet |
with(FeatureSet.Feature... newFeatures)
Returns a feature set combining all the features from
this and newFeatures . |
FeatureSet |
with(FeatureSet.Feature feature)
Returns a feature set combining all the features from
this and feature . |
FeatureSet |
with(FeatureSet newFeatures)
Returns a feature set combining all the features from
this and newFeatures . |
FeatureSet |
with(java.util.Set<FeatureSet.Feature> newFeatures)
Returns a feature set combining all the features from
this and newFeatures . |
FeatureSet |
without(FeatureSet.Feature featureToRemove,
FeatureSet.Feature... moreFeaturesToRemove) |
FeatureSet |
without(FeatureSet other) |
FeatureSet |
withoutTypes() |
public static final FeatureSet BARE_MINIMUM
public static final FeatureSet ES3
public static final FeatureSet ES5
public static final FeatureSet ES6_MODULES
public static final FeatureSet ES6
public static final FeatureSet ES7_MODULES
public static final FeatureSet ES7
public static final FeatureSet ES8_MODULES
public static final FeatureSet ES8
public static final FeatureSet ES2018_MODULES
public static final FeatureSet ES2018
public static final FeatureSet ES2019_MODULES
public static final FeatureSet ES2019
public static final FeatureSet ES_NEXT
public static final FeatureSet ES_UNSUPPORTED
public static final FeatureSet TYPESCRIPT
public static final FeatureSet BROWSER_2020
public static final FeatureSet TS_UNSUPPORTED
public java.lang.String version()
public java.lang.String versionForDebugging()
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.
public FeatureSet without(FeatureSet.Feature featureToRemove, FeatureSet.Feature... moreFeaturesToRemove)
public FeatureSet without(FeatureSet other)
public FeatureSet withoutTypes()
public FeatureSet union(FeatureSet other)
public boolean contains(FeatureSet other)
FeatureSet
contain all of the features of other
?public boolean contains(FeatureSet.Feature feature)
FeatureSet
contain the given feature?public FeatureSet with(FeatureSet.Feature feature)
this
and feature
.public FeatureSet with(FeatureSet.Feature... newFeatures)
this
and newFeatures
.public FeatureSet with(java.util.Set<FeatureSet.Feature> newFeatures)
this
and newFeatures
.public FeatureSet with(FeatureSet newFeatures)
this
and newFeatures
.public boolean has(FeatureSet.Feature feature)
FeatureSet
include feature
?public com.google.common.collect.ImmutableSet<FeatureSet.Feature> getFeatures()
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static FeatureSet valueOf(java.lang.String name)
public static FeatureSet all()
FeatureSet
containing all known features.
NOTE: PassFactory
classes that claim to support FeatureSet.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.
public static FeatureSet latest()
Copyright © 2009-2020 Google. All Rights Reserved.