use of com.google.javascript.jscomp.parsing.parser.FeatureSet in project closure-compiler by google.
the class RewritePolyfills method inject.
private void inject(PolyfillUsage polyfillUsage) {
Polyfill polyfill = polyfillUsage.polyfill();
final FeatureSet outputFeatureSet = compiler.getOptions().getOutputFeatureSet();
final FeatureSet featuresRequiredByPolyfill = FeatureSet.valueOf(polyfill.polyfillVersion);
if (polyfill.kind.equals(Polyfill.Kind.STATIC) && !outputFeatureSet.contains(featuresRequiredByPolyfill)) {
compiler.report(JSError.make(polyfillUsage.node(), INSUFFICIENT_OUTPUT_VERSION_ERROR, polyfillUsage.name(), outputFeatureSet.version()));
}
// version that introduced this symbol?"
if (!outputFeatureSet.contains(FeatureSet.valueOf(polyfill.nativeVersion)) && !polyfill.library.isEmpty()) {
libraries.add(polyfill.library);
}
}
use of com.google.javascript.jscomp.parsing.parser.FeatureSet in project closure-compiler by google.
the class TranspilationPasses method processTranspile.
/**
* Process transpilations if the input language needs transpilation from certain features, on any
* JS file that has features not present in the compiler's output language mode.
*
* @param compiler An AbstractCompiler
* @param combinedRoot The combined root for all JS files.
* @param featureSet Ignored
* @param callbacks The callbacks that should be invoked if a file has ES2015 features.
* @deprecated Please use a regular NodeTraversal object directly, using `shouldTraverse` to skip
* SCRIPT node if desired.
*/
@Deprecated
static void processTranspile(AbstractCompiler compiler, Node combinedRoot, FeatureSet featureSet, NodeTraversal.Callback... callbacks) {
FeatureSet languageOutFeatures = compiler.getOptions().getOutputFeatureSet();
for (Node singleRoot = combinedRoot.getFirstChild(); singleRoot != null; singleRoot = singleRoot.getNext()) {
// added to that file by other transpilation passes.
if (doesScriptHaveUnsupportedFeatures(singleRoot, languageOutFeatures)) {
for (NodeTraversal.Callback callback : callbacks) {
singleRoot.putBooleanProp(Node.TRANSPILED, true);
NodeTraversal.traverse(compiler, singleRoot, callback);
}
}
}
}
Aggregations