From c69d49f9f70beeccce429d0de40a6bed695f61f5 Mon Sep 17 00:00:00 2001 From: tbreisacher Date: Wed, 21 Sep 2016 11:29:11 -0700 Subject: [PATCH] Allow --print_file_after_each_pass to take multiple filenames. This is helpful in debugging CollapseProperties bugs where it appears a name is collapsed in one file but not in another. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=133853621 --- src/com/google/javascript/jscomp/Compiler.java | 15 +++++++++++---- .../google/javascript/jscomp/CompilerOptions.java | 9 +++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/com/google/javascript/jscomp/Compiler.java b/src/com/google/javascript/jscomp/Compiler.java index 61bfa6b6dd9..96a94e261d2 100644 --- a/src/com/google/javascript/jscomp/Compiler.java +++ b/src/com/google/javascript/jscomp/Compiler.java @@ -987,12 +987,19 @@ final void afterPass(String passName) { } final String getCurrentJsSource() { - String filename = options.fileToPrintAfterEachPass; - if (filename == null) { + List filenames = options.filesToPrintAfterEachPass; + if (filenames.isEmpty()) { return toSource(); } else { - Node script = getScriptNode(filename); - return script != null ? toSource(script) : ("File '" + filename + "' not found"); + StringBuilder builder = new StringBuilder(); + for (String filename : filenames) { + Node script = getScriptNode(filename); + String source = script != null + ? "// " + script.getSourceFileName() + "\n" + toSource(script) + : "File '" + filename + "' not found"; + builder.append(source); + } + return builder.toString(); } } diff --git a/src/com/google/javascript/jscomp/CompilerOptions.java b/src/com/google/javascript/jscomp/CompilerOptions.java index 7208807c873..4a837b4f8d1 100644 --- a/src/com/google/javascript/jscomp/CompilerOptions.java +++ b/src/com/google/javascript/jscomp/CompilerOptions.java @@ -880,15 +880,16 @@ public void setTrustedStrings(boolean yes) { // Should only be used when debugging compiler bugs. boolean printSourceAfterEachPass; - // Used to narrow down the printed source when overall input size is large. - String fileToPrintAfterEachPass; + // Used to narrow down the printed source when overall input size is large. If this is empty, + // the entire source is printed. + List filesToPrintAfterEachPass = ImmutableList.of(); public void setPrintSourceAfterEachPass(boolean printSource) { this.printSourceAfterEachPass = printSource; } - public void setFileToPrintAfterEachPass(String filename) { - this.fileToPrintAfterEachPass = filename; + public void setFilesToPrintAfterEachPass(List filenames) { + this.filesToPrintAfterEachPass = filenames; } String reportPath;