You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/08/20 20:22:26 UTC
[1/6] git commit: TAP5-1991: Make YUICompressor less verbose about
common warnings
Updated Branches:
refs/heads/5.4-js-rewrite a9433984c -> 65aa66e34
TAP5-1991: Make YUICompressor less verbose about common warnings
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/65aa66e3
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/65aa66e3
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/65aa66e3
Branch: refs/heads/5.4-js-rewrite
Commit: 65aa66e3450c3e680517d61ed6dd53bf1511101e
Parents: bbeca8f
Author: Howard M. Lewis Ship <hl...@apache.org>
Authored: Mon Aug 20 11:20:23 2012 -0700
Committer: Howard M. Lewis Ship <hl...@apache.org>
Committed: Mon Aug 20 11:20:23 2012 -0700
----------------------------------------------------------------------
.../internal/yuicompressor/AbstractMinimizer.java | 17 ++++++++++----
.../yuicompressor/JavaScriptResourceMinimizer.java | 17 ++++++++++++++-
2 files changed, 28 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65aa66e3/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java
----------------------------------------------------------------------
diff --git a/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java b/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java
index 51d7024..bb4b243 100644
--- a/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java
+++ b/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/AbstractMinimizer.java
@@ -1,4 +1,4 @@
-// Copyright 2011 The Apache Software Foundation
+// Copyright 2011-2012 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -86,10 +86,15 @@ public abstract class AbstractMinimizer implements ResourceMinimizer
if (logger.isDebugEnabled())
{
+ int inputSize = input.getSize();
+ int outputSize = output.getSize();
+
double elapsedMillis = ((double) elapsedNanos) * NANOS_TO_MILLIS;
+ // e.g., reducing 100 bytes to 25 would be a (100-25)/100 reduction, or 75%
+ double reduction = 100d * ((double) (inputSize - outputSize)) / ((double) inputSize);
- logger.debug(String.format("Minimized %s (%,d input bytes of %s to %,d output bytes in %.2f ms)",
- input.getDescription(), input.getSize(), resourceType, output.getSize(), elapsedMillis));
+ logger.debug(String.format("Minimized %s (%,d input bytes of %s to %,d output bytes in %.2f ms, %.2f%% reduction)",
+ input.getDescription(), inputSize, resourceType, outputSize, elapsedMillis, reduction));
}
return output;
@@ -105,8 +110,10 @@ public abstract class AbstractMinimizer implements ResourceMinimizer
/**
* Implemented in subclasses to do the actual work.
*
- * @param resource content to minimize
- * @param output writer for minimized version of input
+ * @param resource
+ * content to minimize
+ * @param output
+ * writer for minimized version of input
*/
protected abstract void doMinimize(StreamableResource resource, Writer output) throws IOException;
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/65aa66e3/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JavaScriptResourceMinimizer.java
----------------------------------------------------------------------
diff --git a/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JavaScriptResourceMinimizer.java b/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JavaScriptResourceMinimizer.java
index 4a3a999..598f977 100644
--- a/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JavaScriptResourceMinimizer.java
+++ b/tapestry-yuicompressor/src/main/java/org/apache/tapestry5/internal/yuicompressor/JavaScriptResourceMinimizer.java
@@ -46,6 +46,12 @@ public class JavaScriptResourceMinimizer extends AbstractMinimizer
EXACT, NEAR, FAR
}
+ private static final String[] IGNORED_WARNINGS = {
+ "Try to use a single 'var' statement per scope.",
+ "Using 'eval' is not recommended",
+ "has already been declared in the same scope"
+ };
+
public JavaScriptResourceMinimizer(final Logger logger, OperationTracker tracker)
{
super(logger, tracker, "JavaScript");
@@ -75,7 +81,8 @@ public class JavaScriptResourceMinimizer extends AbstractMinimizer
final AtomicInteger warningCount = new AtomicInteger();
- Runnable identifyWarnings = new Runnable() {
+ Runnable identifyWarnings = new Runnable()
+ {
@Override
public void run()
{
@@ -100,6 +107,14 @@ public class JavaScriptResourceMinimizer extends AbstractMinimizer
public void warning(String message, String sourceName, int line, String lineSource, int lineOffset)
{
+ for (String ignored : IGNORED_WARNINGS)
+ {
+ if (message.contains(ignored))
+ {
+ return;
+ }
+ }
+
identifySource.run();
errorLines.add(line);