Revision: 3888
Author: mikesamuel
Date: Thu Dec 3 17:21:42 2009
Log: warning cleanup in ancillary tools
http://code.google.com/p/google-caja/source/detail?r=3888
Modified:
/trunk/src/com/google/caja/ancillary/opt/JsOptimizer.java
/trunk/src/com/google/caja/ancillary/opt/StatementSimplifier.java
/trunk/src/com/google/caja/ancillary/servlet/CajaWebToolsServlet.java
/trunk/src/com/google/caja/ancillary/servlet/Request.java
/trunk/src/com/google/caja/ancillary/servlet/StaticFiles.java
/trunk/src/com/google/caja/ancillary/servlet/UserAgentDb.java
/trunk/tests/com/google/caja/ancillary/opt/JsOptimizerTest.java
/trunk/tests/com/google/caja/ancillary/servlet/CajaWebToolsServletTest.java
/trunk/tests/com/google/caja/ancillary/servlet/ZipFileSystemTest.java
=======================================
--- /trunk/src/com/google/caja/ancillary/opt/JsOptimizer.java Thu Dec 3
16:52:46 2009
+++ /trunk/src/com/google/caja/ancillary/opt/JsOptimizer.java Thu Dec 3
17:21:42 2009
@@ -184,8 +184,7 @@
return e;
}
- private static Parser jsParser(CharProducer cp, MessageQueue mq)
- throws ParseException {
+ private static Parser jsParser(CharProducer cp, MessageQueue mq) {
JsLexer lexer = new JsLexer(cp, false);
JsTokenQueue tq = new JsTokenQueue(lexer,
cp.getCurrentPosition().source());
tq.setInputRange(cp.filePositionForOffsets(cp.getOffset(),
cp.getLimit()));
=======================================
--- /trunk/src/com/google/caja/ancillary/opt/StatementSimplifier.java Thu
Dec 3 16:52:46 2009
+++ /trunk/src/com/google/caja/ancillary/opt/StatementSimplifier.java Thu
Dec 3 17:21:42 2009
@@ -66,8 +66,8 @@
*/
public class StatementSimplifier {
/**
- * @param needsBlock true if the optimizer should not replace a block
with
- * less than 2 elements with a simpler structure.
+ * @param mq receives warnings about problems such as breaks to undefined
+ * labels.
* @return the input if no changes were made. Otherwise, a partial
clone.
*/
public static ParseTreeNode optimize(ParseTreeNode n, MessageQueue mq) {
=======================================
--- /trunk/src/com/google/caja/ancillary/servlet/CajaWebToolsServlet.java
Mon Nov 30 20:44:55 2009
+++ /trunk/src/com/google/caja/ancillary/servlet/CajaWebToolsServlet.java
Thu Dec 3 17:21:42 2009
@@ -42,7 +42,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -103,7 +102,7 @@
staticFiles.serve("files/" + path, req, resp);
} else {
// Process a dynamic operation.
- process(reqUri, req.getQueryString(), req, resp);
+ process(reqUri.getPath(), req.getQueryString(), resp);
}
}
@@ -125,20 +124,17 @@
} finally {
in.close();
}
- process(reqUri, query.toString(), req, resp);
+ process(reqUri.getPath(), query.toString(), resp);
}
/**
* Processes a dynamic request which cannot be satisfied by
- * {...@link StaticFiles}.
+ * {...@link StaticFiles} or the special upload handler.
*/
- void process(
- URI reqUri, String query, HttpServletRequest req,
HttpServletResponse out)
+ private void process(String reqPath, String query, HttpServletResponse
out)
throws IOException {
- String reqPath = reqUri.getPath();
-
- List<Pair<String, String>> params = parseQueryString(query);
- Result result = handle(reqPath, params);
+ Result result = handle(reqPath, parseQueryString(query));
+ // Serve the result
if (result.status != 0) { out.setStatus(result.status); }
String contentType = result.getContentType();
if (contentType != null) { out.setContentType(contentType); }
@@ -201,8 +197,7 @@
* @param params query parameters in the order they appear.
* @return the response to send back.
*/
- Result handle(String reqPath, List<Pair<String, String>> params)
- throws IOException {
+ Result handle(String reqPath, List<Pair<String, String>> params) {
MessageQueue mq = new SimpleMessageQueue();
Request req;
{
@@ -303,14 +298,12 @@
return max;
}
- private Result errorPage(String title, MessageQueue mq, Request req)
- throws IOException {
+ private Result errorPage(String title, MessageQueue mq, Request req) {
return errorPage(HttpServletResponse.SC_BAD_REQUEST, title, mq, req);
}
private Result errorPage(
- int status, String title, MessageQueue mq, Request req)
- throws IOException {
+ int status, String title, MessageQueue mq, Request req) {
Document doc = DomParser.makeDocument(null, null);
HtmlQuasiBuilder b = HtmlQuasiBuilder.getBuilder(doc);
DocumentFragment messages = Reporter.messagesToFragment(mq, req, b);
@@ -342,7 +335,7 @@
public void handle(
String tgt, HttpServletRequest req, HttpServletResponse resp,
int dispatch)
- throws IOException, ServletException {
+ throws IOException {
String method = req.getMethod();
if ("GET".equals(method)) {
servlet.doGet(req, resp);
=======================================
--- /trunk/src/com/google/caja/ancillary/servlet/Request.java Mon Nov 30
20:44:55 2009
+++ /trunk/src/com/google/caja/ancillary/servlet/Request.java Thu Dec 3
17:21:42 2009
@@ -159,8 +159,7 @@
public String manual() { return "path of the next input"; }
});
ALL_PARAM_HANDLERS.put("i", new ParamHandler() { // input source
- public void handle(String name, String val, Request c)
- throws BadInputException {
+ public void handle(String name, String val, Request c) {
String mimeType = c.itype;
String path = c.ifile;
if (mimeType != null && !"".equals(mimeType)) {
@@ -221,8 +220,7 @@
}
});
ALL_PARAM_HANDLERS.put("userAgent", new ParamHandler() {
- public void handle(String name, String val, Request c)
- throws BadInputException {
+ public void handle(String name, String val, Request c) {
c.opt = true;
c.userAgent = "*".equals(val) ? null : Glob.globToRegex(val);
}
@@ -241,8 +239,7 @@
}
});
ALL_PARAM_HANDLERS.put("ign", new ParamHandler() {
- public void handle(String name, String val, Request c)
- throws BadInputException {
+ public void handle(String name, String val, Request c) {
List<String> msgTypes = Arrays.asList(
Strings.toUpperCase(val).split("[\\s,]+"));
c.toIgnore.addAll(msgTypes);
=======================================
--- /trunk/src/com/google/caja/ancillary/servlet/StaticFiles.java Thu Dec
3 13:35:35 2009
+++ /trunk/src/com/google/caja/ancillary/servlet/StaticFiles.java Thu Dec
3 17:21:42 2009
@@ -174,7 +174,7 @@
return Collections.synchronizedMap(new LinkedHashMap<K, V>() {
@Override
public boolean removeEldestEntry(Map.Entry<K, V> e) {
- return size() > 128;
+ return size() > maxSize;
}
});
}
=======================================
--- /trunk/src/com/google/caja/ancillary/servlet/UserAgentDb.java Mon Nov
30 20:44:55 2009
+++ /trunk/src/com/google/caja/ancillary/servlet/UserAgentDb.java Thu Dec
3 17:21:42 2009
@@ -40,7 +40,6 @@
/**
* A store of user agent environment files.
*
- * @see com.google.caja.ancillary.opt
* @author [email protected]
*/
final class UserAgentDb {
=======================================
--- /trunk/tests/com/google/caja/ancillary/opt/JsOptimizerTest.java Mon Nov
30 20:13:04 2009
+++ /trunk/tests/com/google/caja/ancillary/opt/JsOptimizerTest.java Thu
Dec 3 17:21:42 2009
@@ -15,7 +15,6 @@
package com.google.caja.ancillary.opt;
import com.google.caja.lexer.FilePosition;
-import com.google.caja.lexer.ParseException;
import com.google.caja.parser.js.Block;
import com.google.caja.parser.js.ObjectConstructor;
import com.google.caja.parser.js.Statement;
@@ -78,8 +77,7 @@
js(fromString("alert(1+1);")));
}
- private void assertOptimized(Statement golden, Block... inputs)
- throws ParseException {
+ private void assertOptimized(Statement golden, Block... inputs) {
for (Block input : inputs) { opt.addInput(input); }
Statement optimized = opt.optimize();
assertEquals(renderProgram(golden), renderProgram(optimized));
=======================================
---
/trunk/tests/com/google/caja/ancillary/servlet/CajaWebToolsServletTest.java
Mon Nov 30 20:44:55 2009
+++
/trunk/tests/com/google/caja/ancillary/servlet/CajaWebToolsServletTest.java
Thu Dec 3 17:21:42 2009
@@ -57,7 +57,7 @@
super.tearDown();
}
- public final void testBadPath() throws IOException {
+ public final void testBadPath() {
new ServletTest()
.get("/bogus")
.expectStatus(404)
@@ -68,7 +68,7 @@
assertNoErrors();
}
- public final void testIndex() throws IOException {
+ public final void testIndex() {
new ServletTest()
.get("/index")
.expectStatus(200)
@@ -81,7 +81,7 @@
assertNoErrors();
}
- public final void testIndexWithPresuppliedInput() throws IOException {
+ public final void testIndexWithPresuppliedInput() {
new ServletTest()
.get("/index")
.param("i", "<p>Hello, World!</p>")
@@ -95,7 +95,7 @@
assertNoErrors();
}
- public final void testIndexWithBadParam() throws IOException {
+ public final void testIndexWithBadParam() {
new ServletTest()
.get("/index")
.param("bogus", "foo")
@@ -107,7 +107,7 @@
assertNoErrors();
}
- public final void testEcho() throws IOException {
+ public final void testEcho() {
new ServletTest()
.get("/echo")
.param("it", "text/javascript")
@@ -121,7 +121,7 @@
assertNoErrors();
}
- public final void testMinify() throws IOException {
+ public final void testMinify() {
new ServletTest()
.get("/echo")
.param("it", "text/javascript")
@@ -134,7 +134,7 @@
assertNoErrors();
}
- public final void testMinifiedWithUA1() throws IOException {
+ public final void testMinifiedWithUA1() {
new ServletTest()
.get("/echo")
.param("it", "text/javascript")
@@ -158,7 +158,7 @@
assertNoErrors();
}
- public final void testMinifiedWithUA2() throws IOException {
+ public final void testMinifiedWithUA2() {
new ServletTest()
.get("/echo")
.param("it", "text/javascript")
@@ -178,7 +178,7 @@
assertNoErrors();
}
- public final void testMinifiedWithUA3() throws IOException {
+ public final void testMinifiedWithUA3() {
new ServletTest()
.get("/echo")
.param("it", "text/javascript")
@@ -198,7 +198,7 @@
assertNoErrors();
}
- public final void testMinifyHtml() throws IOException {
+ public final void testMinifyHtml() {
new ServletTest()
.get("/echo")
.param("it", "text/html")
@@ -219,7 +219,7 @@
assertNoErrors();
}
- public final void testRenamed() throws IOException {
+ public final void testRenamed() {
new ServletTest()
.get("/echo")
.param("it", "text/javascript")
@@ -235,7 +235,7 @@
assertNoErrors();
}
- public final void testAsciiOnly() throws IOException {
+ public final void testAsciiOnly() {
new ServletTest()
.get("/echo")
.param("it", "text/javascript")
@@ -249,7 +249,7 @@
assertNoErrors();
}
- public final void testHtmlInputs() throws IOException {
+ public final void testHtmlInputs() {
new ServletTest()
.get("/echo")
.param("i", "<script>function hi(msg) { alert(msg); }</script>")
@@ -263,7 +263,7 @@
}
- public final void testLint() throws IOException {
+ public final void testLint() {
new ServletTest()
.get("/lint")
.param("i", (""
@@ -292,7 +292,7 @@
assertNoErrors();
}
- public final void testHtmlLint() throws IOException {
+ public final void testHtmlLint() {
new ServletTest()
.get("/lint")
.param("i", ("<select value=foo><option></option></select>"))
@@ -308,7 +308,7 @@
assertNoErrors();
}
- public final void testHtmlDocEcho() throws IOException {
+ public final void testHtmlDocEcho() {
new ServletTest()
.get("/echo")
.param("i",
"<html><head><title>Hello</title></hed><body>World!</body>")
@@ -323,7 +323,7 @@
assertNoErrors();
}
- public final void testDoc() throws IOException {
+ public final void testDoc() {
new ServletTest()
.get("/doc")
.param("ip", "frobbit.js")
@@ -336,7 +336,7 @@
.send();
}
- public final void testDocJar() throws IOException {
+ public final void testDocJar() {
new ServletTest()
.get("/doc")
.param("ip", "foo.js")
@@ -356,7 +356,7 @@
.send();
}
- public final void testHelp() throws IOException {
+ public final void testHelp() {
new ServletTest()
.get("/help")
.expectStatus(200)
@@ -368,7 +368,7 @@
.send();
}
- public final void testLintPageTips() throws IOException {
+ public final void testLintPageTips() {
new ServletTest()
.get("/lint")
.param("it", "text/javascript")
@@ -599,7 +599,7 @@
return this;
}
- Result send() throws IOException {
+ Result send() {
assertTrue(tests.remove(this));
result = servlet.handle(path, params);
mq.getMessages().addAll(result.mq.getMessages());
=======================================
--- /trunk/tests/com/google/caja/ancillary/servlet/ZipFileSystemTest.java
Mon Nov 30 20:44:55 2009
+++ /trunk/tests/com/google/caja/ancillary/servlet/ZipFileSystemTest.java
Thu Dec 3 17:21:42 2009
@@ -60,7 +60,7 @@
}
}
- public final void testBaseName() throws IOException {
+ public final void testBaseName() {
ZipFileSystem zfs = new ZipFileSystem("/foo");
assertEquals("", zfs.basename(""));
assertEquals("/", zfs.basename("/"));
@@ -70,7 +70,7 @@
assertEquals("bar", zfs.basename("/foo/bar/"));
}
- public final void testDirName() throws IOException {
+ public final void testDirName() {
ZipFileSystem zfs = new ZipFileSystem("/foo");
assertEquals(null, zfs.dirname(""));
assertEquals("/", zfs.dirname("/"));
@@ -81,7 +81,7 @@
assertEquals("foo", zfs.dirname("foo/bar"));
}
- public final void testJoin() throws IOException {
+ public final void testJoin() {
ZipFileSystem zfs = new ZipFileSystem("/foo");
assertEquals("foo", zfs.join(null, "foo"));
assertEquals("bar", zfs.join(null, "bar"));