Skip to content

Commit

Permalink
regex match and keep output files in order for setFilesToPrintAfterEa…
Browse files Browse the repository at this point in the history
…chPass

option.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166768019
  • Loading branch information
brad4d authored and blickly committed Aug 29, 2017
1 parent addd51f commit d5aa638
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
20 changes: 12 additions & 8 deletions src/com/google/javascript/jscomp/Compiler.java
Expand Up @@ -1169,17 +1169,21 @@ final void afterPass(String passName) {
}

final String getCurrentJsSource() {
List<String> filenames = options.filesToPrintAfterEachPass;
if (filenames.isEmpty()) {
List<String> fileNameRegexList = options.filesToPrintAfterEachPassRegexList;
if (fileNameRegexList.isEmpty()) {
return toSource();
} else {
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);
checkNotNull(jsRoot);
for (Node fileNode : jsRoot.children()) {
String fileName = fileNode.getSourceFileName();
for (String regex : fileNameRegexList) {
if (fileName.matches(regex)) {
String source = "// " + fileName + "\n" + toSource(fileNode);
builder.append(source);
break;
}
}
}
return builder.toString();
}
Expand Down
6 changes: 3 additions & 3 deletions src/com/google/javascript/jscomp/CompilerOptions.java
Expand Up @@ -983,14 +983,14 @@ public void setTrustedStrings(boolean yes) {
boolean printSourceAfterEachPass;
// Used to narrow down the printed source when overall input size is large. If this is empty,
// the entire source is printed.
List<String> filesToPrintAfterEachPass = ImmutableList.of();
List<String> filesToPrintAfterEachPassRegexList = ImmutableList.of();

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

public void setFilesToPrintAfterEachPass(List<String> filenames) {
this.filesToPrintAfterEachPass = filenames;
public void setFilesToPrintAfterEachPassRegexList(List<String> filePathRegexList) {
this.filesToPrintAfterEachPassRegexList = filePathRegexList;
}

String reportPath;
Expand Down

0 comments on commit d5aa638

Please sign in to comment.