Skip to content

Commit

Permalink
Allow --print_file_after_each_pass to take multiple filenames. This i…
Browse files Browse the repository at this point in the history
…s 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
  • Loading branch information
tbreisacher authored and blickly committed Sep 21, 2016
1 parent 8549da7 commit c69d49f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
15 changes: 11 additions & 4 deletions src/com/google/javascript/jscomp/Compiler.java
Expand Up @@ -987,12 +987,19 @@ final void afterPass(String passName) {
} }


final String getCurrentJsSource() { final String getCurrentJsSource() {
String filename = options.fileToPrintAfterEachPass; List<String> filenames = options.filesToPrintAfterEachPass;
if (filename == null) { if (filenames.isEmpty()) {
return toSource(); return toSource();
} else { } else {
Node script = getScriptNode(filename); StringBuilder builder = new StringBuilder();
return script != null ? toSource(script) : ("File '" + filename + "' not found"); 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();
} }
} }


Expand Down
9 changes: 5 additions & 4 deletions src/com/google/javascript/jscomp/CompilerOptions.java
Expand Up @@ -880,15 +880,16 @@ public void setTrustedStrings(boolean yes) {


// Should only be used when debugging compiler bugs. // Should only be used when debugging compiler bugs.
boolean printSourceAfterEachPass; boolean printSourceAfterEachPass;
// Used to narrow down the printed source when overall input size is large. // Used to narrow down the printed source when overall input size is large. If this is empty,
String fileToPrintAfterEachPass; // the entire source is printed.
List<String> filesToPrintAfterEachPass = ImmutableList.of();


public void setPrintSourceAfterEachPass(boolean printSource) { public void setPrintSourceAfterEachPass(boolean printSource) {
this.printSourceAfterEachPass = printSource; this.printSourceAfterEachPass = printSource;
} }


public void setFileToPrintAfterEachPass(String filename) { public void setFilesToPrintAfterEachPass(List<String> filenames) {
this.fileToPrintAfterEachPass = filename; this.filesToPrintAfterEachPass = filenames;
} }


String reportPath; String reportPath;
Expand Down

0 comments on commit c69d49f

Please sign in to comment.