Moving Jsni helper class into com.google.gwt.dev.shell with other hosted mode code.

Review by: bobv

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@5825 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/javac/JsniCollector.java b/dev/core/src/com/google/gwt/dev/javac/JsniCollector.java
index 9555da1..e49d015 100644
--- a/dev/core/src/com/google/gwt/dev/javac/JsniCollector.java
+++ b/dev/core/src/com/google/gwt/dev/javac/JsniCollector.java
@@ -25,7 +25,6 @@
 import com.google.gwt.dev.js.ast.JsProgram;
 import com.google.gwt.dev.js.ast.JsStatement;
 import com.google.gwt.dev.util.Empty;
-import com.google.gwt.dev.util.Jsni;
 
 import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
 import org.eclipse.jdt.internal.compiler.ast.Argument;
@@ -155,6 +154,10 @@
     }
   }
 
+  public static final String JSNI_BLOCK_END = "}-*/";
+
+  public static final String JSNI_BLOCK_START = "/*-{";
+
   public static void collectJsniMethods(TreeLogger logger,
       Collection<CompilationUnit> units, JsProgram program) {
     for (CompilationUnit unit : units) {
@@ -217,19 +220,19 @@
     int bodyEnd = method.bodyEnd;
     String js = source.substring(bodyStart, bodyEnd + 1);
 
-    int jsniStart = js.indexOf(Jsni.JSNI_BLOCK_START);
+    int jsniStart = js.indexOf(JSNI_BLOCK_START);
     if (jsniStart == -1) {
       return null;
     }
 
-    int jsniEnd = js.indexOf(Jsni.JSNI_BLOCK_END, jsniStart);
+    int jsniEnd = js.indexOf(JSNI_BLOCK_END, jsniStart);
     if (jsniEnd == -1) {
       // Suspicious, but maybe this is just a weird comment, so let it slide.
       //
       return null;
     }
 
-    int srcStart = bodyStart + jsniStart + Jsni.JSNI_BLOCK_START.length();
+    int srcStart = bodyStart + jsniStart + JSNI_BLOCK_START.length();
     int srcEnd = bodyStart + jsniEnd;
     return new Interval(srcStart, srcEnd);
   }
diff --git a/dev/core/src/com/google/gwt/dev/jdt/FindJsniRefVisitor.java b/dev/core/src/com/google/gwt/dev/jdt/FindJsniRefVisitor.java
index 2c3314f..1f7a4ba 100644
--- a/dev/core/src/com/google/gwt/dev/jdt/FindJsniRefVisitor.java
+++ b/dev/core/src/com/google/gwt/dev/jdt/FindJsniRefVisitor.java
@@ -15,6 +15,7 @@
  */
 package com.google.gwt.dev.jdt;
 
+import com.google.gwt.dev.javac.JsniCollector;
 import com.google.gwt.dev.jjs.InternalCompilerException;
 import com.google.gwt.dev.jjs.SourceOrigin;
 import com.google.gwt.dev.js.JsParser;
@@ -29,7 +30,6 @@
 import com.google.gwt.dev.js.rhino.ErrorReporter;
 import com.google.gwt.dev.js.rhino.EvaluatorException;
 import com.google.gwt.dev.js.rhino.TokenStream;
-import com.google.gwt.dev.util.Jsni;
 
 import org.eclipse.jdt.internal.compiler.ASTVisitor;
 import org.eclipse.jdt.internal.compiler.ast.Argument;
@@ -175,13 +175,13 @@
     char[] source = methodDeclaration.compilationResult().getCompilationUnit().getContents();
     String jsniCode = String.valueOf(source, methodDeclaration.bodyStart,
         methodDeclaration.bodyEnd - methodDeclaration.bodyStart + 1);
-    int startPos = jsniCode.indexOf(Jsni.JSNI_BLOCK_START);
-    int endPos = jsniCode.lastIndexOf(Jsni.JSNI_BLOCK_END);
+    int startPos = jsniCode.indexOf(JsniCollector.JSNI_BLOCK_START);
+    int endPos = jsniCode.lastIndexOf(JsniCollector.JSNI_BLOCK_END);
     if (startPos < 0 || endPos < 0) {
       return null; // ignore the error
     }
 
-    startPos += Jsni.JSNI_BLOCK_START.length() - 1; // move up to open brace
+    startPos += JsniCollector.JSNI_BLOCK_START.length() - 1; // move up to open brace
     endPos += 1; // move past close brace
 
     jsniCode = jsniCode.substring(startPos, endPos);
diff --git a/dev/core/src/com/google/gwt/dev/util/Jsni.java b/dev/core/src/com/google/gwt/dev/shell/Jsni.java
similarity index 93%
rename from dev/core/src/com/google/gwt/dev/util/Jsni.java
rename to dev/core/src/com/google/gwt/dev/shell/Jsni.java
index fa1dcbb..a4dcbb0 100644
--- a/dev/core/src/com/google/gwt/dev/util/Jsni.java
+++ b/dev/core/src/com/google/gwt/dev/shell/Jsni.java
@@ -13,7 +13,7 @@
  * License for the specific language governing permissions and limitations under
  * the License.
  */
-package com.google.gwt.dev.util;
+package com.google.gwt.dev.shell;
 
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.dev.javac.JsniMethod;
@@ -23,8 +23,8 @@
 import com.google.gwt.dev.js.ast.JsFunction;
 import com.google.gwt.dev.js.ast.JsNameRef;
 import com.google.gwt.dev.js.ast.JsNode;
-import com.google.gwt.dev.shell.DispatchIdOracle;
-import com.google.gwt.dev.shell.JavaScriptHost;
+import com.google.gwt.dev.util.DefaultTextOutput;
+import com.google.gwt.dev.util.TextOutput;
 
 /**
  * Helper methods working with JSNI.
@@ -94,10 +94,6 @@
 
   public static final String JAVASCRIPTHOST_NAME = JavaScriptHost.class.getName();
 
-  public static final String JSNI_BLOCK_END = "}-*/";
-
-  public static final String JSNI_BLOCK_START = "/*-{";
-
   /**
    * Gets the body of a JSNI method, with Java refs escaped for hosted mode
    * injection.
diff --git a/dev/linux/src/com/google/gwt/dev/shell/moz/ModuleSpaceMoz.java b/dev/linux/src/com/google/gwt/dev/shell/moz/ModuleSpaceMoz.java
index 2b608f4..874be51 100644
--- a/dev/linux/src/com/google/gwt/dev/shell/moz/ModuleSpaceMoz.java
+++ b/dev/linux/src/com/google/gwt/dev/shell/moz/ModuleSpaceMoz.java
@@ -21,9 +21,9 @@
 import com.google.gwt.dev.shell.DispatchIdOracle;
 import com.google.gwt.dev.shell.JsValue;
 import com.google.gwt.dev.shell.JsValueGlue;
+import com.google.gwt.dev.shell.Jsni;
 import com.google.gwt.dev.shell.ModuleSpace;
 import com.google.gwt.dev.shell.ModuleSpaceHost;
-import com.google.gwt.dev.util.Jsni;
 
 import java.util.List;
 
diff --git a/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java b/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java
index 036edc6..07d6408 100644
--- a/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java
+++ b/dev/mac/src/com/google/gwt/dev/shell/mac/ModuleSpaceSaf.java
@@ -21,9 +21,9 @@
 import com.google.gwt.dev.shell.DispatchIdOracle;
 import com.google.gwt.dev.shell.JsValue;
 import com.google.gwt.dev.shell.JsValueGlue;
+import com.google.gwt.dev.shell.Jsni;
 import com.google.gwt.dev.shell.ModuleSpace;
 import com.google.gwt.dev.shell.ModuleSpaceHost;
-import com.google.gwt.dev.util.Jsni;
 
 import java.util.List;
 
diff --git a/dev/oophm/overlay/com/google/gwt/dev/util/Jsni.java b/dev/oophm/overlay/com/google/gwt/dev/shell/Jsni.java
similarity index 96%
rename from dev/oophm/overlay/com/google/gwt/dev/util/Jsni.java
rename to dev/oophm/overlay/com/google/gwt/dev/shell/Jsni.java
index 18a40a5..bc99efd 100644
--- a/dev/oophm/overlay/com/google/gwt/dev/util/Jsni.java
+++ b/dev/oophm/overlay/com/google/gwt/dev/shell/Jsni.java
@@ -13,7 +13,7 @@
  * License for the specific language governing permissions and limitations under
  * the License.
  */
-package com.google.gwt.dev.util;
+package com.google.gwt.dev.shell;
 
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.dev.javac.JsniMethod;
@@ -26,9 +26,8 @@
 import com.google.gwt.dev.js.ast.JsNameRef;
 import com.google.gwt.dev.js.ast.JsNode;
 import com.google.gwt.dev.js.ast.JsProgram;
-import com.google.gwt.dev.shell.DispatchIdOracle;
-import com.google.gwt.dev.shell.JavaScriptHost;
-import com.google.gwt.dev.shell.SyntheticClassMember;
+import com.google.gwt.dev.util.DefaultTextOutput;
+import com.google.gwt.dev.util.TextOutput;
 
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
@@ -228,10 +227,6 @@
 
   public static final String JAVASCRIPTHOST_NAME = JavaScriptHost.class.getName();
 
-  public static final String JSNI_BLOCK_END = "}-*/";
-
-  public static final String JSNI_BLOCK_START = "/*-{";
-
   /**
    * Gets the body of a JSNI method, with Java refs escaped for hosted mode
    * injection.
diff --git a/dev/oophm/src/com/google/gwt/dev/shell/ModuleSpaceOOPHM.java b/dev/oophm/src/com/google/gwt/dev/shell/ModuleSpaceOOPHM.java
index 2df0a69..67805b0 100644
--- a/dev/oophm/src/com/google/gwt/dev/shell/ModuleSpaceOOPHM.java
+++ b/dev/oophm/src/com/google/gwt/dev/shell/ModuleSpaceOOPHM.java
@@ -18,7 +18,6 @@
 import com.google.gwt.core.ext.TreeLogger;
 import com.google.gwt.dev.javac.JsniMethod;
 import com.google.gwt.dev.shell.JsValue.DispatchObject;
-import com.google.gwt.dev.util.Jsni;
 
 import java.util.List;
 import java.util.Set;
diff --git a/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java b/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java
index b666b0b..f86fed0 100644
--- a/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java
+++ b/dev/windows/src/com/google/gwt/dev/shell/ie/ModuleSpaceIE6.java
@@ -20,10 +20,10 @@
 import com.google.gwt.dev.shell.CompilingClassLoader;
 import com.google.gwt.dev.shell.DispatchIdOracle;
 import com.google.gwt.dev.shell.JsValue;
+import com.google.gwt.dev.shell.Jsni;
 import com.google.gwt.dev.shell.ModuleSpace;
 import com.google.gwt.dev.shell.ModuleSpaceHost;
 import com.google.gwt.dev.shell.ie.IDispatchImpl.HResultException;
-import com.google.gwt.dev.util.Jsni;
 
 import org.eclipse.swt.internal.ole.win32.IDispatch;
 import org.eclipse.swt.ole.win32.OleAutomation;