Skip to content

Commit

Permalink
Change the default input language to ES 2017 to match the command-lin…
Browse files Browse the repository at this point in the history
…e default.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=173967724
  • Loading branch information
tbreisacher authored and brad4d committed Oct 31, 2017
1 parent aae1c12 commit bb5b170
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 107 deletions.
2 changes: 1 addition & 1 deletion src/com/google/javascript/jscomp/CompilerOptions.java
Expand Up @@ -1207,7 +1207,7 @@ public void setPrintConfig(boolean printConfig) {
*/ */
public CompilerOptions() { public CompilerOptions() {
// Accepted language // Accepted language
languageIn = LanguageMode.ECMASCRIPT_2017; languageIn = LanguageMode.ECMASCRIPT3;
languageOut = LanguageMode.NO_TRANSPILE; languageOut = LanguageMode.NO_TRANSPILE;


// Which environment to use // Which environment to use
Expand Down
6 changes: 4 additions & 2 deletions src/com/google/javascript/jscomp/ComposeWarningsGuard.java
Expand Up @@ -46,7 +46,8 @@ public class ComposeWarningsGuard extends WarningsGuard {
private final Map<WarningsGuard, Integer> orderOfAddition = new HashMap<>(); private final Map<WarningsGuard, Integer> orderOfAddition = new HashMap<>();
private int numberOfAdds = 0; private int numberOfAdds = 0;


private final Comparator<WarningsGuard> guardComparator = new GuardComparator(orderOfAddition); private final Comparator<WarningsGuard> guardComparator =
new GuardComparator(orderOfAddition);
private boolean demoteErrors = false; private boolean demoteErrors = false;


private static class GuardComparator private static class GuardComparator
Expand All @@ -72,7 +73,8 @@ public int compare(WarningsGuard a, WarningsGuard b) {
} }


// The order that the guards are applied in. // The order that the guards are applied in.
private final TreeSet<WarningsGuard> guards = new TreeSet<>(guardComparator); private final TreeSet<WarningsGuard> guards =
new TreeSet<>(guardComparator);


public ComposeWarningsGuard(List<WarningsGuard> guards) { public ComposeWarningsGuard(List<WarningsGuard> guards) {
addGuards(guards); addGuards(guards);
Expand Down
2 changes: 0 additions & 2 deletions test/com/google/debugging/sourcemap/SourceMapTestCase.java
Expand Up @@ -22,7 +22,6 @@
import com.google.debugging.sourcemap.proto.Mapping.OriginalMapping; import com.google.debugging.sourcemap.proto.Mapping.OriginalMapping;
import com.google.javascript.jscomp.Compiler; import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.CompilerOptions; import com.google.javascript.jscomp.CompilerOptions;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.Result; import com.google.javascript.jscomp.Result;
import com.google.javascript.jscomp.SourceFile; import com.google.javascript.jscomp.SourceFile;
import com.google.javascript.jscomp.SourceMap; import com.google.javascript.jscomp.SourceMap;
Expand Down Expand Up @@ -263,7 +262,6 @@ protected RunResult compile(String js, String fileName) {


protected CompilerOptions getCompilerOptions() { protected CompilerOptions getCompilerOptions() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setSourceMapOutputPath("testcode_source_map.out"); options.setSourceMapOutputPath("testcode_source_map.out");
options.setSourceMapFormat(getSourceMapFormat()); options.setSourceMapFormat(getSourceMapFormat());
options.setSourceMapDetailLevel(detailLevel); options.setSourceMapDetailLevel(detailLevel);
Expand Down
Expand Up @@ -22,7 +22,6 @@


import com.google.common.base.Joiner; import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
Expand Down Expand Up @@ -68,7 +67,6 @@ protected void setUp() throws Exception {
*/ */
protected CompilerOptions getOptions(DiagnosticGroup... typesOfGuard) { protected CompilerOptions getOptions(DiagnosticGroup... typesOfGuard) {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.declaredGlobalExternsOnWindow = false; options.declaredGlobalExternsOnWindow = false;
options.setClosurePass(true); options.setClosurePass(true);
// These are the options that are always on in JsDev which is the only // These are the options that are always on in JsDev which is the only
Expand Down
Expand Up @@ -15,7 +15,6 @@
*/ */
package com.google.javascript.jscomp; package com.google.javascript.jscomp;


import com.google.javascript.jscomp.CompilerOptions.LanguageMode;


/** /**
* Tests that the property renaming primitive goog.reflect.objectProperty * Tests that the property renaming primitive goog.reflect.objectProperty
Expand Down Expand Up @@ -146,8 +145,6 @@ public void testStaticPropRenameSimple() {
@Override @Override
protected CompilerOptions createCompilerOptions() { protected CompilerOptions createCompilerOptions() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT_2017);
options.setLanguageOut(LanguageMode.ECMASCRIPT3);
if (useSimpleMode) { if (useSimpleMode) {
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options); CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
} else { } else {
Expand Down
Expand Up @@ -16,7 +16,6 @@


package com.google.javascript.jscomp; package com.google.javascript.jscomp;


import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import com.google.javascript.jscomp.deps.ModuleLoader; import com.google.javascript.jscomp.deps.ModuleLoader;


/** /**
Expand Down Expand Up @@ -315,7 +314,6 @@ public void testCrossModuleSubclass6() {
@Override @Override
protected CompilerOptions createCompilerOptions() { protected CompilerOptions createCompilerOptions() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setCodingConvention(new GoogleCodingConvention()); options.setCodingConvention(new GoogleCodingConvention());
WarningLevel.VERBOSE.setOptionsForWarningLevel(options); WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
options.setProcessCommonJSModules(true); options.setProcessCommonJSModules(true);
Expand Down
24 changes: 8 additions & 16 deletions test/com/google/javascript/jscomp/CompilerTest.java
Expand Up @@ -114,7 +114,6 @@ public void testPrintExterns() {
List<SourceFile> externs = List<SourceFile> externs =
ImmutableList.of(SourceFile.fromCode("extern", "function alert(x) {}")); ImmutableList.of(SourceFile.fromCode("extern", "function alert(x) {}"));
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.setPrintExterns(true); options.setPrintExterns(true);
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
compiler.init(externs, ImmutableList.<SourceFile>of(), options); compiler.init(externs, ImmutableList.<SourceFile>of(), options);
Expand All @@ -132,7 +131,8 @@ public void testLocalUndefined() throws Exception {
// //
// This test is just to make sure that the compiler doesn't crash. // This test is just to make sure that the compiler doesn't crash.
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options); CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(
options);
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
SourceFile externs = SourceFile.fromCode("externs.js", ""); SourceFile externs = SourceFile.fromCode("externs.js", "");
SourceFile input = SourceFile.fromCode("input.js", SourceFile input = SourceFile.fromCode("input.js",
Expand Down Expand Up @@ -318,7 +318,6 @@ public void testApplyInputSourceMaps() throws Exception {
originalSourcePosition)); originalSourcePosition));


CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
options.sourceMapOutputPath = "fake/source_map_path.js.map"; options.sourceMapOutputPath = "fake/source_map_path.js.map";
options.inputSourceMaps = inputSourceMaps; options.inputSourceMaps = inputSourceMaps;
options.applyInputSourceMaps = true; options.applyInputSourceMaps = true;
Expand Down Expand Up @@ -875,9 +874,6 @@ static Result test(String js, String expected, DiagnosticType error) {


public void testConsecutiveSemicolons() { public void testConsecutiveSemicolons() {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
compiler.initOptions(options);
String js = "if(a);"; String js = "if(a);";
Node n = compiler.parseTestCode(js); Node n = compiler.parseTestCode(js);
Compiler.CodeBuilder cb = new Compiler.CodeBuilder(); Compiler.CodeBuilder cb = new Compiler.CodeBuilder();
Expand Down Expand Up @@ -918,7 +914,6 @@ public void testWarningsFiltering() {
public void testExportSymbolReservesNamesForRenameVars() { public void testExportSymbolReservesNamesForRenameVars() {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
options.setClosurePass(true); options.setClosurePass(true);
options.setVariableRenaming(VariableRenamingPolicy.ALL); options.setVariableRenaming(VariableRenamingPolicy.ALL);


Expand All @@ -928,13 +923,12 @@ public void testExportSymbolReservesNamesForRenameVars() {
Result result = compiler.compile(EMPTY_EXTERNS, inputs, options); Result result = compiler.compile(EMPTY_EXTERNS, inputs, options);


assertTrue(result.success); assertTrue(result.success);
assertThat(compiler.toSource()).isEqualTo("var b;var c;b.exportSymbol(\"a\",c);"); assertEquals("var b;var c;b.exportSymbol(\"a\",c);", compiler.toSource());
} }


public void testGenerateExportsReservesNames() { public void testGenerateExportsReservesNames() {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
options.setClosurePass(true); options.setClosurePass(true);
options.setVariableRenaming(VariableRenamingPolicy.ALL); options.setVariableRenaming(VariableRenamingPolicy.ALL);
options.setGenerateExports(true); options.setGenerateExports(true);
Expand All @@ -945,7 +939,8 @@ public void testGenerateExportsReservesNames() {
Result result = compiler.compile(EMPTY_EXTERNS, inputs, options); Result result = compiler.compile(EMPTY_EXTERNS, inputs, options);


assertTrue(result.success); assertTrue(result.success);
assertThat(compiler.toSource()).isEqualTo("var b;var c={};b.exportSymbol(\"a\",c);"); assertEquals("var b;var c={};b.exportSymbol(\"a\",c);",
compiler.toSource());
} }


private static final DiagnosticType TEST_ERROR = private static final DiagnosticType TEST_ERROR =
Expand Down Expand Up @@ -1437,12 +1432,9 @@ public Class<String> getType() {
} }


private static CompilerOptions createNewFlagBasedOptions() { private static CompilerOptions createNewFlagBasedOptions() {
CompilerOptions options = new CompilerOptions(); CompilerOptions opt = new CompilerOptions();
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options); CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(opt);
options.setLanguageIn(LanguageMode.ECMASCRIPT3); return opt;
options.setLanguageOut(LanguageMode.ECMASCRIPT3);
options.setEmitUseStrict(false);
return options;
} }


private static byte[] serialize(Object obj) throws IOException { private static byte[] serialize(Object obj) throws IOException {
Expand Down
Expand Up @@ -160,9 +160,6 @@ private Node getSideEffectsHookNode() {
private void checkKeepSimplifiedShortCircuitExpr(Node root, private void checkKeepSimplifiedShortCircuitExpr(Node root,
List<String> expected) { List<String> expected) {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
compiler.initOptions(options);
List<Node> replacements = new ArrayList<>(); List<Node> replacements = new ArrayList<>();
GetReplacementSideEffectSubexpressions accumulator = GetReplacementSideEffectSubexpressions accumulator =
new GetReplacementSideEffectSubexpressions(compiler, replacements); new GetReplacementSideEffectSubexpressions(compiler, replacements);
Expand All @@ -180,9 +177,6 @@ private void checkKeepSimplifiedHookExpr(Node root,
boolean elseHasSideEffects, boolean elseHasSideEffects,
List<String> expected) { List<String> expected) {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions();
options.setEmitUseStrict(false);
compiler.initOptions(options);
List<Node> replacements = new ArrayList<>(); List<Node> replacements = new ArrayList<>();
GetReplacementSideEffectSubexpressions accumulator = GetReplacementSideEffectSubexpressions accumulator =
new GetReplacementSideEffectSubexpressions(compiler, replacements); new GetReplacementSideEffectSubexpressions(compiler, replacements);
Expand Down
2 changes: 0 additions & 2 deletions test/com/google/javascript/jscomp/GoldenFileComparer.java
Expand Up @@ -20,7 +20,6 @@


import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.io.Files; import com.google.common.io.Files;
import com.google.javascript.jscomp.CompilerOptions.LanguageMode;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
Expand Down Expand Up @@ -108,7 +107,6 @@ private static void compileAndCompare(
*/ */
public static CompilerOptions options() { public static CompilerOptions options() {
CompilerOptions options = new CompilerOptions(); CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT3);
// Instrumentation done // Instrumentation done
options.setPrettyPrint(true); options.setPrettyPrint(true);
return options; return options;
Expand Down

0 comments on commit bb5b170

Please sign in to comment.