Added pretty printing to the head and tail of script output.
Review by: bobv (postmortem)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@2242 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/core/ext/LinkerContext.java b/dev/core/src/com/google/gwt/core/ext/LinkerContext.java
index ad78576..253a8c1 100644
--- a/dev/core/src/com/google/gwt/core/ext/LinkerContext.java
+++ b/dev/core/src/com/google/gwt/core/ext/LinkerContext.java
@@ -44,6 +44,12 @@
SortedSet<SelectionProperty> getProperties();
/**
+ * Returns <code>true</code> if the output should be as compact is possible
+ * and <code>false</code> if the output should be human-readable.
+ */
+ boolean isOutputCompact();
+
+ /**
* Applies optimizations to a JavaScript program. This method is intended to
* be applied to bootstrap scripts in order to apply context-specific
* transformations to the program, based on the compiler's configuration. The
diff --git a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
index d39f63e..5733f47 100644
--- a/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
+++ b/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
@@ -228,6 +228,10 @@
return propertiesByName.get(name);
}
+ public boolean isOutputCompact() {
+ return jjsOptions.getOutput().shouldMinimize();
+ }
+
@Override
public ArtifactSet link(TreeLogger logger, LinkerContext context,
ArtifactSet artifacts) throws UnableToCompleteException {
diff --git a/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java b/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java
index 53aec6b..2bb2353 100644
--- a/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java
+++ b/dev/core/src/com/google/gwt/core/linker/IFrameLinker.java
@@ -66,7 +66,7 @@
@Override
protected String getModulePrefix(TreeLogger logger, LinkerContext context) {
- DefaultTextOutput out = new DefaultTextOutput(true);
+ DefaultTextOutput out = new DefaultTextOutput(context.isOutputCompact());
out.print("<html>");
out.newlineOpt();
@@ -101,12 +101,13 @@
@Override
protected String getModuleSuffix(TreeLogger logger, LinkerContext context) {
- DefaultTextOutput out = new DefaultTextOutput(true);
+ DefaultTextOutput out = new DefaultTextOutput(context.isOutputCompact());
+
+ out.print("$stats && $stats('" + context.getModuleName()
+ + "', 'startup', 'moduleEvalEnd', {millis:(new Date()).getTime()});");
// Generate the call to tell the bootstrap code that we're ready to go.
out.newlineOpt();
- out.print("$stats && $stats('" + context.getModuleName()
- + "', 'startup', 'moduleEvalEnd', {millis:(new Date()).getTime()});");
out.print("if ($wnd." + context.getModuleFunctionName() + ") $wnd."
+ context.getModuleFunctionName() + ".onScriptLoad();");
out.newline();
diff --git a/dev/core/src/com/google/gwt/core/linker/XSLinker.java b/dev/core/src/com/google/gwt/core/linker/XSLinker.java
index 1307d55..23f1c78 100644
--- a/dev/core/src/com/google/gwt/core/linker/XSLinker.java
+++ b/dev/core/src/com/google/gwt/core/linker/XSLinker.java
@@ -43,7 +43,7 @@
@Override
protected String getModulePrefix(TreeLogger logger, LinkerContext context)
throws UnableToCompleteException {
- DefaultTextOutput out = new DefaultTextOutput(true);
+ DefaultTextOutput out = new DefaultTextOutput(context.isOutputCompact());
out.print("(function(){");
out.newlineOpt();
@@ -70,11 +70,11 @@
@Override
protected String getModuleSuffix(TreeLogger logger, LinkerContext context)
throws UnableToCompleteException {
- DefaultTextOutput out = new DefaultTextOutput(true);
+ DefaultTextOutput out = new DefaultTextOutput(context.isOutputCompact());
- out.newlineOpt();
out.print("$stats && $stats('" + context.getModuleName()
+ "', 'startup', 'moduleEvalEnd', {millis:(new Date()).getTime()});");
+
// Generate the call to tell the bootstrap code that we're ready to go.
out.newlineOpt();
out.print("if (" + context.getModuleFunctionName() + ") {");