Skip to content

Commit c2b084e

Browse files
ChadKillingsworthTyler Breisacher
authored andcommitted
Allow the renaming policies to be disabled by a flag.
Closes #2721 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=175986804
1 parent 8f766d7 commit c2b084e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/com/google/javascript/jscomp/CommandLineRunner.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,11 @@ private static class Flags {
790790
)
791791
private String packageJsonEntryNames = null;
792792

793+
@Option(name = "--renaming",
794+
handler = BooleanOptionHandler.class,
795+
usage = "Disables variable renaming. Cannot be used with ADVANCED optimizations.")
796+
private boolean renaming = true;
797+
793798
@Argument
794799
private List<String> arguments = new ArrayList<>();
795800
private final CmdLineParser parser;
@@ -1559,6 +1564,12 @@ private void initConfigFromFlags(String[] args, PrintStream out, PrintStream err
15591564
}
15601565
}
15611566

1567+
if (!flags.renaming
1568+
&& flags.compilationLevelParsed == CompilationLevel.ADVANCED_OPTIMIZATIONS) {
1569+
reportError("ERROR - renaming cannot be disabled when ADVANCED_OPTMIZATIONS is used.");
1570+
runCompiler = false;
1571+
}
1572+
15621573
getCommandLineConfig()
15631574
.setPrintTree(flags.printTree)
15641575
.setPrintAst(flags.printAst)
@@ -1800,6 +1811,11 @@ protected CompilerOptions createOptions() {
18001811
}
18011812
}
18021813

1814+
if (!flags.renaming) {
1815+
options.setVariableRenaming(VariableRenamingPolicy.OFF);
1816+
options.setPropertyRenaming(PropertyRenamingPolicy.OFF);
1817+
}
1818+
18031819
return options;
18041820
}
18051821

0 commit comments

Comments
 (0)