Revision: 5546
Author:   [email protected]
Date:     Fri Aug  9 13:06:48 2013
Log:      Some more IDE warning fixup
https://codereview.appspot.com/12616044



[email protected]

http://code.google.com/p/google-caja/source/detail?r=5546

Modified:
 /trunk/src/com/google/caja/ancillary/linter/Linter.java
/trunk/src/com/google/caja/demos/playground/server/GWTCajolingServiceImpl.java
 /trunk/src/com/google/caja/lexer/Chardet.java
 /trunk/src/com/google/caja/parser/quasiliteral/Rule.java
 /trunk/src/com/google/caja/plugin/ExpressionSanitizerCaja.java
 /trunk/src/com/google/caja/precajole/StaticPrecajoleMap.java
 /trunk/tests/com/google/caja/parser/quasiliteral/ES53RewriterTest.java
 /trunk/tests/com/google/caja/plugin/BrowserTestCase.java
 /trunk/tests/com/google/caja/plugin/BrowserTestCatalog.java
 /trunk/tests/com/google/caja/plugin/CatalogRunner.java
 /trunk/tests/com/google/caja/plugin/templates/TemplateSanitizerTest.java
 /trunk/tests/com/google/caja/render/OrigSourceRendererTestCase.java
 /trunk/tests/com/google/caja/util/RhinoExecutor.java

=======================================
--- /trunk/src/com/google/caja/ancillary/linter/Linter.java Thu Aug 8 12:09:03 2013 +++ /trunk/src/com/google/caja/ancillary/linter/Linter.java Fri Aug 9 13:06:48 2013
@@ -261,7 +261,7 @@

     checkDeclarations(scopes, overrides, mq);
     checkLabels(lc, buckets, mq);
-    checkUses(scopes, lc.vars, sa, provides, requires, overrides, mq);
+    checkUses(scopes, lc.vars, provides, requires, overrides, mq);
     checkSideEffects(buckets, mq);
     checkDeadCode(buckets, mq);
     checkStringsEmbeddable((Block) ac.node, buckets, mq);
@@ -379,7 +379,7 @@
   }

   private static void checkUses(
-      List<LexicalScope> scopes, LiveSet liveAtEnd, ScopeAnalyzer sa,
+      List<LexicalScope> scopes, LiveSet liveAtEnd,
       Set<String> provides, Set<String> requires, Set<String> overrides,
       MessageQueue mq) {
     LexicalScope globalScope = scopes.get(0);
=======================================
--- /trunk/src/com/google/caja/demos/playground/server/GWTCajolingServiceImpl.java Wed Aug 7 17:39:21 2013 +++ /trunk/src/com/google/caja/demos/playground/server/GWTCajolingServiceImpl.java Fri Aug 9 13:06:48 2013
@@ -113,7 +113,7 @@
     return unknown;
   }

-  public String[] getMessageLevels() {
+  public static String[] getMessageLevels() {
     MessageLevel[] values = MessageLevel.values();
     String[] result = new String[values.length];
     for (int i = 0; i < values.length; i++) {
@@ -207,6 +207,7 @@
     return BuildInfo.getInstance().getBuildInfo();
   }

+  @SuppressWarnings("static-method")
   protected PluginCompiler makePluginCompiler(
       PluginMeta meta, MessageQueue mq) {
     PluginCompiler compiler = new PluginCompiler(
=======================================
--- /trunk/src/com/google/caja/lexer/Chardet.java       Wed Jul 21 13:55:01 2010
+++ /trunk/src/com/google/caja/lexer/Chardet.java       Fri Aug  9 13:06:48 2013
@@ -92,12 +92,6 @@
     } else {
// Use jchardet which tries a variety of heuristics to choose an encoding.
       nsDetector det = new nsDetector(nsPSMDetector.ALL);
-      class Observer implements nsICharsetDetectionObserver {
-        String charset;
-        public void Notify(String charset) {
-          this.charset = charset;
-        }
-      }
       // The below is adapted from the main method in HtmlCharsetDetector.
       Observer observer = new Observer();
       det.Init(observer);
@@ -117,6 +111,13 @@
         joinStreamsWithCharset(buffered.toByteArray(), in, charset),
         charset);
   }
+
+  static final class Observer implements nsICharsetDetectionObserver {
+    String charset;
+    public void Notify(String charset) {
+      this.charset = charset;
+    }
+  }

   private static final byte[] CHARSET_BYTES;
   private static final byte[] ENCODING_BYTES;
@@ -234,59 +235,59 @@
   private static Reader joinStreamsWithCharset(
       byte[] buffered, InputStream tail, String charset)
       throws IOException {
+ return new InputStreamReader(new JoinedStream(buffered, tail), charset);
+  }

-    class JoinedStream extends InputStream {
-      byte[] buffered;
-      int pos;
-      final InputStream tail;
+  static final class JoinedStream extends InputStream {
+    byte[] buffered;
+    int pos;
+    final InputStream tail;

-      JoinedStream(byte[] buffered, InputStream tail) {
-        this.buffered = buffered;
-        this.tail = tail;
+    JoinedStream(byte[] buffered, InputStream tail) {
+      this.buffered = buffered;
+      this.tail = tail;
+    }
+
+    @Override
+    public int read() throws IOException {
+      if (buffered != null) {
+        if (pos < buffered.length) { return buffered[pos++]; }
+        buffered = null;
       }
+      return tail.read();
+    }

-      @Override
-      public int read() throws IOException {
-        if (buffered != null) {
-          if (pos < buffered.length) { return buffered[pos++]; }
+    @Override
+    public int read(byte[] out, int off, int len) throws IOException {
+      int nRead = 0;
+      if (buffered != null) {
+        int avail = buffered.length - pos;
+        if (avail != 0) {
+          int k = Math.min(len, avail);
+          int p1 = pos + k;
+          int p2 = off + k;
+          pos = p1;
+          while (--p2 >= off) { out[p2] = buffered[--p1]; }
+          off += k;
+          len -= k;
+          nRead = k;
+        } else {
           buffered = null;
         }
-        return tail.read();
       }
-
-      @Override
-      public int read(byte[] out, int off, int len) throws IOException {
-        int nRead = 0;
-        if (buffered != null) {
-          int avail = buffered.length - pos;
-          if (avail != 0) {
-            int k = Math.min(len, avail);
-            int p1 = pos + k;
-            int p2 = off + k;
-            pos = p1;
-            while (--p2 >= off) { out[p2] = buffered[--p1]; }
-            off += k;
-            len -= k;
-            nRead = k;
-          } else {
-            buffered = null;
-          }
-        }
-        if (len == 0) { return nRead; }
-        int nFromTail = tail.read(out, off, len);
-        if (nFromTail > 0) { return nFromTail + nRead; }
-        return nRead != 0 ? nRead : -1;
-      }
-
-      @Override
-      public void close() throws IOException {
-        buffered = null;
-        tail.close();
-      }
+      if (len == 0) { return nRead; }
+      int nFromTail = tail.read(out, off, len);
+      if (nFromTail > 0) { return nFromTail + nRead; }
+      return nRead != 0 ? nRead : -1;
     }

- return new InputStreamReader(new JoinedStream(buffered, tail), charset);
+    @Override
+    public void close() throws IOException {
+      buffered = null;
+      tail.close();
+    }
   }
+

   private static boolean isAlnum(byte b) {
     if (b < '0' || b > 'z') { return false; }
=======================================
--- /trunk/src/com/google/caja/parser/quasiliteral/Rule.java Mon Mar 19 15:56:36 2012 +++ /trunk/src/com/google/caja/parser/quasiliteral/Rule.java Fri Aug 9 13:06:48 2013
@@ -298,7 +298,7 @@
    * We operate under the (currently unchecked) assumption
    * that node contains no variables whose names contain a "$_".
    */
-  protected String nym(ParseTreeNode node, String baseName, String ext) {
+ protected static String nym(ParseTreeNode node, String baseName, String ext) {
     String result;
     if (node != null && baseName.indexOf("$_") != -1) {
       result = baseName + "$";
@@ -322,7 +322,8 @@
    * function expression, where the name is derived from baseName.
    * For all other nodes, currently returns the node itself.
    */
- protected ParseTreeNode nymize(ParseTreeNode node, String baseName, String ext) {
+  protected static ParseTreeNode nymize(
+      ParseTreeNode node, String baseName, String ext) {
     Map<String, ParseTreeNode> bindings = makeBindings();
     if (QuasiBuilder.match("function (@ps*) {@bs*;}", node, bindings)) {
       return QuasiBuilder.substV(
=======================================
--- /trunk/src/com/google/caja/plugin/ExpressionSanitizerCaja.java Wed Aug 7 17:39:21 2013 +++ /trunk/src/com/google/caja/plugin/ExpressionSanitizerCaja.java Fri Aug 9 13:06:48 2013
@@ -76,6 +76,7 @@
     return result;
   }

+  @SuppressWarnings("static-method")
   protected Rewriter newES53Rewriter(ModuleManager mgr) {
     return new ES53Rewriter(mgr, false);
   }
=======================================
--- /trunk/src/com/google/caja/precajole/StaticPrecajoleMap.java Sun Aug 4 11:05:15 2013 +++ /trunk/src/com/google/caja/precajole/StaticPrecajoleMap.java Fri Aug 9 13:06:48 2013
@@ -263,7 +263,11 @@
       return null;
     }
     try {
-      return ByteStreams.toByteArray(is);
+      try {
+        return ByteStreams.toByteArray(is);
+      } finally {
+        is.close();
+      }
     } catch (IOException e) {
       return null;
     }
=======================================
--- /trunk/tests/com/google/caja/parser/quasiliteral/ES53RewriterTest.java Mon May 20 13:12:41 2013 +++ /trunk/tests/com/google/caja/parser/quasiliteral/ES53RewriterTest.java Fri Aug 9 13:06:48 2013
@@ -473,7 +473,7 @@
// then its NUM___ descriptor will be writable and configurable afterward.
     // This occurred because a bad test was not registering it as an own
     // property descriptor.
-
+
     // Test for symptom
     rewriteAndExecute(
         "var o = {0: 'foo'};" +
@@ -1930,7 +1930,7 @@
* Properties on any object with certain protected names such as 'toString' * are virtualized. Virtualized properties are implemented as accessors even
    * if they are data.
-   *
+   *
* Test that they appear as data or accessor properties when defined so, and
    * that the writable flag is preserved.
    */
@@ -2064,7 +2064,7 @@
         "var testImports = ___.copy(___.sharedImports);");
     for (String f : assertFunctions) {
       importsSetup
-          .append("testImports.DefineOwnProperty___('" + f + "', " +
+          .append("testImports.DefineOwnProperty___('" + f + "', " +
                       "{ value: ___.markFunc(" + f + ") });");
     }
     importsSetup.append(
=======================================
--- /trunk/tests/com/google/caja/plugin/BrowserTestCase.java Thu Aug 8 12:23:22 2013 +++ /trunk/tests/com/google/caja/plugin/BrowserTestCase.java Fri Aug 9 13:06:48 2013
@@ -246,6 +246,7 @@
   }

   /** Override point */
+  @SuppressWarnings("static-method")
   protected int waitForCompletionTimeout() {
     // 10s because the es53 cajoler is slow the first time it runs.
     return 10000;
=======================================
--- /trunk/tests/com/google/caja/plugin/BrowserTestCatalog.java Tue May 14 14:13:11 2013 +++ /trunk/tests/com/google/caja/plugin/BrowserTestCatalog.java Fri Aug 9 13:06:48 2013
@@ -45,7 +45,6 @@

   /**
    * Obtain a catalog parsed from JSON at the given <em>resource</em> URL.
-   * @throws IOException
    */
   public static BrowserTestCatalog get(URL url) throws IOException {
     // thread-safe sloppy memoization
@@ -86,16 +85,33 @@
     private ParserOutput(List<Entry> entries) {
       this.entries = entries;
     }
+    /**
+     * @param label unused in this stub.
+     * @param comment unused in this stub.
+     */
     public ParserOutput addGroup(String label, String comment) {
       return this;
     }
+    /**
+     * @param label unused in this stub.
+     * @param comment unused in this stub.
+     */
     public ParserOutput addMiniGroup(String label, String comment) {
       return this;
     }
+    /**
+     * @param label unused in this stub.
+     * @param comment unused in this stub.
+     * @param manual unused in this stub.
+     */
     public void addTest(String url, String label, String longLabel,
         String comment, boolean manual, String expectedFailure) {
       entries.add(new Entry(url, longLabel, expectedFailure));
     }
+    /**
+     * @param label unused in this stub.
+     * @param comment unused in this stub.
+     */
     public void addNonTest(String label, String comment) {}
   }

=======================================
--- /trunk/tests/com/google/caja/plugin/CatalogRunner.java Tue May 14 14:13:11 2013 +++ /trunk/tests/com/google/caja/plugin/CatalogRunner.java Fri Aug 9 13:06:48 2013
@@ -45,8 +45,7 @@
   public CatalogRunner(Class<?> testClass) throws InitializationError {
     super(testClass);
     try {
-      CatalogName annotation = (CatalogName) testClass
-          .getAnnotation(CatalogName.class);
+      CatalogName annotation = testClass.getAnnotation(CatalogName.class);
       if (annotation == null) {
         throw new NullPointerException(testClass +
             " does not have CatalogName annotation");
=======================================
--- /trunk/tests/com/google/caja/plugin/templates/TemplateSanitizerTest.java Fri Oct 12 16:44:10 2012 +++ /trunk/tests/com/google/caja/plugin/templates/TemplateSanitizerTest.java Fri Aug 9 13:06:48 2013
@@ -276,7 +276,7 @@
             "<html alpha='a' beta='b'>"
             + "<body alpha='a' background='#bbb'></body></html>")),
         "<caja-v-html data-caja-alpha=\"a\" data-caja-beta=\"b\">" +
-            "<caja-v-head></caja-v-head>" +
+            "<caja-v-head></caja-v-head>" +
"<caja-v-body data-caja-alpha=\"a\" data-caja-background=\"#bbb\">" +
             "</caja-v-body></caja-v-html>");
   }
=======================================
--- /trunk/tests/com/google/caja/render/OrigSourceRendererTestCase.java Tue Mar 30 17:26:48 2010 +++ /trunk/tests/com/google/caja/render/OrigSourceRendererTestCase.java Fri Aug 9 13:06:48 2013
@@ -96,7 +96,7 @@
       Map<InputSource, ? extends CharSequence> originalSource,
       MessageContext mc, RenderContext rc);

-  private FilePosition toFilePosition(
+  private static FilePosition toFilePosition(
       String testInputLine, Map<InputSource, String> originalSrcs) {
     Matcher m = Pattern.compile(
         "(.*):(\\d+)\\+(\\d+)-(?:(\\d+)\\+)?(\\d+)$")
=======================================
--- /trunk/tests/com/google/caja/util/RhinoExecutor.java Tue May 14 14:13:11 2013 +++ /trunk/tests/com/google/caja/util/RhinoExecutor.java Fri Aug 9 13:06:48 2013
@@ -274,6 +274,8 @@
     return sb.toString();
   }

+  // Methods are accessed reflectively by script engine.
+  @SuppressWarnings("static-method")
   public static class ScriptPowerBox {
     private final Context cx;
     private final Scriptable global;

--

--- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to